- template<PieceType Piece>
- MoveStack* generate_discovered_checks(const Position& pos, Square from, MoveStack* mlist) {
-
- assert(Piece != QUEEN);
-
- Bitboard b = pos.attacks_from<Piece>(from) & pos.empty_squares();
- if (Piece == KING)
- {
- Square ksq = pos.king_square(opposite_color(pos.side_to_move()));
- b &= ~QueenPseudoAttacks[ksq];
- }
- SERIALIZE_MOVES(b);
- return mlist;
- }
-
- template<PieceType Piece>
- MoveStack* generate_direct_checks(const Position& pos, MoveStack* mlist, Color us,
- Bitboard dc, Square ksq) {
- assert(Piece != KING);
-
- Square from;
- Bitboard checkSqs;
- const Square* ptr = pos.piece_list_begin(us, Piece);
-
- if ((from = *ptr++) == SQ_NONE)
- return mlist;
-
- checkSqs = pos.attacks_from<Piece>(ksq) & pos.empty_squares();
-
- do
- {
- if ( (Piece == QUEEN && !(QueenPseudoAttacks[from] & checkSqs))
- || (Piece == ROOK && !(RookPseudoAttacks[from] & checkSqs))
- || (Piece == BISHOP && !(BishopPseudoAttacks[from] & checkSqs)))
- continue;
-
- if (dc && bit_is_set(dc, from))
- continue;
-
- Bitboard bb = pos.attacks_from<Piece>(from) & checkSqs;
- SERIALIZE_MOVES(bb);
-
- } while ((from = *ptr++) != SQ_NONE);
-
- return mlist;
- }
-