- template<Color Us>
- MoveStack* generate_pawn_blocking_evasions(const Position& pos, Bitboard pinned,
- Bitboard blockSquares, MoveStack* mlist) {
-
- // Calculate our parametrized parameters at compile time
- const Bitboard TRank8BB = (Us == WHITE ? Rank8BB : Rank1BB);
- const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
- const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
- const SquareDelta TDELTA_N = (Us == WHITE ? DELTA_N : DELTA_S);
-
- Bitboard b1, b2;
- Square to;
- Bitboard pawns = pos.pieces(PAWN, Us) & ~pinned;
- Bitboard emptySquares = pos.empty_squares();
-
- if (pawns & TRank7BB) // There is some promotion candidate ?
- {
- // Note that blockSquares are always empty
- b1 = move_pawns<Us, DELTA_N>(pawns) & blockSquares & TRank8BB;
- while (b1)
- {
- to = pop_1st_bit(&b1);
- (*mlist++).move = make_promotion_move(to - TDELTA_N, to, QUEEN);
- (*mlist++).move = make_promotion_move(to - TDELTA_N, to, ROOK);
- (*mlist++).move = make_promotion_move(to - TDELTA_N, to, BISHOP);
- (*mlist++).move = make_promotion_move(to - TDELTA_N, to, KNIGHT);
- }
- }
-
- // Single pawn pushes
- b1 = move_pawns<Us, DELTA_N>(pawns) & emptySquares & ~TRank8BB;
- b2 = b1 & blockSquares;
- SERIALIZE_MOVES_D(b2, -TDELTA_N);
-
- // Double pawn pushes. Note that blockSquares are always empty
- b1 = move_pawns<Us, DELTA_N>(b1 & TRank3BB) & blockSquares;
- SERIALIZE_MOVES_D(b1, -TDELTA_N -TDELTA_N);
- return mlist;
- }
-