/** * Returns a new <code>Move</code> by this player. Internally records the move (update the * internal game board) as a move by this player. Changes search depth based on whether pieces are * being added or stepped * * @return the Move chosen by this player */ public Move chooseMove() { int maxDepth = searchDepth; if (maxDepth == VARDEPTH) { if (board.getNumPieces(color) > 8) // Step move maxDepth = 4; else // Add move maxDepth = 4; } Move m; if (board.getNumPieces(color) == 0) { // First move starts in center m = new Move(3, 3); if (!board.isValidMove(m, color)) m = new Move(3, 4); } else { ScoreMove sm = chooseMove(maxDepth, color, Scorer.MINSCORE - 1, Scorer.MAXSCORE + 1); m = sm.move; Scorer.clearCache(); } board.makeMove(m, color); return m; }
/** * Forces this player to make the specified move if legal and returns true. If the move is not * legal, returns false and does not record the move. * * @param m the Move forced to make * @return true if legal move, false otherwise */ public boolean forceMove(Move m) { if (!board.isValidMove(m, color)) return false; board.makeMove(m, color); return true; }
/** * Records the specified move as a move by the opponent if it is legal and returns true. If the * move is not legal, returns false and does not record the move. * * @param m the Move provided by the opponent * @return true if legal move, false otherwise */ public boolean opponentMove(Move m) { if (!board.isValidMove(m, oppositeColor(color))) return false; board.makeMove(m, oppositeColor(color)); return true; }