- return n;
- }
-
-
- template<Color C>
- int generate_pawn_noncaptures(const Position& pos, MoveStack* mlist) {
-
- static const PawnParams PP = (C == WHITE ? WhitePawnParams : BlackPawnParams);
-
- Bitboard pawns = pos.pawns(PP.us);
- Bitboard enemyPieces = pos.pieces_of_color(PP.them);
- Bitboard emptySquares = pos.empty_squares();
- Bitboard b1, b2;
- Square sq;
- int n = 0;
-
- // Underpromotion captures in the a1-h8 (a8-h1 for black) direction
- b1 = (C == WHITE ? pawns << 9 : pawns >> 7) & ~FileABB & enemyPieces & PP.Rank8BB;
- while (b1)
- {
- sq = pop_1st_bit(&b1);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NE, sq, ROOK);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NE, sq, BISHOP);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NE, sq, KNIGHT);
- }
-
- // Underpromotion captures in the h1-a8 (h8-a1 for black) direction
- b1 = (C == WHITE ? pawns << 7 : pawns >> 9) & ~FileHBB & enemyPieces & PP.Rank8BB;
- while (b1)
- {
- sq = pop_1st_bit(&b1);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NW, sq, ROOK);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NW, sq, BISHOP);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_NW, sq, KNIGHT);
- }
-
- // Single pawn pushes
- b1 = (C == WHITE ? pawns << 8 : pawns >> 8) & emptySquares;
- b2 = b1 & PP.Rank8BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_N, sq, ROOK);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_N, sq, BISHOP);
- mlist[n++].move = make_promotion_move(sq - PP.DELTA_N, sq, KNIGHT);
- }
- b2 = b1 & ~PP.Rank8BB;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_move(sq - PP.DELTA_N, sq);
- }
-
- // Double pawn pushes
- b2 = (C == WHITE ? (b1 & PP.Rank3BB) << 8 : (b1 & PP.Rank3BB) >> 8) & emptySquares;
- while (b2)
- {
- sq = pop_1st_bit(&b2);
- mlist[n++].move = make_move(sq - PP.DELTA_N - PP.DELTA_N, sq);
- }
- return n;
- }
-
-
- template<Color C>
- int generate_pawn_checks(const Position& pos, Bitboard dc, Square ksq, MoveStack* mlist)
- {
- static const PawnParams PP = (C == WHITE ? WhitePawnParams : BlackPawnParams);
-
- // Pawn moves which give discovered check. This is possible only if the
- // pawn is not on the same file as the enemy king, because we don't
- // generate captures.
- int n = 0;
- Bitboard empty = pos.empty_squares();
-
- // Find all friendly pawns not on the enemy king's file
- Bitboard b1 = pos.pawns(pos.side_to_move()) & ~file_bb(ksq), b2, b3;
-
- // Discovered checks, single pawn pushes
- b2 = b3 = (C == WHITE ? (b1 & dc) << 8 : (b1 & dc) >> 8) & ~PP.Rank8BB & empty;
- while (b3)
- {
- Square to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - PP.DELTA_N, to);
- }
-
- // Discovered checks, double pawn pushes
- b3 = (C == WHITE ? (b2 & PP.Rank3BB) << 8 : (b2 & PP.Rank3BB) >> 8) & empty;
- while (b3)
- {
- Square to = pop_1st_bit(&b3);
- mlist[n++].move = make_move(to - PP.DELTA_N - PP.DELTA_N, to);
- }
-
- // Direct checks. These are possible only for pawns on neighboring files
- // of the enemy king
-
- b1 &= (~dc & neighboring_files_bb(ksq)); // FIXME why ~dc ??