-
- 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);
+
+ // Function
+ int generate_castle_moves(const Position&, MoveStack*);
+
+ // Template generate_pawn_captures() with specializations
+ template<Color, Color, Bitboard, SquareDelta, SquareDelta, SquareDelta>
+ int do_generate_pawn_captures(const Position& pos, MoveStack* mlist);
+
+ template<Color>
+ inline int generate_pawn_captures(const Position& p, MoveStack* m) {
+ return do_generate_pawn_captures<WHITE, BLACK, Rank8BB, DELTA_NE, DELTA_NW, DELTA_N>(p, m);
+ }
+ template<>
+ inline int generate_pawn_captures<BLACK>(const Position& p, MoveStack* m) {
+ return do_generate_pawn_captures<BLACK, WHITE, Rank1BB, DELTA_SE, DELTA_SW, DELTA_S>(p, m);
+ }
+
+ // Template generate_pawn_noncaptures() with specializations
+ template<Color, Color, Bitboard, Bitboard, SquareDelta, SquareDelta, SquareDelta>
+ int do_generate_pawn_noncaptures(const Position& pos, MoveStack* mlist);
+
+ template<Color>
+ inline int generate_pawn_noncaptures(const Position& p, MoveStack* m) {
+ return do_generate_pawn_noncaptures<WHITE, BLACK, Rank8BB, Rank3BB, DELTA_NE, DELTA_NW, DELTA_N>(p, m);
+ }
+ template<>
+ inline int generate_pawn_noncaptures<BLACK>(const Position& p, MoveStack* m) {
+ return do_generate_pawn_noncaptures<BLACK, WHITE, Rank1BB, Rank6BB, DELTA_SE, DELTA_SW, DELTA_S>(p, m);
+ }
+
+ // Template generate_pawn_blocking_evasions() with specializations
+ template<Color Us, Bitboard, Bitboard, SquareDelta>
+ int do_generate_pawn_blocking_evasions(const Position& pos, Bitboard not_pinned,
+ Bitboard blockSquares, MoveStack* mlist);
+ template<Color>
+ inline int generate_pawn_blocking_evasions(const Position& p, Bitboard np, Bitboard bs, MoveStack* m) {
+ return do_generate_pawn_blocking_evasions<WHITE, Rank8BB, Rank3BB, DELTA_N>(p, np, bs, m);
+ }
+ template<>
+ inline int generate_pawn_blocking_evasions<BLACK>(const Position& p, Bitboard np, Bitboard bs, MoveStack* m) {
+ return do_generate_pawn_blocking_evasions<BLACK, Rank1BB, Rank6BB, DELTA_S>(p, np, bs, m);
+ }
+
+ // Template generate_pawn_checks() with specializations
+ template<Color, Color, Bitboard, Bitboard, SquareDelta>
+ int do_generate_pawn_checks(const Position&, Bitboard, Square, MoveStack*);
+
+ template<Color>
+ inline int generate_pawn_checks(const Position& p, Bitboard dc, Square ksq, MoveStack* m) {
+ return do_generate_pawn_checks<WHITE, BLACK, Rank8BB, Rank3BB, DELTA_N>(p, dc, ksq, m);
+ }
+ template<>
+ inline int generate_pawn_checks<BLACK>(const Position& p, Bitboard dc, Square ksq, MoveStack* m) {
+ return do_generate_pawn_checks<BLACK, WHITE, Rank1BB, Rank6BB, DELTA_S>(p, dc, ksq, m);
+ }
+
+ // non-pawn templates
+ template<PieceType>
+ int generate_piece_moves(const Position&, MoveStack*, Color us, Bitboard);
+ template<>
+ int generate_piece_moves<KING>(const Position& pos, MoveStack* mlist, Color us, Bitboard target);
+
+ template<PieceType>
+ int generate_piece_checks(const Position&, Bitboard, Bitboard, Square, MoveStack*);
+ int generate_piece_checks_king(const Position&, Square, Bitboard, Square, MoveStack*);
+
+ template<PieceType>
+ int generate_piece_blocking_evasions(const Position&, Bitboard, Bitboard, MoveStack*);