-
- int generate_black_pawn_captures(const Position &pos, MoveStack *mlist) {
-
- Bitboard pawns = pos.pawns(BLACK);
- Bitboard enemyPieces = pos.pieces_of_color(WHITE);
- Square sq;
- int n = 0;
-
- // Captures in the a8-h1 direction
- Bitboard b1 = (pawns >> 7) & ~FileABB & enemyPieces;
-
- // Capturing promotions
- Bitboard b2 = b1 & Rank1BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_promotion_move(sq - DELTA_SE, sq, QUEEN);
- }
-
- // Capturing non-promotions
- b2 = b1 & ~Rank1BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_move(sq - DELTA_SE, sq);
- }
-
- // Captures in the h8-a1 direction
- b1 = (pawns >> 9) & ~FileHBB & enemyPieces;
-
- // Capturing promotions
- b2 = b1 & Rank1BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_promotion_move(sq - DELTA_SW, sq, QUEEN);
- }
-
- // Capturing Non-promotions
- b2 = b1 & ~Rank1BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_move(sq - DELTA_SW, sq);
- }
-
- // Non-capturing promotions
- b1 = (pawns >> 8) & pos.empty_squares() & Rank1BB;
- while (b1)
- {
- sq = pop_1st_bit(&b1);
- mlist[n++].move = make_promotion_move(sq - DELTA_S, sq, QUEEN);
- }
-
- // En passant captures
- if (pos.ep_square() != SQ_NONE)
- {
- assert(square_rank(pos.ep_square()) == RANK_3);
- b1 = pawns & pos.white_pawn_attacks(pos.ep_square());