- const PawnOffsets WhitePawnOffsets = { Rank3BB, Rank8BB, RANK_8, DELTA_N, DELTA_NE, DELTA_NW, WHITE, BLACK,
- &forward_white, forward_left_white, forward_right_white };
-
- const PawnOffsets BlackPawnOffsets = { Rank6BB, Rank1BB, RANK_1, DELTA_S, DELTA_SE, DELTA_SW, BLACK, WHITE,
- &forward_black, &forward_left_black, &forward_right_black };
-
- int generate_pawn_captures(const PawnOffsets&, const Position&, MoveStack*);
- int generate_pawn_noncaptures(const PawnOffsets&, const Position&, MoveStack*);
- int generate_pawn_checks(const PawnOffsets&, const Position&, Bitboard, Square, MoveStack*, int);
- int generate_piece_checks(PieceType, const Position&, Bitboard, Bitboard, Square, MoveStack*, int);
- int generate_piece_moves(PieceType, const Position&, MoveStack*, Color, Bitboard);
- int generate_castle_moves(const Position&, MoveStack*, Color);
- int generate_piece_blocking_evasions(PieceType, const Position&, Bitboard, Bitboard, MoveStack*, int);
- int generate_pawn_blocking_evasions(const PawnOffsets&, const Position&, Bitboard, Bitboard, MoveStack*, int);
+ template<>
+ inline MoveStack* generate_piece_checks<PAWN>(const Position& p, MoveStack* m, Color us, Bitboard dc, Square ksq) {
+
+ return (us == WHITE ? generate_pawn_checks<WHITE>(p, dc, ksq, m)
+ : generate_pawn_checks<BLACK>(p, dc, ksq, m));
+ }
+
+ // Template generate_piece_moves() with specializations and overloads
+ template<PieceType>
+ MoveStack* generate_piece_moves(const Position&, MoveStack*, Color us, Bitboard);
+
+ template<>
+ MoveStack* generate_piece_moves<KING>(const Position&, MoveStack*, Color, Bitboard);
+
+ template<PieceType Piece, MoveType Type>
+ inline MoveStack* generate_piece_moves(const Position& p, MoveStack* m, Color us) {
+
+ assert(Piece == PAWN);
+
+ if (Type == CAPTURE)
+ return (us == WHITE ? generate_pawn_captures<WHITE>(p, m)
+ : generate_pawn_captures<BLACK>(p, m));
+ else
+ return (us == WHITE ? generate_pawn_noncaptures<WHITE>(p, m)
+ : generate_pawn_noncaptures<BLACK>(p, m));
+ }
+
+ template<PieceType>
+ MoveStack* generate_piece_moves(const Position&, MoveStack*, Color us, Bitboard, Bitboard);
+
+ template<>
+ inline MoveStack* generate_piece_moves<PAWN>(const Position& p, MoveStack* m,
+ Color us, Bitboard t, Bitboard pnd) {
+
+ return (us == WHITE ? generate_pawn_blocking_evasions<WHITE>(p, pnd, t, m)
+ : generate_pawn_blocking_evasions<BLACK>(p, pnd, t, m));
+ }