Refactor Position::pseudo_legal Pawn Move Check

use intermediate variables to make the statement easier to read

closes https://github.com/official-stockfish/Stockfish/pull/6045

No functional change
This commit is contained in:
FauziAkram
2025-05-02 18:32:55 +03:00
committed by Joost VandeVondele
parent c4e2479a75
commit 07f6edf934

View File

@@ -597,10 +597,14 @@ bool Position::pseudo_legal(const Move m) const {
if ((Rank8BB | Rank1BB) & to) if ((Rank8BB | Rank1BB) & to)
return false; return false;
if (!(attacks_bb<PAWN>(from, us) & pieces(~us) & to) // Not a capture // Check if it's a valid capture, single push, or double push
&& !((from + pawn_push(us) == to) && empty(to)) // Not a single push const bool isCapture = bool(attacks_bb<PAWN>(from, us) & pieces(~us) & to);
&& !((from + 2 * pawn_push(us) == to) // Not a double push const bool isSinglePush = (from + pawn_push(us) == to) && empty(to);
&& (relative_rank(us, from) == RANK_2) && empty(to) && empty(to - pawn_push(us)))) const bool isDoublePush = (from + 2 * pawn_push(us) == to)
&& (relative_rank(us, from) == RANK_2) && empty(to)
&& empty(to - pawn_push(us));
if (!(isCapture || isSinglePush || isDoublePush))
return false; return false;
} }
else if (!(attacks_bb(type_of(pc), from, pieces()) & to)) else if (!(attacks_bb(type_of(pc), from, pieces()) & to))