public override Move <ConnectFourToken> GetNextMove(IBoardGame <ConnectFourToken> game) { string input; Move <ConnectFourToken> move; do { Console.Write($"Player {this}, enter a column number [{1}, {game.Width}]: "); input = Console.ReadLine(); }while (!int.TryParse(input, out int result) || !game.IsMoveAllowed(move = new Move <ConnectFourToken>(this, new Coordinate(result, 1)))); return(move); }
public override Move <ConnectFourToken> GetNextMove(IBoardGame <ConnectFourToken> game) { ConnectFourGame clone = (ConnectFourGame)game.Clone(); (Move <ConnectFourToken> nextMove, int _) = Minimax( moveAndPosition: (Move <ConnectFourToken> .Default, clone), depth: MinimaxDepth, alpha: int.MinValue, beta: int.MaxValue, currentPlayer: clone.CurrentPlayer, maximizingCurrentPlayer: true); if (!game.IsMoveAllowed(nextMove)) { throw new InvalidOperationException(); } return(nextMove); }