Пример #1
0
        public void Test1()
        {
            var first = new[]
            {
                Played.Self, Played.Empty, Played.Empty,
                Played.Empty, Played.Self, Played.Empty,
                Played.Empty, Played.Empty, Played.Self,
            };
            var empty = new[]
            {
                Played.Empty, Played.Empty, Played.Empty,
                Played.Empty, Played.Empty, Played.Empty,
                Played.Empty, Played.Empty, Played.Empty,
            };
            var board = new[]
            {
                first, empty, empty,
                empty, empty, empty,
                empty, empty, empty,
            };
            var score = Constants.WinCorner + Constants.CenterSquareAnyBoard + Constants.SmallBoardWin;

            Assert.AreEqual(AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board)), score);
            Invert(board);
            Assert.AreEqual(AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board)), score * -1);
        }
Пример #2
0
        public void TestScoringEmpty()
        {
            var board = new Played[9][];

            for (var i = 0; i < 9; i++)
            {
                board[i] = new Played[9];
                for (var j = 0; j < 9; j++)
                {
                    board[i][j] = Played.Empty;
                }
            }

            var score = AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board));

            Assert.AreEqual(score, 0);
        }
Пример #3
0
        public void Test2()
        {
            var board = new[]
            {
                new[]
                {
                    Played.Opponent, Played.Self, Played.Empty,
                    Played.Empty, Played.Empty, Played.Empty,
                    Played.Empty, Played.Empty, Played.Empty,
                },

                new[]
                {
                    Played.Empty, Played.Self, Played.Empty,
                    Played.Opponent, Played.Empty, Played.Empty,
                    Played.Empty, Played.Empty, Played.Empty,
                },
                new[]
                {
                    Played.Empty, Played.Self, Played.Empty,
                    Played.Empty, Played.Empty, Played.Empty,
                    Played.Empty, Played.Self, Played.Empty,
                },
                new[]
                {
                    Played.Self, Played.Empty, Played.Empty,
                    Played.Opponent, Played.Opponent, Played.Opponent,
                    Played.Empty, Played.Self, Played.Empty,
                },
                new[]
                {
                    Played.Self, Played.Opponent, Played.Empty,
                    Played.Self, Played.Empty, Played.Empty,
                    Played.Self, Played.Opponent, Played.Opponent,
                },
                new[]
                {
                    Played.Empty, Played.Empty, Played.Opponent,
                    Played.Empty, Played.Self, Played.Empty,
                    Played.Opponent, Played.Empty, Played.Empty,
                },
                new[]
                {
                    Played.Empty, Played.Empty, Played.Opponent,
                    Played.Opponent, Played.Empty, Played.Empty,
                    Played.Self, Played.Self, Played.Self,
                },
                new[]
                {
                    Played.Empty, Played.Empty, Played.Empty,
                    Played.Empty, Played.Empty, Played.Empty,
                    Played.Opponent, Played.Empty, Played.Empty,
                },
                new[]
                {
                    Played.Opponent, Played.Self, Played.Empty,
                    Played.Empty, Played.Empty, Played.Self,
                    Played.Empty, Played.Opponent, Played.Self,
                }
            };

            Assert.AreEqual(44, AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board)));
            Invert(board);
            Assert.AreEqual(-44, AlgoHeuristic.ComputeScore(board, AlgoHeuristic.GetBoardResult(board)));
        }