]> git.sesse.net Git - stockfish/commitdiff
Call apply_weight() only once in passed pawns evaluation
authorMarco Costalba <mcostalba@gmail.com>
Fri, 20 Aug 2010 07:16:43 +0000 (09:16 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 24 Aug 2010 18:13:13 +0000 (19:13 +0100)
First accumulate the bonus for each pawn, then call the
not very fast apply_weight().

Should be no functional change apart from rounding issues.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/evaluate.cpp

index 6bdf423598c6d7bf0504947e2edb3b0cf7fa2838..aeecc0b7ff8b19c815a65e3cc22a9715d89847d3 100644 (file)
@@ -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]);
   }