- Square checksq = first_1(checkers);
- Bitboard target = squares_between(checksq, ksq);
-
- assert(pos.color_of_piece_on(checksq) == them);
-
- // Pawn captures
- b1 = pos.attacks_from<PAWN>(checksq, them) & pos.pieces(PAWN, us) & ~pinned;
- while (b1)
- {
- from = pop_1st_bit(&b1);
- if (relative_rank(us, checksq) == RANK_8)
- {
- (*mlist++).move = make_promotion_move(from, checksq, QUEEN);
- (*mlist++).move = make_promotion_move(from, checksq, ROOK);
- (*mlist++).move = make_promotion_move(from, checksq, BISHOP);
- (*mlist++).move = make_promotion_move(from, checksq, KNIGHT);
- } else
- (*mlist++).move = make_move(from, checksq);
- }
-
- // Pawn blocking evasions (possible only if the checking piece is a slider)
- if (sliderAttacks)
- mlist = generate_piece_evasions<PAWN>(pos, mlist, us, target, pinned);
-
- // Add the checking piece to the target squares
- target |= checkers;
-
- // Captures and blocking evasions for the other pieces
- mlist = generate_piece_evasions<KNIGHT>(pos, mlist, us, target, pinned);
- mlist = generate_piece_evasions<BISHOP>(pos, mlist, us, target, pinned);
- mlist = generate_piece_evasions<ROOK>(pos, mlist, us, target, pinned);
- mlist = generate_piece_evasions<QUEEN>(pos, mlist, us, target, pinned);
-
- // Finally, the special case of en passant captures. An en passant
- // capture can only be a check evasion if the check is not a discovered
- // check. If pos.ep_square() is set, the last move made must have been
- // a double pawn push. If, furthermore, the checking piece is a pawn,
- // an en passant check evasion may be possible.
- if (pos.ep_square() != SQ_NONE && (checkers & pos.pieces(PAWN, them)))
- {
- to = pos.ep_square();
- b1 = pos.attacks_from<PAWN>(to, them) & pos.pieces(PAWN, us);