Esempio n. 1
0
            public void ShouldGenerateFourMovesWhenBlackPawnIsPromoted()
            {
                const string boardSetup = "8/8/8/8/8/8/rrrrrrrp/8 b KQkq - 0 1";
                var          board      = new Game.Board();

                board.ParseFen(boardSetup);

                board.GenerateMoves(board.WhitePawnPieceList);
                board.Moves[board.Ply].Count.Should().Be(4);
            }
Esempio n. 2
0
            public void ShouldEmptyTheSquare()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);

                board.ClearPiece(board.Squares[21]);

                board.Squares[21].Type.Should().Be(PieceType.Empty);
            }
Esempio n. 3
0
            public void ShouldGenerateTwentyNineMovesFromBA3()
            {
                const string boardSetup = "rnbqkbnr/pppp1ppp/4p3/8/1P6/B7/P1PPPPPP/RN1QKBNR b KQkq - 0 1";
                var          board      = new Game.Board();

                board.ParseFen(boardSetup);

                board.GenerateMoves();
                board.Moves[board.Ply].Count.Should().Be(29);
            }
Esempio n. 4
0
            public void ShouldMoveAndCaptureSingleAvailableTarget()
            {
                const string initialBoardSetup = "8/8/7P/6qr/7b/8/8/8 b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(1);
            }
Esempio n. 5
0
            public void ShouldGenerateNoInitialMoves()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(0);
            }
Esempio n. 6
0
            public void ShouldGenerateTwentyInitialBlackMoves()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves();
                board.Moves[board.Ply].Count.Should().Be(20);
            }
Esempio n. 7
0
            public void ShouldGenerateSixteenInitialBlackMoves()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhitePawnPieceList);
                board.Moves[board.Ply].Count.Should().Be(16);
            }
Esempio n. 8
0
            public void ShouldMoveFromCenterToEdgesOfBoard()
            {
                const string initialBoardSetup = "8/8/8/8/3r4/8/8/8 b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(14);
            }
Esempio n. 9
0
            public void ShouldMoveAndCaptureAllAvailableTargets()
            {
                const string initialBoardSetup = "8/8/8/3Q4/2QrQ3/3Q4/8/8 b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(4);
            }
Esempio n. 10
0
            public void ShouldGenerateFourteenMovesIfFourteenWhiteMovesAreAvailable()
            {
                const string initialBoardSetup = "rnbqkbn1/ppppppp1/8/8/8/8/PPPPPPP1/7R w KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(14);
            }
Esempio n. 11
0
            public void ShouldGenerateOneMoveIfOneBlackMoveIsAvailable()
            {
                const string initialBoardSetup = "r1bqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(1);
            }
Esempio n. 12
0
            public void ShouldGenerateFourteenMovesIfFourteenBlackMovesAreAvailable()
            {
                const string initialBoardSetup = "r7/1ppppppp/8/8/8/8/1PPPPPPP/1NBQKBNR b KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteRookPieceList);
                board.Moves[board.Ply].Count.Should().Be(14);
            }
Esempio n. 13
0
            public void ShouldRemovePieceFromList()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);

                board.ClearPiece(board.Squares[21]);

                //board.WhiteRookPieceList.Count.Should().Be(3);
            }
Esempio n. 14
0
            public void ShouldGenerateTwoMoveWhenOnlyTwoCapturesAreAvailable()
            {
                const string boardSetup =
                    "rnbqkbnr/rnbqkbnr/rnbqkbnr/rnbqbbnr/rnbPkbnr/rnbqkbnr/rnbqkbnr/rnbqkbnr w KQkq - 0 1";
                var board = new Game.Board();

                board.ParseFen(boardSetup);

                board.GenerateMoves(board.WhitePawnPieceList);
                board.Moves[board.Ply].Count.Should().Be(2);
            }
Esempio n. 15
0
            public void ShouldUpdateTheMaterial()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);
                int material = board.Material[(int)Color.White];

                board.ClearPiece(board.Squares[21]);

                board.Material[(int)Color.White].Should().Be(material - new Rook().Value);
            }
Esempio n. 16
0
            public void ShouldMoveTheWhiteQueenRookWhenItIsAWhiteQueenSideCastle()
            {
                const string initialBoardSetupForWhiteQueenSideCastle = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R3KBNR w KQkq - 0 1";
                var          board = new Game.Board();

                board.ParseFen(initialBoardSetupForWhiteQueenSideCastle);
                var m = new Move(new King(), 23, true);

                board.MakeMove(m);
                board.Squares[24].Type.Should().Be(PieceType.Rook);
            }
Esempio n. 17
0
            public void ShouldSetInitialMoveCorrectly()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves();
                board.MakeMove(board.Moves[0][0]);
                board.Moves[0][0].ToSquare.Should().Be(41);
            }
Esempio n. 18
0
            public void ShouldUpdatePlyAfterMakingMove()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
                var          board             = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves();
                board.MakeMove(board.Moves[0][0]);
                board.Ply.Should().Be(1);
            }
Esempio n. 19
0
            public void ShouldSetTheBlackQueenRookSquareWhenItIsABlackQueenSideCastle()
            {
                const string initialBoardSetupForWhiteQueenSideCastle = "rnbqk2r/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";
                var          board = new Game.Board();

                board.ParseFen(initialBoardSetupForWhiteQueenSideCastle);
                var m = new Move(new King(), 97, true);

                board.MakeMove(m);
                board.Squares[98].Type.Should().Be(PieceType.Empty);
            }
Esempio n. 20
0
            public void ShouldSetTheWhiteKingRookSquareWhenItIsAWhiteKingSideCastle()
            {
                const string initialBoardSetupForWhiteKingSideCastle = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w KQkq - 0 1";
                var          board = new Game.Board();

                board.ParseFen(initialBoardSetupForWhiteKingSideCastle);
                var m = new Move(new King(), 27, true);

                board.MakeMove(m);
                board.Squares[28].Type.Should().Be(PieceType.Empty);
            }
Esempio n. 21
0
            public void ShouldHaveEightMovesFromTheMiddleOfTheBoard()
            {
                const string initialBoardSetup = "8/8/8/3n4/8/8/8/8 b KQkq - 0 1";

                var board = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteKnightPieceList);
                board.Moves[board.Ply].Count.Should().Be(8);
            }
Esempio n. 22
0
                public void ShouldCreateCorrectlyColoredPieces()
                {
                    var board = new Game.Board();

                    board.ParseFen(InitialBoardSetup);

                    board.Squares[21].Color.Should().Be(Color.White);
                    board.Squares[22].Color.Should().Be(Color.White);
                    board.Squares[81].Color.Should().Be(Color.Black);
                    board.Squares[91].Color.Should().Be(Color.Black);
                }
Esempio n. 23
0
            public void ShouldHaveTwoMovesForBlackKnightOnTheFirstRank()
            {
                const string initialBoardSetup = "rn6/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";

                var board = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteKnightPieceList);
                board.Moves[board.Ply].Count.Should().Be(2);
            }
Esempio n. 24
0
            public void ShouldHaveFourInitialMovesForWhite()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";

                var board = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteKnightPieceList);
                board.Moves[board.Ply].Count.Should().Be(4);
            }
Esempio n. 25
0
            public void ShouldCastleKingSideWhenBlackToMove()
            {
                const string initialBoardSetup = "rnbqk2r/pppppppp/8/8/8/8/PPPPPPPP/RBNQKBNR b KQkq - 0 1";
                var          board             = new Game.Board();

                board.CastlePermission = CastlePermissions.WhiteKing | CastlePermissions.WhiteQueen |
                                         CastlePermissions.BlackKing | CastlePermissions.BlackQueen;
                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteKingPieceList);
                board.Moves[board.Ply].Count.Should().Be(2);
            }
Esempio n. 26
0
            public void ShouldSwitchSide()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);
                var m = new Move(new Pawn {
                    Square = 31, Color = Color.White
                }, 41);

                board.MakeMove(m);
                board.SideToMove.Should().Be(Color.Black);
            }
Esempio n. 27
0
            public void ShouldNotPromoteIfThereIsNoPromotion()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);
                var m = new Move(new Pawn {
                    Square = 31, Color = Color.White
                }, 41);

                board.MakeMove(m);
                board.Squares[41].Type.Should().Be(PieceType.Pawn);
            }
Esempio n. 28
0
            public void ShouldReturnFalseIfTheKingIsInCheck()
            {
                const string blackKingAttackedAfterRookMove = "3k4/3r4/8/3R4/8/8/8/4K3 b KQkq - 0 1";
                var          board = new Game.Board();

                board.ParseFen(blackKingAttackedAfterRookMove);
                var m = new Move(new Rook {
                    Square = 84, Color = Color.Black
                }, 86);

                board.MakeMove(m).Should().BeFalse();
            }
Esempio n. 29
0
            public void ShouldHaveFourInitialMovesForBlackToTheCorrectSquares()
            {
                const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1";

                var board = new Game.Board();

                board.ParseFen(initialBoardSetup);

                board.GenerateMoves(board.WhiteKnightPieceList);
                board.Moves[board.Ply][0].PieceToMove.Square.Should().Be(92);
                board.Moves[board.Ply][0].ToSquare.Should().Be(73);
                board.Moves[board.Ply][1].ToSquare.Should().Be(71);
            }
Esempio n. 30
0
            public void ShouldUpdateThePly()
            {
                var board = new Game.Board();

                board.ParseFen(InitialBoardSetupWhiteToMove);
                var m = new Move(new Pawn {
                    Square = 22
                }, 23);

                board.MakeMove(m);

                board.Ply.Should().Be(1);
            }