- template<> FORCE_INLINE
- MoveStack* generate_moves<KING, false>(const Position& pos, MoveStack* mlist, Color us,
- Bitboard target, const CheckInfo*) {
- Square from = pos.king_square(us);
- Bitboard b = pos.attacks_from<KING>(from) & target;
- SERIALIZE(b);
+
+ template<Color Us, GenType Type> FORCE_INLINE
+ ExtMove* generate_all(const Position& pos, ExtMove* mlist, Bitboard target,
+ const CheckInfo* ci = NULL) {
+
+ const bool Checks = Type == QUIET_CHECKS;
+
+ mlist = generate_pawn_moves<Us, Type>(pos, mlist, target, ci);
+ mlist = generate_moves<KNIGHT, Checks>(pos, mlist, Us, target, ci);
+ mlist = generate_moves<BISHOP, Checks>(pos, mlist, Us, target, ci);
+ mlist = generate_moves< ROOK, Checks>(pos, mlist, Us, target, ci);
+ mlist = generate_moves< QUEEN, Checks>(pos, mlist, Us, target, ci);
+
+ if (Type != QUIET_CHECKS && Type != EVASIONS)
+ {
+ Square from = pos.king_square(Us);
+ Bitboard b = pos.attacks_from<KING>(from) & target;
+ SERIALIZE(b);
+ }
+
+ if (Type != CAPTURES && Type != EVASIONS && pos.can_castle(Us))
+ {
+ if (pos.is_chess960())
+ {
+ mlist = generate_castling< KING_SIDE, Checks, true>(pos, mlist, Us);
+ mlist = generate_castling<QUEEN_SIDE, Checks, true>(pos, mlist, Us);
+ }
+ else
+ {
+ mlist = generate_castling< KING_SIDE, Checks, false>(pos, mlist, Us);
+ mlist = generate_castling<QUEEN_SIDE, Checks, false>(pos, mlist, Us);
+ }
+ }
+