]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Rename ei.kingDanger in ei.margin
[stockfish] / src / evaluate.cpp
index 6bdf423598c6d7bf0504947e2edb3b0cf7fa2838..da4860fe1ce25b26ae89d44fa97b6392a4ae23ba 100644 (file)
@@ -709,14 +709,14 @@ namespace {
         attackUnits = Min(99, Max(0, attackUnits));
 
         // Finally, extract the king danger score from the KingDangerTable[]
-        // array and subtract the score from evaluation. Set also ei.kingDanger[]
+        // array and subtract the score from evaluation. Set also ei.margin[]
         // value that will be used for pruning because this value can sometimes
         // be very big, and so capturing a single attacking piece can therefore
         // result in a score change far bigger than the value of the captured piece.
         ei.value -= Sign[Us] * KingDangerTable[Us][attackUnits];
-        ei.kingDanger[Us] = mg_value(KingDangerTable[Us][attackUnits]);
+        ei.margin[Us] = mg_value(KingDangerTable[Us][attackUnits]);
     } else
-        ei.kingDanger[Us] = VALUE_ZERO;
+        ei.margin[Us] = VALUE_ZERO;
   }
 
 
@@ -727,11 +727,14 @@ namespace {
 
     const Color Them = (Us == WHITE ? BLACK : WHITE);
 
+    Score bonus = SCORE_ZERO;
     Bitboard squaresToQueen, defendedSquares, unsafeSquares, supportingPawns;
     Bitboard b = ei.pi->passed_pawns(Us);
 
-    while (b)
-    {
+    if (!b)
+        return;
+
+    do {
         Square s = pop_1st_bit(&b);
 
         assert(pos.pawn_is_passed(Us, s));
@@ -806,11 +809,12 @@ namespace {
             else if (pos.pieces(ROOK, QUEEN, Them))
                 ebonus -= ebonus / 4;
         }
+        bonus += make_score(mbonus, ebonus);
 
-        // Add the scores for this pawn to the middle game and endgame eval
-        ei.value += Sign[Us] * apply_weight(make_score(mbonus, ebonus), Weights[PassedPawns]);
+    } while (b);
 
-    } // while
+    // Add the scores to the middle game and endgame eval
+    ei.value += Sign[Us] * apply_weight(bonus, Weights[PassedPawns]);
   }