// AlphaBeta should be no different from Minimax regarding the quality of decision making,
        //  only faster, so they should always draw against each other
        public void PlayerAIAlphaBeta9_vsPlayerAIMinimax9_AlwaysATie()
        {
            // Arrange
            Player minimax   = new PlayerAIMinimax('X', "Minimax", 9);
            Player alphabeta = new PlayerAIAlphaBeta('O', "AlphaBeta", 9);

            // Act & Assert
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(minimax, alphabeta), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(alphabeta, minimax), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
        }
        // minimax with AlphaBeta with sufficient depth will always draw against itself
        public void PlayerAIAlphaBeta9_vsPlayerAIAlphaBeta9_AlwaysATie()
        {
            // Arrange
            Player alphabeta1 = new PlayerAIAlphaBeta('X', "AlphaBeta1", 9);
            Player alphabeta2 = new PlayerAIAlphaBeta('O', "AlphaBeta2", 9);

            // Act & Assert
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(alphabeta1, alphabeta2), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(alphabeta2, alphabeta1), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
        }
Пример #3
0
        // If we let two perfect minimaxing AIs play against each other, they should always tie.
        public void PlayerAIMinimax9_vsPlayerAIMinimax9_AlwaysATie()
        {
            // Arrange
            Player minimax1 = new PlayerAIMinimax('X', "Minimax1", 9);
            Player minimax2 = new PlayerAIMinimax('O', "Minimax2", 9);

            // Act & Assert
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(minimax1, minimax2), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(minimax2, minimax1), Is.Not.EqualTo(-1).And.Not.EqualTo(1));
            }
        }
        // just like minimax, minimax with alphabeta should never lose to a random AI
        public void PlayerAIAlphaBeta9_vsPlayerAIRandom_NeverLoses()
        {
            // Arrange
            Player alphabeta = new PlayerAIAlphaBeta('X', "AlphaBeta", 9);
            Player random    = new PlayerAIRandom('O', "Random");

            // Act & Assert
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(alphabeta, random), Is.Not.EqualTo(-1));
            }

            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(random, alphabeta), Is.Not.EqualTo(1));
            }
        }
Пример #5
0
        // If we let a perfect minimaxing AI play against an AI that picks randomly, the minimaxer should never lose.
        public void PlayerAIMinimax9_vsPlayerAIRandom_NeverLoses()
        {
            // Arrange
            Player minimax = new PlayerAIMinimax('X', "Minimax", 9);
            Player random  = new PlayerAIRandom('O', "Random");

            // Act & Assert
            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(minimax, random), Is.Not.EqualTo(-1));
            }

            for (int i = 0; i < iterations; i++)
            {
                Assert.That(TestsMain.SimulateGame(random, minimax), Is.Not.EqualTo(1));
            }
        }