- 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<GenType Type> FORCE_INLINE
+ MoveStack* generate_all(const Position& pos, MoveStack* mlist, Color us,
+ Bitboard target, const CheckInfo* ci = NULL) {
+
+ const bool Checks = Type == QUIET_CHECKS;
+
+ mlist = (us == WHITE ? generate_pawn_moves<WHITE, Type>(pos, mlist, target, ci)
+ : generate_pawn_moves<BLACK, 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_castle<KING_SIDE, Checks, true>(pos, mlist, us);
+ mlist = generate_castle<QUEEN_SIDE, Checks, true>(pos, mlist, us);
+ }
+ else
+ {
+ mlist = generate_castle<KING_SIDE, Checks, false>(pos, mlist, us);
+ mlist = generate_castle<QUEEN_SIDE, Checks, false>(pos, mlist, us);
+ }
+ }
+