Skip to content

Commit

Permalink
Revert "Replace aligned() function with line_bb() and simplify king p…
Browse files Browse the repository at this point in the history
…iece detection" (#5915)

closes #5915

No functional change

Co-authored-by: Robert Nürnberg <[email protected]>
  • Loading branch information
xu-shawn and robertnurnberg authored Feb 28, 2025
1 parent 5c617e5 commit f3bfce3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KING>(us));
}


Expand Down Expand Up @@ -648,15 +648,15 @@ 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<KING>(~sideToMove)) || m.type_of() == CASTLING;

switch (m.type_of())
{
case NORMAL :
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<KING>(~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
Expand Down

0 comments on commit f3bfce3

Please sign in to comment.