Пример #1
0
        private static void TestBestMove(HexGame game, int level, Location expectedBestMove)
        {
            Minimax hexPlayer = new Minimax(game.Board, game.GoodMoves, new CandidateMovesAll());
            MinimaxResult bestMove = hexPlayer.DoMinimax(level, true);

            // test the location of the move
            Assert.AreEqual(expectedBestMove, bestMove.Move, "Wrong move at level " + level);

            // test the expected score
            if (level >= 3)
            {
                Assert.AreEqual(Occupied.PlayerX,  MoveScoreConverter.Winner(bestMove.Score));
            }
        }
Пример #2
0
        private static Minimax MakeMinimaxForBoard(HexBoard board)
        {
            GoodMoves goodMoves = new GoodMoves();
            ICandidateMoves candidateMovesFinder = new CandidateMovesAll();

            Minimax result = new Minimax(board, goodMoves, candidateMovesFinder);
            result.GenerateDebugData = true;

            return result;
        }
Пример #3
0
        private void DoMove()
        {
            Minimax hexPlayer = new Minimax(this.hexGame.Board, this.hexGame.GoodMoves, this.MakeCandiateMovesFinder());
            MinimaxResult minimaxResult = hexPlayer.DoMinimax(this.computerSkillLevel, this.MoveIsPlayerX());
            this.PlayLocation = this.GetBestMove(minimaxResult);
            this.MoveTime = hexPlayer.MoveTime;

            this.CallCompletedAction();
        }
Пример #4
0
        private static void DoTestTestNoLingeringWin(Minimax minimax, int depth)
        {
            MinimaxResult result = minimax.DoMinimax(depth, true);

            int bestMoveScore = result.Score;

            // play here to win
            Location expectedMove = new Location(0, 4);
            Assert.AreEqual(expectedMove, result.Move, "Wrong best move at depth " + depth);

            AssertWinner(bestMoveScore, Occupied.PlayerX);
        }