+ template<>
+ MoveStack* generate_piece_moves<KING>(const Position& pos, MoveStack* mlist, Color us, Bitboard target) {
+
+ Bitboard b;
+ Square from = pos.king_square(us);
+
+ b = pos.piece_attacks<KING>(from) & target;
+ SERIALIZE_MOVES(b);
+ return mlist;
+ }
+
+ template<PieceType Piece>
+ MoveStack* generate_piece_blocking_evasions(const Position& pos, MoveStack* mlist, Color us,
+ Bitboard not_pinned, Bitboard blockSquares) {
+
+ Bitboard b = pos.pieces_of_color_and_type(us, Piece) & not_pinned;
+ while (b)
+ {
+ Square from = pop_1st_bit(&b);
+ Bitboard bb = pos.piece_attacks<Piece>(from) & blockSquares;
+ SERIALIZE_MOVES(bb);
+ }
+ return mlist;
+ }
+
+ template<>
+ MoveStack* generate_piece_blocking_evasions<PAWN>(const Position& p, MoveStack* m, Color us,
+ Bitboard np, Bitboard bs) {
+ if (us == WHITE)
+ return do_generate_pawn_blocking_evasions<WHITE, RANK_8, Rank3BB, DELTA_N>(p, np, bs, m);
+ else
+ return do_generate_pawn_blocking_evasions<BLACK, RANK_1, Rank6BB, DELTA_S>(p, np, bs, m);
+ }
+
+ template<Color Us, Color Them, Bitboard TRank8BB, SquareDelta TDELTA_NE,
+ SquareDelta TDELTA_NW, SquareDelta TDELTA_N
+ >
+ MoveStack* do_generate_pawn_captures(const Position& pos, MoveStack* mlist) {
+
+ Square to;
+ Bitboard pawns = pos.pawns(Us);
+ Bitboard enemyPieces = pos.pieces_of_color(Them);