{
// Penalty if any relative pin or discovered attack against the queen
Bitboard queenPinners;
- if (pos.slider_blockers(pos.pieces(Them, ROOK, BISHOP), s, queenPinners))
+ if (pos.slider_blockers(pos.pieces(Them, ROOK, BISHOP), s, queenPinners, Them))
score -= WeakQueen;
}
}
void Position::set_check_info(StateInfo* si) const {
- si->blockersForKing[WHITE] = slider_blockers(pieces(BLACK), count<KING>(WHITE) ? square<KING>(WHITE) : SQ_NONE, si->pinners[BLACK]);
- si->blockersForKing[BLACK] = slider_blockers(pieces(WHITE), count<KING>(BLACK) ? square<KING>(BLACK) : SQ_NONE, si->pinners[WHITE]);
+ si->blockersForKing[WHITE] = slider_blockers(pieces(BLACK), count<KING>(WHITE) ? square<KING>(WHITE) : SQ_NONE, si->pinners[BLACK], BLACK);
+ si->blockersForKing[BLACK] = slider_blockers(pieces(WHITE), count<KING>(BLACK) ? square<KING>(BLACK) : SQ_NONE, si->pinners[WHITE], WHITE);
Square ksq = count<KING>(~sideToMove) ? square<KING>(~sideToMove) : SQ_NONE;
/// a pinned or a discovered check piece, according if its color is the opposite
/// or the same of the color of the slider.
-Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const {
+Bitboard Position::slider_blockers(Bitboard sliders, Square s, Bitboard& pinners, Color c) const {
Bitboard blockers = 0;
pinners = 0;
return blockers;
// Snipers are sliders that attack 's' when a piece is removed
- Bitboard snipers = sliders
- & attackers_to(s, 0)
- & ~attackers_to(s);
+ Bitboard snipers = 0;
+
+ for (PieceType pt : piece_types())
+ {
+ Bitboard b = sliders & (PseudoAttacks[~c][pt][s] ^ LeaperAttacks[~c][pt][s]) & pieces(c, pt);
+ if (b)
+ snipers |= b & ~attacks_from(~c, pt, s);
+ }
while (snipers)
{
Bitboard attacks_from(Color c, PieceType pt, Square s) const;
template<PieceType> Bitboard attacks_from(Color c, Square s) const;
Bitboard moves_from(Color c, PieceType pt, Square s) const;
- Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners) const;
+ Bitboard slider_blockers(Bitboard sliders, Square s, Bitboard& pinners, Color c) const;
// Properties of moves
bool legal(Move m) const;