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); }
public void ShouldEmptyTheSquare() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); board.ClearPiece(board.Squares[21]); board.Squares[21].Type.Should().Be(PieceType.Empty); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void ShouldRemovePieceFromList() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); board.ClearPiece(board.Squares[21]); //board.WhiteRookPieceList.Count.Should().Be(3); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); }
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); }
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); }