@Before public void setup() { board = new Board(); player1 = new Player(true, "martijn"); board.addPlayer(player1); player2 = new Player(false, "nietMartijn"); board.addPlayer(player2); Thread t = new Thread(new InputReader(board)); t.start(); }
public static void main(String[] args) throws Exception { Board board = new Board(); IPlayer humanPlayer = new HumanPlayer(); IPlayer AIPlayer = new AIPlayer(); IPlayer currentPlayer = humanPlayer; while (!board.isGameOver()) { if (humanPlayer == currentPlayer) { HumanBoardGUI gui = new HumanBoardGUI(board); JFrame frame = BoardGUI.addToFrame(gui); Move move = gui.getHumanMove(); boolean moveSuccessful = board.execute(move); if (moveSuccessful) currentPlayer = AIPlayer; else System.out.println("Human made bad move"); frame.setVisible(false); } else { Move move = AIPlayer.getMove(board); boolean moveSuccessful = board.execute(move); if (moveSuccessful) currentPlayer = humanPlayer; else System.out.println("AIPlayer made bad move: " + move); } } }