From 00469d1798920b6272e9d92e250db0a388b5afd9 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Fri, 20 Aug 2010 09:16:43 +0200 Subject: [PATCH] Call apply_weight() only once in passed pawns evaluation 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 --- src/evaluate.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 6bdf4235..aeecc0b7 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -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]); } -- 2.39.2