+ template<PieceType Piece>
+ int generate_piece_moves(const Position &pos, MoveStack *mlist,
+ Color side, Bitboard target) {
+ int n = 0;
+ for (int i = 0; i < pos.piece_count(side, Piece); i++)
+ {
+ Square from = pos.piece_list(side, Piece, i);
+ Bitboard b = pos.piece_attacks<Piece>(from) & target;
+ while (b)
+ {
+ Square to = pop_1st_bit(&b);
+ mlist[n++].move = make_move(from, to);
+ }
+ }
+ return n;
+ }
+
+
+ template<PieceType Piece>
+ int generate_piece_blocking_evasions(const Position& pos, Bitboard b,
+ Bitboard blockSquares, MoveStack* mlist, int n) {
+ while (b)
+ {
+ Square from = pop_1st_bit(&b);
+ Bitboard bb = pos.piece_attacks<Piece>(from) & blockSquares;
+ while (bb)
+ {
+ Square to = pop_1st_bit(&bb);
+ mlist[n++].move = make_move(from, to);
+ }
+ }
+ return n;
+ }
+
+