-
- int generate_white_pawn_captures(const Position&, MoveStack*);
- int generate_black_pawn_captures(const Position&, MoveStack*);
- int generate_white_pawn_noncaptures(const Position&, MoveStack*);
- int generate_black_pawn_noncaptures(const Position&, MoveStack*);
- int generate_piece_moves(PieceType, const Position&, MoveStack*, Color side, Bitboard t);
- int generate_castle_moves(const Position&, MoveStack*, Color us);
-
- int generate_piece_checks(PieceType pce, const Position& pos, Bitboard target,
- Bitboard dc, Square ksq, MoveStack* mlist, int n);
-
- inline Bitboard next_row_white(Bitboard b) { return b << 8; }
- inline Bitboard next_row_black(Bitboard b) { return b >> 8; }
-
- struct PawnOffsets {
-
- Bitboard Rank3BB;
- Bitboard Rank8BB;
- SquareDelta DELTA_N;
- Color them;
- Bitboard (*next_row_fn)(Bitboard b);
- };
- const PawnOffsets WhitePawnOffsets = { Rank3BB, Rank8BB, DELTA_N, BLACK, &next_row_white };
- const PawnOffsets BlackPawnOffsets = { Rank6BB, Rank1BB, DELTA_S, WHITE, &next_row_black };
-
- int generate_pawn_checks(const PawnOffsets& ofs, const Position& pos, Bitboard dc,
- Square ksq, MoveStack* mlist, int n);
-}
-
-
-////
-//// Functions
-////
-
-
-/// generate_captures generates() all pseudo-legal captures and queen
-/// promotions. The return value is the number of moves generated.
-
-int generate_captures(const Position& pos, MoveStack* mlist) {
-
- assert(pos.is_ok());
- assert(!pos.is_check());
-
- Color us = pos.side_to_move();
- Bitboard target = pos.pieces_of_color(opposite_color(us));
- int n;
-
- if (us == WHITE)
- n = generate_white_pawn_captures(pos, mlist);
- else
- n = generate_black_pawn_captures(pos, mlist);
-
- for (PieceType pce = KNIGHT; pce <= KING; pce++)
- n += generate_piece_moves(pce, pos, mlist+n, us, target);
-
- return n;
-}
-
-
-/// generate_noncaptures() generates all pseudo-legal non-captures and
-/// underpromotions. The return value is the number of moves generated.
-
-int generate_noncaptures(const Position& pos, MoveStack *mlist) {
-
- assert(pos.is_ok());
- assert(!pos.is_check());
-
- Color us = pos.side_to_move();
- Bitboard target = pos.empty_squares();
- int n;
-
- if (us == WHITE)
- n = generate_white_pawn_noncaptures(pos, mlist);
- else
- n = generate_black_pawn_noncaptures(pos, mlist);
-
- for (PieceType pce = KNIGHT; pce <= KING; pce++)
- n += generate_piece_moves(pce, pos, mlist+n, us, target);