- if (!(checkers & (checkers - 1))) // Only one bit set?
- {
- Square checksq = first_1(checkers);
-
- assert(pos.color_of_piece_on(checksq) == them);
-
- // Find pinned pieces
- Bitboard not_pinned = ~pos.pinned_pieces(us);
-
- // Generate captures of the checking piece
-
- // Pawn captures
- b1 = pos.pawn_attacks(them, checksq) & pos.pawns(us) & not_pinned;
- while (b1)
- {
- from = pop_1st_bit(&b1);
- if (relative_rank(us, checksq) == RANK_8)
- {
- mlist[n++].move = make_promotion_move(from, checksq, QUEEN);
- mlist[n++].move = make_promotion_move(from, checksq, ROOK);
- mlist[n++].move = make_promotion_move(from, checksq, BISHOP);
- mlist[n++].move = make_promotion_move(from, checksq, KNIGHT);
- } else
- mlist[n++].move = make_move(from, checksq);
- }
-
- // Pieces captures
- b1 = ( (pos.piece_attacks<KNIGHT>(checksq) & pos.knights(us))
- | (pos.piece_attacks<BISHOP>(checksq) & pos.bishops_and_queens(us))
- | (pos.piece_attacks<ROOK>(checksq) & pos.rooks_and_queens(us)) ) & not_pinned;
-
- while (b1)
- {
- from = pop_1st_bit(&b1);
- mlist[n++].move = make_move(from, checksq);
- }
-
- // Blocking check evasions are possible only if the checking piece is
- // a slider
- if (checkers & pos.sliders())
- {
- Bitboard blockSquares = squares_between(checksq, ksq);
-
- assert((pos.occupied_squares() & blockSquares) == EmptyBoardBB);
-
- // Pawn moves. Because a blocking evasion can never be a capture, we
- // only generate pawn pushes.
- if (us == WHITE)
- n = generate_pawn_blocking_evasions<WHITE>(pos, not_pinned, blockSquares, mlist, n);
- else
- n = generate_pawn_blocking_evasions<BLACK>(pos, not_pinned, blockSquares, mlist, n);
-
- // Pieces moves
- b1 = pos.knights(us) & not_pinned;
- if (b1)
- n = generate_piece_blocking_evasions<KNIGHT>(pos, b1, blockSquares, mlist, n);
-
- b1 = pos.bishops(us) & not_pinned;
- if (b1)
- n = generate_piece_blocking_evasions<BISHOP>(pos, b1, blockSquares, mlist, n);
-
- b1 = pos.rooks(us) & not_pinned;
- if (b1)
- n = generate_piece_blocking_evasions<ROOK>(pos, b1, blockSquares, mlist, n);
-
- b1 = pos.queens(us) & not_pinned;
- if (b1)
- n = generate_piece_blocking_evasions<QUEEN>(pos, b1, blockSquares, mlist, n);