From: Ondrej Mosnacek Date: Tue, 28 Aug 2018 23:22:22 +0000 (+0200) Subject: Refactor pure static eval code X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=4aa091cf4486b0f03d0026eee5a1b48c04dbad8e;hp=8a4821923ac6860c791185a6d25c60ad0391739f Refactor pure static eval code This commit tries to make the new pure static eval code more readable by splitting up the nested assignments into separate lines and making a few more cosmetic tweaks. No functional change. --- diff --git a/src/search.cpp b/src/search.cpp index cd435c67..03a8bfcd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -705,15 +705,16 @@ namespace { // Step 6. Static evaluation of the position if (inCheck) { - ss->staticEval = pureStaticEval = eval = VALUE_NONE; + ss->staticEval = eval = pureStaticEval = VALUE_NONE; improving = false; goto moves_loop; // Skip early pruning when in check } else if (ttHit) { // Never assume anything on values stored in TT - if ((ss->staticEval = pureStaticEval = eval = tte->eval()) == VALUE_NONE) - eval = ss->staticEval = pureStaticEval = evaluate(pos); + ss->staticEval = eval = pureStaticEval = tte->eval(); + if (eval == VALUE_NONE) + ss->staticEval = eval = pureStaticEval = evaluate(pos); // Can ttValue be used as a better position evaluation? if ( ttValue != VALUE_NONE @@ -722,12 +723,17 @@ namespace { } else { - int p = (ss-1)->statScore; - int bonus = p > 0 ? (-p - 2500) / 512 : - p < 0 ? (-p + 2500) / 512 : 0; + if ((ss-1)->currentMove != MOVE_NULL) + { + int p = (ss-1)->statScore; + int bonus = p > 0 ? (-p - 2500) / 512 : + p < 0 ? (-p + 2500) / 512 : 0; - ss->staticEval = eval = (ss-1)->currentMove != MOVE_NULL ? (pureStaticEval = evaluate(pos)) + bonus - : (pureStaticEval = -(ss-1)->staticEval + 2 * Eval::Tempo); + pureStaticEval = evaluate(pos); + ss->staticEval = eval = pureStaticEval + bonus; + } + else + ss->staticEval = eval = pureStaticEval = -(ss-1)->staticEval + 2 * Eval::Tempo; tte->save(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, pureStaticEval); }