writing into binpack file | bench 1857933

This commit is contained in:
rektdie committed 2025-04-01 21:29:00 +02:00
1 parent 649bee6490
commit 7c62a3e672
3 files changed
+83 -3

No files matched your search

+6 -3
View File
@@ -148,7 +148,7 @@ Move parseMove(Board &board, std::string_view str) {
}
std::array<uint8_t, 16> CompressPieces(Board &board) {
const uint8_t UNMOVED_ROOK = 0x08; // We only have 4 bits, so we use bit 3 to mark unmoved rooks
const uint8_t UNMOVED_ROOK = 0x08; // We use bit 3 to mark unmoved rooks
std::array<uint8_t, 16> compressed{}; // Zero-initialize
for (int square = 0; square < 64; square++) {
@@ -164,9 +164,12 @@ std::array<uint8_t, 16> CompressPieces(Board &board) {
pieceCode = pieceType + 6; // Black: 7-12
}
// Check for unmoved rook
// Check for unmoved rooks (based solely on castling rights)
if (pieceType == Rook) {
if ((board.castlingRights & (whiteKingRight | whiteQueenRight | blackKingRight | blackQueenRight)) != 0) {
if ((board.colors[White] & board.pieces[Rook]) && (board.castlingRights & (whiteKingRight | whiteQueenRight))) {
pieceCode |= UNMOVED_ROOK; // Mark as unmoved rook (bit 3 set)
}
if ((board.colors[Black] & board.pieces[Rook]) && (board.castlingRights & (blackKingRight | blackQueenRight))) {
pieceCode |= UNMOVED_ROOK; // Mark as unmoved rook (bit 3 set)
}
}