- p.king_attacks(s) & ~p.pieces_of_color(us) & ~attackedByOthers;
- while(b) {
- Square from, to = pop_1st_bit(&b);
- if(!(escapeSquares
- & ~queen_attacks_bb(to, occ & clear_mask_bb(s)))) {
- // We have a mate, unless the queen is pinned or there
- // is an X-ray attack through the queen.
- for(int i = 0; i < p.queen_count(them); i++) {
- from = p.queen_list(them, i);
- if(bit_is_set(p.queen_attacks(from), to)
- && !bit_is_set(p.pinned_pieces(them), from)
- && !(rook_attacks_bb(to, occ & clear_mask_bb(from))
- & p.rooks_and_queens(us))
- && !(rook_attacks_bb(to, occ & clear_mask_bb(from))
- & p.rooks_and_queens(us)))
- ei.mateThreat[them] = make_move(from, to);
+ p.piece_attacks<KING>(s) & ~p.pieces_of_color(us) & ~attackedByOthers;
+
+ while (b)
+ {
+ Square from, to = pop_1st_bit(&b);
+ if (!(escapeSquares & ~queen_attacks_bb(to, occ & ClearMaskBB[s])))
+ {
+ // We have a mate, unless the queen is pinned or there
+ // is an X-ray attack through the queen.
+ for (int i = 0; i < p.piece_count(them, QUEEN); i++)
+ {
+ from = p.piece_list(them, QUEEN, i);
+ if ( bit_is_set(p.piece_attacks<QUEEN>(from), to)
+ && !bit_is_set(p.pinned_pieces(them), from)
+ && !(rook_attacks_bb(to, occ & ClearMaskBB[from]) & p.rooks_and_queens(us))
+ && !(rook_attacks_bb(to, occ & ClearMaskBB[from]) & p.rooks_and_queens(us)))
+
+ ei.mateThreat[them] = make_move(from, to);
+ }