Add Chess960 (FRC) and DFRC support
- castling moves are stored as "king takes own rook" (from = king square, to = castling rook square) - per-colour castling rook squares (Board::castleRook), so DFRC (different back ranks for white/black) works - FEN parsing/printing: KQkq (X-FEN) and Shredder-FEN file letters - Board::CanCastle(): generic castling legality (empty paths, king not attacked, rook x-ray check) - MakeMove handles arbitrary king/rook start squares (king and rook may stay in place or swap through each other's squares) - UCI_Chess960 option: castling printed/parsed as king-takes-rook when on, standard e1g1 style otherwise (both are accepted when parsing) - viri format, perft castle check and castling right updates no longer assume a1/h1/a8/h8
This commit is contained in:
1 parent
e984510434
commit
aa97abaadc
9 files changed
+247
-71
No files matched your search
+13
-2
@@ -38,7 +38,11 @@ public:
|
||||
|
||||
bool sideToMove = White;
|
||||
|
||||
uint8_t castlingRights = 0;
|
||||
uint8_t castlingRights = 0;
|
||||
|
||||
// Squares of the castling rooks, indexed by CastleIdx(color, kingSide).
|
||||
// Standard chess: h1, a1, h8, a8. Chess960 / DFRC positions override them while parsing the FEN.
|
||||
std::array<int, 4> castleRook = {h1, a1, h8, a8};
|
||||
int enPassantTarget = noEPTarget;
|
||||
|
||||
short positionIndex = 0;
|
||||
@@ -95,5 +99,12 @@ public:
|
||||
bool GivesDirectCheck(Move &move);
|
||||
|
||||
bool IsLegal(Move &move);
|
||||
bool IsPseudoLegal(Move &move);
|
||||
bool IsPseudoLegal(Move &move);
|
||||
|
||||
// Index of a castling right, same bit order as CASTLING_RIGHTS (white K, white Q, black K, black Q)
|
||||
static constexpr int CastleIdx(bool color, bool kingSide) { return color * 2 + (kingSide ? 0 : 1); }
|
||||
|
||||
bool CanCastle(bool us, bool kingSide);
|
||||
void AddCastlingRight(char symbol);
|
||||
char CastlingSymbol(uint8_t right, char standardSymbol) const;
|
||||
};
|
||||
Reference in new issue
Block a user