]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Assorted code style of latest commits
[stockfish] / src / evaluate.cpp
index 0194079b3724a6ba07d98ec5f56d318f8b7dd8aa..b50792da85a05ae5ad85f3557543cb01bbfc69d6 100644 (file)
@@ -498,24 +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));
-    if(b)
+    // Non-pawn enemies attacked by a pawn
+    weak = (pos.pieces(Them) ^ pos.pieces(Them, PAWN)) & ei.attackedBy[Us][PAWN];
+
+    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;
-       // Unsafe pawn threats
-        if(unsafe_pawn_threats)
-         score += ThreatenedByHangingPawn;
+        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;
 
-       // Evaluate safe pawn threats
-        while(safe_pawn_threats)
-         score += ThreatenedByPawn[type_of(pos.piece_on(pop_lsb(&safe_pawn_threats)))];
+        if (weak ^ safeThreats)
+            score += ThreatenedByHangingPawn;
 
+        while (safeThreats)
+            score += ThreatenedByPawn[type_of(pos.piece_on(pop_lsb(&safeThreats)))];
     }
 
     // Non-pawn enemies defended by a pawn