+ // Do we have escape squares from queen contact check attack ?
+ if (!(escapeSquares & ~queen_attacks_bb(to, occ & ClearMaskBB[s])))
+ {
+ // We have a mate, unless the queen is pinned or there
+ // is an X-ray attack through the queen.
+ for (int i = 0; i < pos.piece_count(Them, QUEEN); i++)
+ {
+ from = pos.piece_list(Them, QUEEN, i);
+ if ( bit_is_set(pos.attacks_from<QUEEN>(from), to)
+ && !bit_is_set(pos.pinned_pieces(Them), from)
+ && !(rook_attacks_bb(to, occ & ClearMaskBB[from]) & pos.pieces(ROOK, QUEEN, Us))
+ && !(bishop_attacks_bb(to, occ & ClearMaskBB[from]) & pos.pieces(BISHOP, QUEEN, Us)))
+
+ // Set the mate threat move
+ ei.mateThreat[Them] = make_move(from, to);
+ }