+ // Find squares attacked by slider checkers, we will
+ // remove them from king evasions set so to avoid a couple
+ // of cycles in the slow king evasions legality check loop.
+ Bitboard checkers = pos.checkers();
+ Bitboard checkersAttacks = EmptyBoardBB;
+ Bitboard b = checkers & (pos.queens() | pos.bishops());
+ while (b)
+ {
+ from = pop_1st_bit(&b);
+ checkersAttacks |= bishop_attacks_bb(from, b2);
+ }
+
+ b = checkers & (pos.queens() | pos.rooks());
+ while (b)
+ {
+ from = pop_1st_bit(&b);
+ checkersAttacks |= rook_attacks_bb(from, b2);
+ }
+
+ // Generate evasions for king
+ Bitboard b1 = pos.piece_attacks<KING>(ksq) & ~pos.pieces_of_color(us) & ~checkersAttacks;