mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 01:27:16 +08:00
Simplify castlingPath (#2088)
Instead of looping through kfrom,kto, rfrom, rto, we can use BetweenBB. This is less lines of code and it is more clear what castlingPath actually is. Personal benchmarks are all over the place. However, this code is only executed when loading a position, so performance doesn't seem that relevant. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
ab4b94e173
commit
ec49e676a7
@@ -340,13 +340,8 @@ void Position::set_castling_right(Color c, Square 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);
|
||||
|
||||
for (Square s = std::min(rfrom, rto); s <= std::max(rfrom, rto); ++s)
|
||||
if (s != kfrom && s != rfrom)
|
||||
castlingPath[cr] |= s;
|
||||
|
||||
for (Square s = std::min(kfrom, kto); s <= std::max(kfrom, kto); ++s)
|
||||
if (s != kfrom && s != rfrom)
|
||||
castlingPath[cr] |= s;
|
||||
castlingPath[cr] = (between_bb(rfrom, rto) | between_bb(kfrom, kto) | rto | kto)
|
||||
& ~(square_bb(kfrom) | rfrom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user