Exemple #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);
        }
        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);
            }
        }
Exemple #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);
        }
Exemple #4
0
 public Move GetNextMove(CheckersModel gameModel)
 {
     return(new Move(fromRowClicked, fromColClicked, toRowClicked, toColClicked));
 }
Exemple #5
0
 public Move GetNextMove(CheckersModel gameModel)
 {
     return(miniMax(gameModel));
 }