mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-06 10:53:50 +08:00
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:
committed by
Joost VandeVondele
parent
c4e2479a75
commit
07f6edf934
@@ -597,10 +597,14 @@ bool Position::pseudo_legal(const Move m) const {
|
||||
if ((Rank8BB | Rank1BB) & to)
|
||||
return false;
|
||||
|
||||
if (!(attacks_bb<PAWN>(from, us) & pieces(~us) & to) // Not a capture
|
||||
&& !((from + pawn_push(us) == to) && empty(to)) // Not a single push
|
||||
&& !((from + 2 * pawn_push(us) == to) // Not a double push
|
||||
&& (relative_rank(us, from) == RANK_2) && empty(to) && empty(to - pawn_push(us))))
|
||||
// Check if it's a valid capture, single push, or double push
|
||||
const bool isCapture = bool(attacks_bb<PAWN>(from, us) & pieces(~us) & to);
|
||||
const bool isSinglePush = (from + pawn_push(us) == to) && empty(to);
|
||||
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;
|
||||
}
|
||||
else if (!(attacks_bb(type_of(pc), from, pieces()) & to))
|
||||
|
||||
Reference in New Issue
Block a user