- Created a GameGoal class to encapsulate the expected computer behavior/target score for a game. The PlayerModel.java function getTargetScore() now returns a GameGoal object.

This commit is contained in:
Marshall
2012-04-26 12:08:17 -04:00
parent b8a13a87d0
commit 0cfe26faf1
4 changed files with 92 additions and 61 deletions

View File

@@ -6,7 +6,6 @@ import org.apache.log4j.Logger;
import player.AlphaBetaComPlayer;
import player.HumanPlayer;
import player.MinimaxComPlayer;
import player.Player;
import view.BoardPanel;
import view.MessagePanel;
@@ -16,16 +15,16 @@ public class Referee implements Runnable {
public static final String COM_TURN = "Waiting for the computer's move.";
public static final String GAME_OVER = "Game over!";
public static final String PLAYER_TURN = "Waiting for the player's move.";
public static final Logger LOGGER = Logger.getLogger(Referee.class
.getName());
public static final String PLAYER_TURN = "Waiting for the player's move.";
private final Board board;
private final HumanPlayer humanPlayer = new HumanPlayer();
private BoardPanel boardPanel;
private final Player computerPlayer;
private BoardPanel boardPanel;
private final HumanPlayer humanPlayer = new HumanPlayer();
private MessagePanel messagePanel;
private ScorePanel scorePanel;
@@ -34,6 +33,40 @@ public class Referee implements Runnable {
computerPlayer = new AlphaBetaComPlayer();
}
public Player getComputerPlayer() {
return computerPlayer;
}
public HumanPlayer getHumanPlayer() {
return humanPlayer;
}
public String getMessage() {
if (isOver()) {
return GAME_OVER;
} else if (board.isPlayerTurn()) {
return PLAYER_TURN;
} else {
return COM_TURN;
}
}
public int getPlayerScore() {
return board.getTurn();
}
public TileColor getTile(int r, int c) {
return board.getTile(r, c);
}
public boolean isOver() {
return board.isTerminalState();
}
public void playToken(Move move) {
board.playTile(move.getCell(), move.getColor());
}
@Override
public void run() {
int plies = 0;
@@ -76,40 +109,6 @@ public class Referee implements Runnable {
}
}
public Player getComputerPlayer() {
return computerPlayer;
}
public HumanPlayer getHumanPlayer() {
return humanPlayer;
}
public String getMessage() {
if (isOver()) {
return GAME_OVER;
} else if (board.isPlayerTurn()) {
return PLAYER_TURN;
} else {
return COM_TURN;
}
}
public int getPlayerScore() {
return board.getTurn();
}
public TileColor getTile(int r, int c) {
return board.getTile(r, c);
}
public boolean isOver() {
return board.isTerminalState();
}
public void playToken(Move move) {
board.playTile(move.getCell(), move.getColor());
}
public void setBoardPanel(BoardPanel boardPanel) {
this.boardPanel = boardPanel;
}