- // 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);
- }
-
- // Finally, the ugly 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.pawns(them)))
- {
- to = pos.ep_square();
- b1 = pos.pawn_attacks(them, to) & pos.pawns(us);
-
- assert(b1 != EmptyBoardBB);
-
- b1 &= not_pinned;
- while (b1)
- {
- from = pop_1st_bit(&b1);
-
- // Before generating the move, we have to make sure it is legal.
- // This is somewhat tricky, because the two disappearing pawns may
- // cause new "discovered checks". We test this by removing the
- // two relevant bits from the occupied squares bitboard, and using
- // the low-level bitboard functions for bishop and rook attacks.
- b2 = pos.occupied_squares();
- clear_bit(&b2, from);
- clear_bit(&b2, checksq);
- if (!( (bishop_attacks_bb(ksq, b2) & pos.bishops_and_queens(them))
- ||(rook_attacks_bb(ksq, b2) & pos.rooks_and_queens(them))))
-
- mlist[n++].move = make_ep_move(from, to);
- }
- }