mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 03:57:45 +00:00
Consolidate CastlingSide and CastlingRights
This is a non-functional simplification that removes CastlingSide and implements the functionality in CastlingRights (thanks to Jörg Oster for a comment on the first version of this patch). STC LLR: 2.96 (-2.94,2.94) [-3.00,1.00] Total: 53854 W: 12077 L: 12019 D: 29758 http://tests.stockfishchess.org/tests/view/5d517b940ebc5925cf107474 Closes https://github.com/official-stockfish/Stockfish/pull/2265 No functional change
This commit is contained in:
committed by
Stéphane Nicolet
parent
a016626825
commit
3984b8f8f0
+8
-9
@@ -330,16 +330,15 @@ Position& Position::set(const string& fenStr, bool isChess960, StateInfo* si, Th
|
||||
void Position::set_castling_right(Color c, Square rfrom) {
|
||||
|
||||
Square kfrom = square<KING>(c);
|
||||
CastlingSide cs = kfrom < rfrom ? KING_SIDE : QUEEN_SIDE;
|
||||
CastlingRight cr = (c | cs);
|
||||
CastlingRights cr = c & (kfrom < rfrom ? KING_SIDE: QUEEN_SIDE);
|
||||
|
||||
st->castlingRights |= cr;
|
||||
castlingRightsMask[kfrom] |= cr;
|
||||
castlingRightsMask[rfrom] |= cr;
|
||||
castlingRookSquare[cr] = rfrom;
|
||||
|
||||
Square kto = relative_square(c, cs == KING_SIDE ? SQ_G1 : SQ_C1);
|
||||
Square rto = relative_square(c, cs == KING_SIDE ? SQ_F1 : SQ_D1);
|
||||
Square kto = relative_square(c, cr & KING_SIDE ? SQ_G1 : SQ_C1);
|
||||
Square rto = relative_square(c, cr & KING_SIDE ? SQ_F1 : SQ_D1);
|
||||
|
||||
castlingPath[cr] = (between_bb(rfrom, rto) | between_bb(kfrom, kto) | rto | kto)
|
||||
& ~(square_bb(kfrom) | rfrom);
|
||||
@@ -1300,14 +1299,14 @@ bool Position::pos_is_ok() const {
|
||||
}
|
||||
|
||||
for (Color c : { WHITE, BLACK })
|
||||
for (CastlingSide s : {KING_SIDE, QUEEN_SIDE})
|
||||
for (CastlingRights cr : {c & KING_SIDE, c & QUEEN_SIDE})
|
||||
{
|
||||
if (!can_castle(c | s))
|
||||
if (!can_castle(cr))
|
||||
continue;
|
||||
|
||||
if ( piece_on(castlingRookSquare[c | s]) != make_piece(c, ROOK)
|
||||
|| castlingRightsMask[castlingRookSquare[c | s]] != (c | s)
|
||||
|| (castlingRightsMask[square<KING>(c)] & (c | s)) != (c | s))
|
||||
if ( piece_on(castlingRookSquare[cr]) != make_piece(c, ROOK)
|
||||
|| castlingRightsMask[castlingRookSquare[cr]] != (cr)
|
||||
|| (castlingRightsMask[square<KING>(c)] & (cr)) != (cr))
|
||||
assert(0 && "pos_is_ok: Castling");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user