- // Case 3: If the moving piece in the threatened move is a slider, don't
- // prune safe moves which block its ray.
- if ( piece_is_slider(pos.piece_on(tfrom))
- && (between_bb(tfrom, tto) & mto)
- && pos.see_sign(m) >= 0)
+ // The moved piece attacks the square 'tto' ?
+ if (pos.attacks_from(piece, m1to, occ) & m2to)
+ return true;
+
+ // Scan for possible X-ray attackers behind the moved piece
+ Bitboard xray = (attacks_bb< ROOK>(m2to, occ) & pos.pieces(color_of(piece), QUEEN, ROOK))
+ | (attacks_bb<BISHOP>(m2to, occ) & pos.pieces(color_of(piece), QUEEN, BISHOP));
+
+ // Verify attackers are triggered by our move and not already existing
+ if (xray && (xray ^ (xray & pos.attacks_from<QUEEN>(m2to))))
+ return true;
+ }
+
+ // Don't prune safe moves which block the threat path
+ if ((between_bb(m2from, m2to) & m1to) && pos.see_sign(first) >= 0)