-/// generate<QUIET_CHECKS> generates all pseudo-legal non-captures and knight
-/// underpromotions that give check. Returns a pointer to the end of the move list.
-template<>
-ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* moveList) {
-
- assert(!pos.checkers());
-
- Color us = pos.side_to_move();
- Bitboard dc = pos.blockers_for_king(~us) & pos.pieces(us) & ~pos.pieces(PAWN);
-
- while (dc)
- {
- Square from = pop_lsb(&dc);
- PieceType pt = type_of(pos.piece_on(from));
-
- Bitboard b = attacks_bb(pt, from, pos.pieces()) & ~pos.pieces();
-
- if (pt == KING)
- b &= ~attacks_bb<QUEEN>(pos.square<KING>(~us));
-
- while (b)
- *moveList++ = make_move(from, pop_lsb(&b));
- }
-
- return us == WHITE ? generate_all<WHITE, QUIET_CHECKS>(pos, moveList)
- : generate_all<BLACK, QUIET_CHECKS>(pos, moveList);
-}
-
-
-/// generate<EVASIONS> generates all pseudo-legal check evasions when the side
-/// to move is in check. Returns a pointer to the end of the move list.
-template<>
-ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* moveList) {
-
- assert(pos.checkers());
-
- Color us = pos.side_to_move();
- Square ksq = pos.square<KING>(us);
- Bitboard sliderAttacks = 0;
- Bitboard sliders = pos.checkers() & ~pos.pieces(KNIGHT, PAWN);
-
- // Find all the squares attacked by slider checkers. We will remove them from
- // the king evasions in order to skip known illegal moves, which avoids any
- // useless legality checks later on.
- while (sliders)
- sliderAttacks |= line_bb(ksq, pop_lsb(&sliders)) & ~pos.checkers();
-
- // Generate evasions for king, capture and non capture moves
- Bitboard b = attacks_bb<KING>(ksq) & ~pos.pieces(us) & ~sliderAttacks;
- while (b)
- *moveList++ = make_move(ksq, pop_lsb(&b));
-
- if (more_than_one(pos.checkers()))
- return moveList; // Double check, only a king move can save the day
-
- // Generate blocking evasions or captures of the checking piece
- return us == WHITE ? generate_all<WHITE, EVASIONS>(pos, moveList)
- : generate_all<BLACK, EVASIONS>(pos, moveList);
-}
-
-