예제 #1
0
        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
        private void makeMove(Move move)
        {
            if (model.TryMakeMove(currentPlayer.Colour, move))
            {
                currentPlayer = player1 == currentPlayer ? player2 : player1;
                MoveHistory.Add(move);
                UIUpdateActionOnLegalMove();

                CheckForGameCompletion();
            }
        }
예제 #3
0
        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);
        }