private GameBoard baseResult(GameBoard board) { int bestScore = int.MinValue; GameBoard output = board; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (!board.canPlayAtPosition(x, y)) continue; GameBoard playBoard = board.makeMove(x, y); int score = evaluateBoard(board.currentTurn, playBoard); if (score > bestScore) { bestScore = score; output = playBoard; } } } return output; }
private GameBoard getResultOfNPlay(GameBoard board, int ply) { if (ply == 0) return baseResult(board); int bestScore = int.MinValue; GameBoard output = board; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (!board.canPlayAtPosition(x, y)) continue; GameBoard playBoard = board.makeMove(x, y); GameBoard result = getResultOfNPlay(playBoard, ply - 1); int score = evaluateBoard(board.currentTurn, result); if (score > bestScore) { bestScore = score; output = result; } } } return output; }