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 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 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 ShouldHashASinglePiece() { var board = new Game.Board(); var piece = new Pawn { Square = 1 }; board.HashPiece(piece); board.PositionKey.Should().Be(HashPawnSquareOne); }
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); }
private void SidePanelTextBox0_SelectionChanged(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Enter) { // there should be a way better binding than this BoardString = SidePanelTextBox0.Text; Board = new Game.Board(BoardString); RemoveAllLitSquares(); // remove all the lit squares ViewBoardString(); } }
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 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 ShouldGenerateInitialBlackMoveCorrectly() { 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.GenerateMoves(); board.Moves[board.Ply][0].ToSquare.Should().Be(71); }
public void ShouldGenerateTwentyInitialReplies() { 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.GenerateMoves(); board.Moves[board.Ply].Count.Should().Be(20); }
public void ShouldHaveTwoMovesForBlackKnightOnTheFirstRankToTheCorrectSquares() { 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][0].PieceToMove.Square.Should().Be(92); board.Moves[board.Ply][1].PieceToMove.Square.Should().Be(92); }
public void ShouldHaveEightCaptureMovesFromTheMiddleOfTheBoard() { const string initialBoardSetup = "pppppppp/ppBpBppp/pBpppBpp/3n4/pBpppBpp/ppBpBppp/pppppppp/pppppppp 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 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 ShouldAddANewEntryToHistory() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 22 }, 23); board.MakeMove(m); board.History.Count.Should().Be(1); }
public void ShouldUpdateTheEnPassantSquareHistoryEntry() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 22 }, 23); board.MakeMove(m); board.History[0].EnPassantSquare.Should().Be(board.EnPassantSquare); }
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); }
public void ShouldUpdateTheCastlePermissionsIfTheBlackKingRookHasMoved() { const string initialBoardSetupForWhiteRookMove = "rnbqkbnr/ppppppp1/8/8/8/8/PPPPPPPP/RBNQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupForWhiteRookMove); var m = new Move(new Rook { Color = Color.Black, Square = 98 }, 88); board.MakeMove(m); ((int)(board.CastlePermission & CastlePermissions.BlackKing)).Should().Be(0); }
public void ShouldUpdateTheCastlePermissionsIfTheWhiteQueenRookHasMoved() { const string initialBoardSetupForWhiteRookMove = "rnbqkbnr/pppppppp/8/8/8/8/1PPPPPPP/RBNQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupForWhiteRookMove); var m = new Move(new Rook { Color = Color.White, Square = 21 }, 22); board.MakeMove(m); ((int)(board.CastlePermission & CastlePermissions.WhiteQueen)).Should().Be(0); }
public void ShouldHashOutTheEnPassantKeyIfItIsSet() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var initialPosKey = board.PositionKey; board.EnPassantSquare = 41; var m = new Move(new Pawn(), 23); board.MakeMove(m); board.PositionKey.Should().NotBe(initialPosKey); }
public void ShouldUpdateTheCastlePermissionsInHistoryEntry() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 22 }, 23); board.MakeMove(m); board.History[0].CastlePermissions.Should().Be(board.CastlePermission); }
public void ShouldUpdateTheFifyMoveCountInHistoryEntry() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 22 }, 23); board.MakeMove(m); board.History[0].FiftyMoveCount.Should().Be(board.FiftyMoveCount); }
public void ShouldHasInTheNewSide() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var oldPosition = board.PositionKey; var m = new Move(new Pawn { Square = 31, Color = Color.White }, 31); board.MakeMove(m); board.PositionKey.Should().NotBe(oldPosition); }
public void ShouldUpdatePieceList() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMoveNoWhiteRook); var rook = new Rook { Square = 21, Color = Color.White }; board.AddPiece(rook); //board.WhiteRookPieceList.Count.Should().Be(4); }
public void ShouldChangePositionKeyIfTheBlackKingRookMoves() { const string initialBoardSetupForWhiteRookMove = "rnbqkbnr/ppppppp1/8/8/8/8/1PPPPPPP/RBNQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupForWhiteRookMove); var initialPosKey = board.PositionKey; var m = new Move(new Rook { Color = Color.White, Square = 98 }, 88); board.MakeMove(m); board.PositionKey.Should().NotBe(initialPosKey); }
public void ShouldPutPiecesOnCorrectSquares() { Game.Board board = new Game.Board(); board.ParseFen(InitialBoardSetup); board.Squares[91].Should().BeOfType <Rook>(); board.Squares[92].Should().BeOfType <EmptyPiece>(); board.Squares[93].Should().BeOfType <EmptyPiece>(); board.Squares[94].Should().BeOfType <EmptyPiece>(); board.Squares[95].Should().BeOfType <King>(); board.Squares[96].Should().BeOfType <EmptyPiece>(); board.Squares[97].Should().BeOfType <EmptyPiece>(); board.Squares[98].Should().BeOfType <Rook>(); }
static private List <Game.Tile> GetPlayerTokenTiles(Game.Board board, Object player) { var playerTiles = new List <Game.Tile>(); board.Columns.ForEach(col => { col.Tiles.ForEach(tile => { if (tile.OwningPlayer == player) { playerTiles.Add(tile); } }); }); return(playerTiles); }
static public List <Game.Tile> FindDirectWinningPossibilities(Game.Board board, Object player) { var allPotentialWinningTiles = new List <Game.Tile>(); var placeable = board.GetAllPlaceableTiles(); foreach (Tile t in placeable) { if (IsDirectlyWinnableOnTileForPlayer(board, t, player)) { allPotentialWinningTiles.Add(t); } } return(allPotentialWinningTiles); }
public void ShouldPromoteIfThereIsAPromotion() { var board = new Game.Board(); board.ParseFen(InitialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 81, Color = Color.White }, 91, new Queen { Square = 91 }); board.MakeMove(m); board.Squares[91].Type.Should().Be(PieceType.Queen); }
public void ShouldHashInTheSide() { var board = new Game.Board(); var pawn1 = new Pawn { Square = 1 }; board.HashSide(); board.HashPiece(pawn1); board.PositionKey.Should().NotBe(HashPawnSquareOne); board.HashSide(); board.PositionKey.Should().Be(HashPawnSquareOne); }