- 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, named
- // according to the point of view of white side.
- const Color Them = (Us == WHITE ? BLACK : WHITE);
- const Bitboard TRank7BB = (Us == WHITE ? Rank7BB : Rank2BB);
- const Bitboard TRank3BB = (Us == WHITE ? Rank3BB : Rank6BB);
- const Square TDELTA_N = (Us == WHITE ? DELTA_N : DELTA_S);
- const Square TDELTA_NE = (Us == WHITE ? DELTA_NE : DELTA_SE);
- const Square TDELTA_NW = (Us == WHITE ? DELTA_NW : DELTA_SW);
-
- Square to;
- Bitboard b1, b2, dc1, dc2, pawnPushes, emptySquares;
- Bitboard pawns = pos.pieces(PAWN, Us);
- Bitboard pawnsOn7 = pawns & TRank7BB;
- Bitboard enemyPieces = (Type == MV_CAPTURE ? target : pos.pieces(Them));
-
- // Pre-calculate pawn pushes before changing emptySquares definition
- if (Type != MV_CAPTURE)
- {
- emptySquares = (Type == MV_NON_CAPTURE ? target : pos.empty_squares());
- pawnPushes = move_pawns<TDELTA_N>(pawns & ~TRank7BB) & emptySquares;
- }