X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=d48ec18cb0d69aead115584573e135d468a9ea06;hp=fdae0ae0bf211999f9c2ee69472c4f151af0f8a0;hb=ad2a0e356e395038a08324f9ff0afee7fc98b8e9;hpb=d438720a1c8115485ff47eeca3b734cd681d01c4 diff --git a/src/position.cpp b/src/position.cpp index fdae0ae0..d48ec18c 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -464,7 +464,7 @@ const string Position::fen() const { Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const { - Bitboard result = 0; + Bitboard blockers = 0; pinners = 0; // Snipers are sliders that attack 's' when a piece is removed @@ -476,14 +476,14 @@ Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners Square sniperSq = pop_lsb(&snipers); Bitboard b = between_bb(s, sniperSq) & pieces(); - if (!more_than_one(b)) + if (b && !more_than_one(b)) { - result |= b; + blockers |= b; if (b & pieces(color_of(piece_on(s)))) pinners |= sniperSq; } } - return result; + return blockers; } @@ -540,7 +540,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 !(pinned_pieces(us) & from) + return !(blockers_for_king(us) & from) || aligned(from, to_sq(m), square(us)); } @@ -632,7 +632,7 @@ bool Position::gives_check(Move m) const { return true; // Is there a discovered check? - if ( (discovered_check_candidates() & from) + if ( (st->blockersForKing[~sideToMove] & from) && !aligned(from, to, square(~sideToMove))) return true;