Exemplo n.º 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));
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
        }