コード例 #1
0
        public void TestBWinNextTurn()
        {
            UltimateBoard b = Games.GetBoard(Games.Draw, 53);

            b.Play((1, 0, 1, 0));
            b.Play((1, 0, 0, 0));
            b.Play((0, 1, 2, 0));
            b.Play((1, 0, 1, 2));
            b.Play((0, 2, 1, 0)); // Now the only available play wins the game.
            Assert.That(RandomSimulator.Simulate(b), Is.EqualTo(0));
        }
コード例 #2
0
        public void TestELargerTree()
        {
            UltimateBoard b = Games.GetBoard(Games.Draw, 53);

            b.Play((1, 0, 1, 0));
            b.Play((1, 0, 0, 0));
            b.Play((0, 1, 2, 0));
            b.Play((1, 0, 1, 2));
            float sum = 0;

            for (int i = 0; i < 1000; i++)
            {
                sum += RandomSimulator.Simulate(new UltimateBoard(b));
            }
            Assert.That(sum / 1000, Is.GreaterThan(0.76).And.LessThan(0.86));
        }
コード例 #3
0
        public void TestADrawnGame()
        {
            UltimateBoard b = Games.GetBoard(Games.Draw, Games.Draw.Length); // Play the game to the end.

            Assert.That(RandomSimulator.Simulate(b), Is.EqualTo(0.5f));
        }
コード例 #4
0
        public void TestAWonBySecond()
        {
            UltimateBoard b = Games.GetBoard(Games.OWins, Games.OWins.Length); // Play the game until O wins.

            Assert.That(RandomSimulator.Simulate(b), Is.EqualTo(1));
        }