- template<Color Us, MoveType Type>
- MoveStack* generate_pawn_moves(const Position& pos, MoveStack* mlist, Bitboard target, Square ksq) {
-
- // Calculate our parametrized parameters at compile time
- const Color Them = (Us == WHITE ? BLACK : WHITE);
- 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);
- const SquareDelta TDELTA_NE = (Us == WHITE ? DELTA_NE : DELTA_SE);
- const SquareDelta TDELTA_NW = (Us == WHITE ? DELTA_NW : DELTA_SW);
-
- Square to;
- Bitboard b1, b2, enemyPieces, emptySquares;
- Bitboard pawns = pos.pieces(PAWN, Us);
-
- // Standard captures and capturing promotions and underpromotions
- if (Type == CAPTURE || Type == EVASION || (pawns & TRank7BB))
- {
- enemyPieces = (Type == CAPTURE ? target : pos.pieces_of_color(opposite_color(Us)));
-
- if (Type == EVASION)
- enemyPieces &= target; // Capture only the checker piece
-
- mlist = generate_promotions<Us, Type, TDELTA_NE>(pos, mlist, pawns, enemyPieces);
- mlist = generate_pawn_captures<Type, TDELTA_NE>(mlist, pawns, enemyPieces);
- mlist = generate_promotions<Us, Type, TDELTA_NW>(pos, mlist, pawns, enemyPieces);
- mlist = generate_pawn_captures<Type, TDELTA_NW>(mlist, pawns, enemyPieces);
- }
-
- // Non-capturing promotions and underpromotions
- if (pawns & TRank7BB)
- {
- b1 = pos.empty_squares();
-
- if (Type == EVASION)
- b1 &= target; // Only blocking promotion pushes