public void GetMoves_WhiteKing_CanCastleBothSides() { var board = new ChessBoardState(); board.Clear(); board.SetSpot(5, 1, ChessPiece.WhiteKing); board.SetSpot(1, 1, ChessPiece.WhiteRook); board.SetSpot(8, 1, ChessPiece.WhiteRook); board.SetSpot(1, 2, ChessPiece.BlackRook); board.SetSpot(8, 2, ChessPiece.BlackRook); board.SetWhiteCanCastleKingside(true); board.SetWhiteCanCastleQueenside(true); var expectedMoves = new List <string> { // A1 Rook "Ra1-b1", "Ra1-c1", "Ra1-d1", "Ra1xa2", // King "O-O-O", "Ke1-d1", "Ke1-f1", "O-O", // H1 Rook "Rh1-f1", "Rh1-g1", "Rh1xh2" }; CheckPossibleMoves(board, expectedMoves); }
public void GetMoves_WhiteKing_CantCastleWhileInCheck() { var board = new ChessBoardState(); board.Clear(); board.SetSpot(5, 1, ChessPiece.WhiteKing); board.SetSpot(1, 1, ChessPiece.WhiteRook); board.SetSpot(8, 1, ChessPiece.WhiteRook); board.SetSpot(1, 2, ChessPiece.BlackRook); board.SetSpot(8, 2, ChessPiece.BlackRook); board.SetSpot(5, 8, ChessPiece.BlackRook); board.SetWhiteCanCastleKingside(true); board.SetWhiteCanCastleQueenside(true); // White is able to castle, but can't because they're in check. They can only move their king out of the way. var expectedMoves = new List <string> { // A1 Rook //"Ra1-b1", //"Ra1-c1", //"Ra1-d1", //"Ra1xa2", // King //"O-O-O", "Ke1-d1", "Ke1-f1", //"O-O", // H1 Rook //"Rh1-f1", //"Rh1-g1", //"Rh1xh2" }; CheckPossibleMoves(board, expectedMoves); }
public void GetMoves_WhiteKing_CastleRights_AcrossCheck_KSJump() { var board = new ChessBoardState(); board.Clear(); board.SetSpot(5, 1, ChessPiece.WhiteKing); board.SetSpot(5, 8, ChessPiece.BlackKing); board.SetSpot(1, 1, ChessPiece.WhiteRook); board.SetSpot(8, 1, ChessPiece.WhiteRook); board.SetSpot(1, 2, ChessPiece.BlackRook); board.SetSpot(6, 3, ChessPiece.BlackRook); // King can't castle kingside when there's a Black Rook on this square. board.SetSpot(8, 2, ChessPiece.BlackRook); board.SetWhiteCanCastleKingside(true); board.SetWhiteCanCastleQueenside(true); var expectedMoves = new List <string> { // A1 Rook "Ra1-b1", "Ra1-c1", "Ra1-d1", "Ra1xa2", // King "O-O-O", "Ke1-d1", //"Ke1-f1", //"O-O", // H1 Rook "Rh1-f1", "Rh1-g1", "Rh1xh2" }; CheckPossibleMoves(board, expectedMoves); }