From f3bfce353168b03e4fedce515de1898c691f81ec Mon Sep 17 00:00:00 2001 From: xu-shawn <50402888+xu-shawn@users.noreply.github.com> Date: Fri, 28 Feb 2025 00:50:59 -0800 Subject: [PATCH] Revert "Replace aligned() function with line_bb() and simplify king piece detection" (#5915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes https://github.com/official-stockfish/Stockfish/pull/5915 No functional change Co-authored-by: Robert Nürnberg --- src/position.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 1e19e3c8a..37e9a2eb5 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -560,7 +560,7 @@ bool Position::legal(Move m) const { // A non-king move is legal if and only if it is not pinned or it // is moving along the ray towards or away from the king. - return !(blockers_for_king(us) & from) || line_bb(from, to) & pieces(us, KING); + return !(blockers_for_king(us) & from) || aligned(from, to, square(us)); } @@ -648,7 +648,7 @@ bool Position::gives_check(Move m) const { // Is there a discovered check? if (blockers_for_king(~sideToMove) & from) - return !(line_bb(from, to) & pieces(~sideToMove, KING) || m.type_of() == CASTLING); + return !aligned(from, to, square(~sideToMove)) || m.type_of() == CASTLING; switch (m.type_of()) { @@ -656,7 +656,7 @@ bool Position::gives_check(Move m) const { return false; case PROMOTION : - return attacks_bb(m.promotion_type(), to, pieces() ^ from) & pieces(~sideToMove, KING); + return attacks_bb(m.promotion_type(), to, pieces() ^ from) & square(~sideToMove); // En passant capture with check? We have already handled the case of direct // checks and ordinary discovered check, so the only case we need to handle