Beispiel #1
0
        public void canSimEnumSetupBoardTo4MovesAhead()
        {
            Board b = TestBoard.createAndSetupBoard();

            Board.BoardWithHistory copyOfBoardWH = new Board.BoardWithHistory()
            {
                Board        = b,
                BoardHistory = b.BoardString,
            };

            int simBoardsCount = 0;

            foreach (Board.BoardWithHistory simBoard in b.EnumSimTillNumMovesAhead(4, Piece.PlayerColour.White))
            {
                simBoardsCount++;
            }
            Assert.AreEqual <int>(197702, simBoardsCount);
        }
Beispiel #2
0
        public void cannotMove2AtStartIfPieceInTheWay()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(6, 7);
            b.Move(5, 7);

            b.Select(1, 0);
            b.Move(3, 0);

            b.Select(6, 6);
            b.Move(5, 6);

            b.Select(3, 0);
            b.Move(4, 0);

            b.Select(6, 0);
            b.Move(4, 0);
        }
Beispiel #3
0
        public void simulationReturnsCorrectSimulationBoardsForPawnAtStart()
        {
            Board b = TestBoard.createBoard();

            b.Place <Pawn>(Piece.PlayerColour.White, 6, 3);
            List <Board> simBoards = b.Simulate(Piece.PlayerColour.White);

            List <Cell> expectedPositions = new List <Cell>()
            {
                new Cell(5, 3), //One ahead
                new Cell(4, 3)  //Two ahead
            };

            foreach (Board simBoard in simBoards)
            {
                Pawn p = simBoard.GetFirstPiece <Pawn>(Piece.PlayerColour.White);
                Assert.IsNotNull(p);
                Assert.IsTrue(expectedPositions.Contains(p.ParentCell));
            }
        }
Beispiel #4
0
        public void canSimFourMovesAhead()
        {
            Board b = TestBoard.createBoard();

            b.Place <Pawn>(Piece.PlayerColour.White, 4, 3);
            b.Place <Pawn>(Piece.PlayerColour.Black, 2, 1);
            b.GetFirstPiece <Pawn>(Piece.PlayerColour.White).AtStartPosition = false;
            b.GetFirstPiece <Pawn>(Piece.PlayerColour.Black).AtStartPosition = false;
            SimulationTree simTree = b.Simulate(Piece.PlayerColour.White, 4);
            List <Board>   fourMovesAheadBoards = simTree.GetPossibilitesAtNumMovesAhead(4);

            Assert.AreEqual <int>(1, fourMovesAheadBoards.Count);

            Pawn whiteOneMoveAheadPawn = fourMovesAheadBoards[0].GetFirstPiece <Pawn>(Piece.PlayerColour.White);

            Assert.AreEqual <Cell>(new Cell(2, 3), whiteOneMoveAheadPawn.ParentCell);

            Pawn blackTwoMovesAheadPawn = fourMovesAheadBoards[0].GetFirstPiece <Pawn>(Piece.PlayerColour.Black);

            Assert.AreEqual <Cell>(new Cell(4, 1), blackTwoMovesAheadPawn.ParentCell);
        }
Beispiel #5
0
        public void simulationReturnsTwoBoardsForSinglePawnAtStart()
        {
            Board b = TestBoard.createBoard();

            b.Place <Pawn>(Piece.PlayerColour.White, 6, 3);
            List <Board> simBoards = b.Simulate(Piece.PlayerColour.White);

            Assert.AreEqual <int>(2, simBoards.Count);
            List <Cell> expectedPositions = new List <Cell>()
            {
                new Cell(5, 3),
                new Cell(4, 3)
            };

            foreach (Board simBoard in simBoards)
            {
                Pawn p = simBoard.GetFirstPiece <Pawn>(Piece.PlayerColour.White);
                Assert.IsNotNull(p);
                Assert.IsTrue(expectedPositions.Contains(p.ParentCell));
            }
        }
Beispiel #6
0
        public void colourNotInStaleManteByDefault()
        {
            Board b = TestBoard.createAndSetupBoard();

            Assert.IsFalse(b.InStalemate(Piece.PlayerColour.White));
        }
Beispiel #7
0
        public void colourNotInStalemateWhenNoKing()
        {
            Board b = TestBoard.createBoard();

            Assert.IsFalse(b.InStalemate(Piece.PlayerColour.White));
        }
Beispiel #8
0
        public void getExceptionWhenSelectCellColTooLarge()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(0, Board.NumOfCols + 1);
        }
Beispiel #9
0
        public void getExceptionWhenSelectCellRowTooLarge()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(Board.NumOfRows + 1, 0);
        }
Beispiel #10
0
        public void getExceptionWhenSelectCellNegativeCol()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(0, -1);
        }
Beispiel #11
0
        public void getExceptionWhenSelectCellNegativeRow()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(-1, 0);
        }
Beispiel #12
0
        public void canSelectCell()
        {
            Board b = TestBoard.createAndSetupBoard();

            b.Select(0, 1);
        }