public void makeAiMove() { // System.out.println("Presenter makeAiMove"); if (state.isGameOver()) { return; } AlphaBetaPruning ai = new AlphaBetaPruning(new Heuristic()); Integer aiMove = ai.findBestMove(state, 5, new DateTimer(3000)); System.out.println("P MAIM state: " + state); System.out.println("P MAIM move: " + aiMove); State oldState = state.copyState(); stateToSetAfterAnimation = state.copyState(); stateToSetAfterAnimation.makeMove(aiMove); makeAnimatedMove(aiMove, oldState); // state.makeMove(aiMove); System.out.println("State after Move: " + state); // setState(state); // graphics.sendMoveToServerAI(aiMove, state); // this will be made in the graphics after the move was saved // if (state.getWhoseTurn().equals(usersSide.getOpposite())) // makeAiMove(); }
/** Set a message in the case of game over */ void message() { if (state.isGameOver()) { graphics.gameOverSound(); String msg = ""; if (state.winner() == null) { msg = messages.tie(); } else { String winner = state.winner().isNorth() ? "North" : "South"; msg = messages.winnerIs(winner, state.score() + ""); } graphics.setMessage(msg); publish(msg); } }