diff --git a/src/movegen.cpp b/src/movegen.cpp index 1e42f99e..50496136 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -313,17 +313,9 @@ ExtMove* generate(const Position& pos, ExtMove* moveList) { Color us = pos.side_to_move(); Square ksq = pos.square(us); - Bitboard sliderAttacks = 0; - Bitboard sliders = pos.checkers() & ~pos.pieces(KNIGHT, PAWN); - // Find all the squares attacked by slider checkers. We will remove them from - // the king evasions in order to skip known illegal moves, which avoids any - // useless legality checks later on. - while (sliders) - sliderAttacks |= line_bb(ksq, pop_lsb(sliders)) & ~pos.checkers(); - - // Generate evasions for king, capture and non capture moves - Bitboard b = attacks_bb(ksq) & ~pos.pieces(us) & ~sliderAttacks; + // Generate evasions for king + Bitboard b = attacks_bb(ksq) & ~pos.pieces(us); while (b) *moveList++ = make_move(ksq, pop_lsb(b)); diff --git a/src/position.cpp b/src/position.cpp index 6c5a11b2..ec356ace 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -544,7 +544,7 @@ bool Position::legal(Move m) const { // If the moving piece is a king, check whether the destination square is // attacked by the opponent. if (type_of(piece_on(from)) == KING) - return !(attackers_to(to) & pieces(~us)); + return !(attackers_to(to, pieces() ^ from) & pieces(~us)); // 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.