コード例 #1
0
ファイル: AIPlayer.cs プロジェクト: Gregoryann/CheckersGame
        private double maxValue(CheckersModel gameClone, int depth)
        {
            var moves = shuffle(gameClone.GetPossibleMoves(Colour));

            if (moves.Count == 0)
            {
                return(double.MinValue);
            }
            if (depth == 0)
            {
                return(gameClone.CountPiecesOfColour(Colour) - gameClone.CountPiecesOfColour(Colour.MyEnemy()));
            }

            var maxFound = double.MinValue;

            foreach (var move in moves)
            {
                CheckersModel clone = gameClone.Clone();
                if (!clone.TryMakeMove(Colour, move))
                {
                    Console.WriteLine("YOU ALSO F****D UP");
                }
                maxFound = Math.Max(maxFound, minValue(clone, depth - 1));
            }
            return(maxFound);
        }
コード例 #2
0
        public void Reset(List <Move> playUpTo = null)
        {
            model         = new CheckersModel();
            currentPlayer = player1;
            MoveHistory   = new List <Move>();

            //No moves to play? Then skip out early
            if (playUpTo == null)
            {
                return;
            }

            foreach (var move in playUpTo)
            {
                makeMove(move);
            }
        }
コード例 #3
0
ファイル: AIPlayer.cs プロジェクト: Gregoryann/CheckersGame
        private Move miniMax(CheckersModel gameModel, int depth = 5)
        {
            var bestScore = double.MinValue;
            var bestMove  = Move.Empty;

            foreach (var move in shuffle(gameModel.GetPossibleMoves(Colour)))
            {
                CheckersModel clone = gameModel.Clone();
                clone.TryMakeMove(Colour, move);

                var score = minValue(clone, depth - 1);
                if (score >= bestScore)
                {
                    bestMove  = move;
                    bestScore = score;
                }
            }
            return(bestMove);
        }
コード例 #4
0
 public Move GetNextMove(CheckersModel gameModel)
 {
     return(new Move(fromRowClicked, fromColClicked, toRowClicked, toColClicked));
 }
コード例 #5
0
ファイル: AIPlayer.cs プロジェクト: Gregoryann/CheckersGame
 public Move GetNextMove(CheckersModel gameModel)
 {
     return(miniMax(gameModel));
 }