]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Bitwise operator overloads between Bitboard and Square
[stockfish] / src / search.cpp
index fa12ee7109c77ad66b4f02eb8b65acc6379205a8..1131fae7e01cfe329d2769e615b0bbb879cf2b84 100644 (file)
@@ -1363,8 +1363,7 @@ split_point_start: // At split points actual search starts from here
         return true;
 
     // Rule 2. Queen contact check is very dangerous
         return true;
 
     // Rule 2. Queen contact check is very dangerous
-    if (   type_of(pc) == QUEEN
-        && bit_is_set(kingAtt, to))
+    if (type_of(pc) == QUEEN && (kingAtt & to))
         return true;
 
     // Rule 3. Creating new double threats with checks
         return true;
 
     // Rule 3. Creating new double threats with checks
@@ -1419,23 +1418,21 @@ split_point_start: // At split points actual search starts from here
 
     // Case 3: Moving through the vacated square
     p2 = pos.piece_on(f2);
 
     // Case 3: Moving through the vacated square
     p2 = pos.piece_on(f2);
-    if (   piece_is_slider(p2)
-        && bit_is_set(squares_between(f2, t2), f1))
+    if (piece_is_slider(p2) && (squares_between(f2, t2) & f1))
       return true;
 
     // Case 4: The destination square for m2 is defended by the moving piece in m1
     p1 = pos.piece_on(t1);
       return true;
 
     // Case 4: The destination square for m2 is defended by the moving piece in m1
     p1 = pos.piece_on(t1);
-    if (bit_is_set(pos.attacks_from(p1, t1), t2))
+    if (pos.attacks_from(p1, t1) & t2)
         return true;
 
     // Case 5: Discovered check, checking piece is the piece moved in m1
     ksq = pos.king_square(pos.side_to_move());
         return true;
 
     // Case 5: Discovered check, checking piece is the piece moved in m1
     ksq = pos.king_square(pos.side_to_move());
-    if (    piece_is_slider(p1)
-        &&  bit_is_set(squares_between(t1, ksq), f2))
+    if (piece_is_slider(p1) && (squares_between(t1, ksq) & f2))
     {
         Bitboard occ = pos.occupied_squares();
     {
         Bitboard occ = pos.occupied_squares();
-        xor_bit(&occ, f2);
-        if (bit_is_set(pos.attacks_from(p1, t1, occ), ksq))
+        occ ^= f2;
+        if (pos.attacks_from(p1, t1, occ) & ksq)
             return true;
     }
     return false;
             return true;
     }
     return false;
@@ -1505,9 +1502,9 @@ split_point_start: // At split points actual search starts from here
 
     // Case 3: If the moving piece in the threatened move is a slider, don't
     // prune safe moves which block its ray.
 
     // 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))
-        && bit_is_set(squares_between(tfrom, tto), mto)
-        && pos.see_sign(m) >= 0)
+    if (    piece_is_slider(pos.piece_on(tfrom))
+        && (squares_between(tfrom, tto) & mto)
+        &&  pos.see_sign(m) >= 0)
         return true;
 
     return false;
         return true;
 
     return false;