]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Exclude queen from Rook Contact Check computation
[stockfish] / src / evaluate.cpp
index f5eece7dc0725f8c72f8c91ec75838ba4e7788d7..563e707ffe48df1c01d0e65dd5b4cbb7fb03e2f9 100644 (file)
@@ -438,7 +438,7 @@ namespace {
         {
             // ...and then remove squares not supported by another enemy piece
             b &= (  ei.attackedBy[Them][PAWN]   | ei.attackedBy[Them][KNIGHT]
-                  | ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][QUEEN]);
+                  | ei.attackedBy[Them][BISHOP]);
 
             if (b)
                 attackUnits += RookContactCheck * popcount<Max15>(b);
@@ -498,25 +498,24 @@ namespace {
     enum { Defended, Weak };
     enum { Minor, Major };
 
-    Bitboard b, weak, defended, safe_pawns, safe_pawn_threats, unsafe_pawn_threats;
+    Bitboard b, weak, defended, safeThreats;
     Score score = SCORE_ZERO;
 
-    // Pawn Threats
-    b = ei.attackedBy[Us][PAWN] & (pos.pieces(Them) ^ pos.pieces(Them, PAWN));
+    // Non-pawn enemies attacked by a pawn
+    weak = (pos.pieces(Them) ^ pos.pieces(Them, PAWN)) & ei.attackedBy[Us][PAWN];
 
-    if (b)
+    if (weak)
     {
-        safe_pawns = pos.pieces(Us, PAWN) & (~ei.attackedBy[Them][ALL_PIECES] | ei.attackedBy[Us][ALL_PIECES]);
-        safe_pawn_threats = (shift_bb<Right>(safe_pawns) | shift_bb<Left>(safe_pawns)) & (pos.pieces(Them) ^ pos.pieces(Them, PAWN));
-        unsafe_pawn_threats = b ^ safe_pawn_threats;
+        b = pos.pieces(Us, PAWN) & ( ~ei.attackedBy[Them][ALL_PIECES]
+                                    | ei.attackedBy[Us][ALL_PIECES]);
+
+        safeThreats = (shift_bb<Right>(b) | shift_bb<Left>(b)) & weak;
 
-        // Unsafe pawn threats
-        if (unsafe_pawn_threats)
+        if (weak ^ safeThreats)
             score += ThreatenedByHangingPawn;
 
-        // Evaluate safe pawn threats
-        while (safe_pawn_threats)
-            score += ThreatenedByPawn[type_of(pos.piece_on(pop_lsb(&safe_pawn_threats)))];
+        while (safeThreats)
+            score += ThreatenedByPawn[type_of(pos.piece_on(pop_lsb(&safeThreats)))];
     }
 
     // Non-pawn enemies defended by a pawn