- Bitboard b, occ, oldAtt, newAtt, kingAtt;
- Square from, to, ksq;
- Piece pc;
- Color them;
-
- from = from_sq(move);
- to = to_sq(move);
- them = ~pos.side_to_move();
- ksq = pos.king_square(them);
- kingAtt = pos.attacks_from<KING>(ksq);
- pc = pos.piece_moved(move);
-
- occ = pos.pieces() ^ from ^ ksq;
- oldAtt = pos.attacks_from(pc, from, occ);
- newAtt = pos.attacks_from(pc, to, occ);
-
- // Rule 1. Checks which give opponent's king at most one escape square are dangerous
- b = kingAtt & ~pos.pieces(them) & ~newAtt & ~(1ULL << to);
-
- if (!more_than_one(b))
+ Piece pc = pos.piece_moved(move);
+ Square from = from_sq(move);
+ Square to = to_sq(move);
+ Color them = ~pos.side_to_move();
+ Square ksq = pos.king_square(them);
+ Bitboard enemies = pos.pieces(them);
+ Bitboard kingAtt = pos.attacks_from<KING>(ksq);
+ Bitboard occ = pos.pieces() ^ from ^ ksq;
+ Bitboard oldAtt = pos.attacks_from(pc, from, occ);
+ Bitboard newAtt = pos.attacks_from(pc, to, occ);
+
+ // Checks which give opponent's king at most one escape square are dangerous
+ if (!more_than_one(kingAtt & ~(enemies | newAtt | to)))