public override CheckersMove NextMove(CheckersGame game) { const int minValue = int.MaxValue; int maxValue = int.MinValue; CheckersMove bestMove = null; // Enumerate all moves foreach (CheckersMove move in game.EnumLegalMoves()) { if (!game.IsPlaying) { break; } CheckersGame nextGameState = game.Clone(); nextGameState.MovePiece(move.Clone(nextGameState)); int curValue = minMove(game, nextGameState, 1, maxValue, minValue); if ((curValue > maxValue) || (bestMove == null)) { maxValue = curValue; bestMove = move; } OnTick(game); } return(bestMove); }
public override CheckersMove NextMove(CheckersGame game) { const int minValue = int.MaxValue; int maxValue = int.MinValue; CheckersMove bestMove = null; // Enumerate all moves foreach(CheckersMove move in game.EnumLegalMoves()) { if(!game.IsPlaying) break; CheckersGame nextGameState = game.Clone(); nextGameState.MovePiece(move.Clone(nextGameState)); int curValue = minMove(game, nextGameState, 1, maxValue, minValue); if((curValue > maxValue) || (bestMove == null)) { maxValue = curValue; bestMove = move; } OnTick(game); } return bestMove; }