]> git.sesse.net Git - stockfish/commitdiff
Refactor pure static eval code
authorOndrej Mosnacek <omosnacek@gmail.com>
Tue, 28 Aug 2018 23:22:22 +0000 (01:22 +0200)
committerStéphane Nicolet <cassio@free.fr>
Tue, 28 Aug 2018 23:24:45 +0000 (01:24 +0200)
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.

src/search.cpp

index cd435c672f877a64082689d91eb852f5fbe3eb07..03a8bfcd0885fc0d6d92e6079ffbf816ef789733 100644 (file)
@@ -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);
     }