- template<> // Special case the King
- int generate_piece_checks<KING>(const Position& pos, Bitboard, Bitboard dc,
- Square ksq, MoveStack* mlist, int n) {
- if (bit_is_set(dc, ksq))
- {
- Bitboard bb = pos.piece_attacks<KING>(ksq)
- & pos.empty_squares()
- & ~QueenPseudoAttacks[ksq];
- while (bb)
- {
- Square to = pop_1st_bit(&bb);
- mlist[n++].move = make_move(ksq, to);
- }
- }
- return n;
+ 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, BLACK, Rank8BB, DELTA_NE, DELTA_NW, DELTA_N>(p, m)
+ : generate_pawn_captures<BLACK, WHITE, Rank1BB, DELTA_SE, DELTA_SW, DELTA_S>(p, m));
+ else
+ return (us == WHITE ? generate_pawn_noncaptures<WHITE, BLACK, Rank8BB, Rank3BB, DELTA_NE, DELTA_NW, DELTA_N>(p, m)
+ : generate_pawn_noncaptures<BLACK, WHITE, Rank1BB, Rank6BB, DELTA_SE, DELTA_SW, DELTA_S>(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) {
+ if (us == WHITE)
+ return generate_pawn_blocking_evasions<WHITE, RANK_8, Rank3BB, DELTA_N>(p, pnd, t, m);
+ else
+ return generate_pawn_blocking_evasions<BLACK, RANK_1, Rank6BB, DELTA_S>(p, pnd, t, m);