// Position representation
Bitboard pieces(PieceType pt) const;
- Bitboard pieces(PieceType pt1, PieceType pt2) const;
+ template<typename ...PieceTypes> Bitboard pieces(PieceType pt, PieceTypes... pts) const;
Bitboard pieces(Color c) const;
- Bitboard pieces(Color c, PieceType pt) const;
- Bitboard pieces(Color c, PieceType pt1, PieceType pt2) const;
+ template<typename ...PieceTypes> Bitboard pieces(Color c, PieceTypes... pts) const;
Piece piece_on(Square s) const;
Square ep_square() const;
bool empty(Square s) const;
return byTypeBB[pt];
}
-inline Bitboard Position::pieces(PieceType pt1, PieceType pt2) const {
- return pieces(pt1) | pieces(pt2);
+template<typename ...PieceTypes>
+inline Bitboard Position::pieces(PieceType pt, PieceTypes... pts) const {
+ return pieces(pt) | pieces(pts...);
}
inline Bitboard Position::pieces(Color c) const {
return byColorBB[c];
}
-inline Bitboard Position::pieces(Color c, PieceType pt) const {
- return pieces(c) & pieces(pt);
-}
-
-inline Bitboard Position::pieces(Color c, PieceType pt1, PieceType pt2) const {
- return pieces(c) & (pieces(pt1) | pieces(pt2));
+template<typename ...PieceTypes>
+inline Bitboard Position::pieces(Color c, PieceTypes... pts) const {
+ return pieces(c) & pieces(pts...);
}
template<PieceType Pt> inline int Position::count(Color c) const {
{
if (depth < 2 - capture)
continue;
- // don't prune move if a heavy enemy piece (KQR) is under attack after the exchanges
- Bitboard leftEnemies = (pos.pieces(~us, QUEEN, ROOK) | pos.pieces(~us, KING)) & occupied;
+ // Don't prune the move if opp. King/Queen/Rook is attacked by a slider after the exchanges.
+ // Since in see_ge we don't update occupied when the king recaptures, we also don't prune the
+ // move when the opp. King gets a discovered slider attack DURING the exchanges.
+ Bitboard leftEnemies = pos.pieces(~us, ROOK, QUEEN, KING) & occupied;
Bitboard attacks = 0;
occupied |= to_sq(move);
while (leftEnemies && !attacks)
{
Square sq = pop_lsb(leftEnemies);
- attacks |= pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
- // exclude Queen/Rook(s) which were already threatened before SEE
- if (attacks && (sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us))))
+ attacks = pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
+ // Exclude Queen/Rook(s) which were already threatened before SEE
+ if (attacks && sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us)))
attacks = 0;
}
if (!attacks)