示例#1
0
        private static void PlayerScoreBlankBoard(IPathLengthFactory pathLengthFactory)
        {
            HexBoard       hexBoard   = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // blank board
            int xScore = pathLength.PlayerScore(true);
            int yScore = pathLength.PlayerScore(false);

            Assert.AreEqual(xScore, yScore, "x and y score");

            // no advantage
            int equalMoveScore = pathLength.SituationScore();

            Assert.AreEqual(equalMoveScore, 0, "equalMoveScore");

            // all cells still on the clean path
            pathLength.PlayerScore(true);
            List <Location> cleanPathX = pathLength.GetCleanPath(true);

            pathLength.PlayerScore(false);
            List <Location> cleanPathY = pathLength.GetCleanPath(false);

            const int AllCellsCount = BoardSize * BoardSize;

            Assert.AreEqual(AllCellsCount, cleanPathX.Count, "Clean path x should have all cells");
            Assert.AreEqual(AllCellsCount, cleanPathY.Count, "Clean path y should have all cells");
        }
示例#2
0
        private static void PlayerScoreZigZag(IPathLengthFactory pathLengthFactory)
        {
            HexBoard       hexBoard   = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            for (int y = 0; y < hexBoard.Size - 1; y++)
            {
                hexBoard.PlayMove(2, y, true);
                hexBoard.PlayMove(5, hexBoard.Size - (1 + y), true);

                int xScore = pathLength.PlayerScore(true);
                Assert.IsTrue(xScore > 0);

                int yScore = pathLength.PlayerScore(false);
                Assert.IsTrue(yScore >= hexBoard.Size);
                if (y > (hexBoard.Size / 2))
                {
                    Assert.IsTrue(yScore > xScore);
                }

                // some advantage to player 1
                int advantageMoveScore = pathLength.SituationScore();
                Assert.IsTrue(advantageMoveScore >= y);
            }
        }
示例#3
0
        private static void PlayerScorePartBarricade(IPathLengthFactory pathLengthFactory)
        {
            HexBoard       hexBoard   = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // partly baricaded board
            for (int y = 0; y < hexBoard.Size; y++)
            {
                if ((y % 2) == 0)
                {
                    hexBoard.PlayMove(2, y, true);
                }
            }

            int xScore = pathLength.PlayerScore(true);

            Assert.IsTrue(xScore > 0);

            int yScore = pathLength.PlayerScore(false);

            Assert.IsTrue(yScore > xScore);

            // some advantage to player 1
            int advantageMoveScore = pathLength.SituationScore();

            Assert.IsTrue(advantageMoveScore > 0);
        }
示例#4
0
 private static void AllTests(IPathLengthFactory pathLengthFactory)
 {
     PlayerScoreBlankBoard(pathLengthFactory);
     PlayerScoreBaricaded(pathLengthFactory);
     PlayerScoreAlmostBarricaded(pathLengthFactory);
     PlayerScorePartBarricade(pathLengthFactory);
     PlayerScoreZigZag(pathLengthFactory);
 }
示例#5
0
 private static void AllTests(IPathLengthFactory pathLengthFactory)
 {
     PlayerScoreBlankBoard(pathLengthFactory);
     PlayerScoreBaricaded(pathLengthFactory);
     PlayerScoreAlmostBarricaded(pathLengthFactory);
     PlayerScorePartBarricade(pathLengthFactory);
     PlayerScoreZigZag(pathLengthFactory);
 }
示例#6
0
        public Minimax(HexBoard board, GoodMoves goodMoves, ICandidateMoves candidateMovesFinder)
        {
            this.actualBoard = board;
            this.goodMoves = goodMoves;
            this.candidateMovesFinder = candidateMovesFinder;

            this.boardCache = new BoardCache(board.Size);
            this.pathLengthFactory = new PathLengthAStarFactory();
        }
示例#7
0
        public Minimax(HexBoard board, GoodMoves goodMoves, ICandidateMoves candidateMovesFinder)
        {
            this.actualBoard          = board;
            this.goodMoves            = goodMoves;
            this.candidateMovesFinder = candidateMovesFinder;

            this.boardCache        = new BoardCache(board.Size);
            this.pathLengthFactory = new PathLengthAStarFactory();
        }
示例#8
0
        public Minimax(HexBoard board, GoodMoves goodMoves, ICandidateMoves candidateMovesFinder)
        {
            this.board = board;

            this.depth = 0;

            this.candidateMovesFinder = candidateMovesFinder;
            this.pathLengthFactory    = new PathLengthAStarFactory();
            GoodMoves = goodMoves;
        }
示例#9
0
        private static void PlayerScoreBaricaded(IPathLengthFactory pathLengthFactory)
        {
            HexBoard       hexBoard   = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // baricaded board
            for (int y = 0; y < hexBoard.Size; y++)
            {
                hexBoard.PlayMove(2, y, true);
            }

            int xScore = pathLength.PlayerScore(true);

            Assert.AreEqual(xScore, 0);

            int yScore = pathLength.PlayerScore(false);

            Assert.IsTrue(yScore > hexBoard.Size);

            // winning advantage to player 1
            int winMoveScore = pathLength.SituationScore();

            AssertWinner(winMoveScore, Occupied.PlayerX);
        }
示例#10
0
        private static void PlayerScoreAlmostBarricaded(IPathLengthFactory pathLengthFactory)
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // almost barricated board
            for (int y = 0; y < hexBoard.Size; y++)
            {
                if (y != 3)
                {
                    hexBoard.PlayMove(2, y, true);
                }
            }

            int xScore = pathLength.PlayerScore(true);
            Assert.IsTrue(xScore > 0);

            int yScore = pathLength.PlayerScore(false);
            Assert.IsTrue(yScore > xScore);

            // strong advantage to player 1
            int advantageMoveScore = pathLength.SituationScore();
            Assert.IsTrue(advantageMoveScore > 0);
        }
示例#11
0
        private static void PlayerScoreBaricaded(IPathLengthFactory pathLengthFactory)
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // baricaded board
            for (int y = 0; y < hexBoard.Size; y++)
            {
                hexBoard.PlayMove(2, y, true);
            }

            int xScore = pathLength.PlayerScore(true);
            Assert.AreEqual(xScore, 0);

            int yScore = pathLength.PlayerScore(false);
            Assert.IsTrue(yScore > hexBoard.Size);

            // winning advantage to player 1
            int winMoveScore = pathLength.SituationScore();
            AssertWinner(winMoveScore, Occupied.PlayerX);
        }
示例#12
0
        private static void PlayerScoreZigZag(IPathLengthFactory pathLengthFactory)
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            for (int y = 0; y < hexBoard.Size - 1; y++)
            {
                hexBoard.PlayMove(2, y, true);
                hexBoard.PlayMove(5, hexBoard.Size - (1 + y), true);

                int xScore = pathLength.PlayerScore(true);
                Assert.IsTrue(xScore > 0);

                int yScore = pathLength.PlayerScore(false);
                Assert.IsTrue(yScore >= hexBoard.Size);
                if (y > (hexBoard.Size / 2))
                {
                    Assert.IsTrue(yScore > xScore);
                }

                // some advantage to player 1
                int advantageMoveScore = pathLength.SituationScore();
                Assert.IsTrue(advantageMoveScore >= y);
            }
        }
示例#13
0
        private static void PlayerScoreBlankBoard(IPathLengthFactory pathLengthFactory)
        {
            HexBoard hexBoard = new HexBoard(BoardSize);
            PathLengthBase pathLength = pathLengthFactory.CreatePathLength(hexBoard);

            // blank board
            int xScore = pathLength.PlayerScore(true);
            int yScore = pathLength.PlayerScore(false);
            Assert.AreEqual(xScore, yScore, "x and y score");

            // no advantage
            int equalMoveScore = pathLength.SituationScore();
            Assert.AreEqual(equalMoveScore, 0, "equalMoveScore");

            // all cells still on the clean path
            pathLength.PlayerScore(true);
            List<Location> cleanPathX = pathLength.GetCleanPath(true);

            pathLength.PlayerScore(false);
            List<Location> cleanPathY = pathLength.GetCleanPath(false);

            const int AllCellsCount = BoardSize * BoardSize;
            Assert.AreEqual(AllCellsCount, cleanPathX.Count, "Clean path x should have all cells");
            Assert.AreEqual(AllCellsCount, cleanPathY.Count, "Clean path y should have all cells");
        }