]> git.sesse.net Git - stockfish/commitdiff
Do not reset ss->eval in the beginning of the node
authorJoona Kiiski <joona.kiiski@gmail.com>
Sun, 18 Jul 2010 13:24:07 +0000 (16:24 +0300)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 19 Jul 2010 02:43:58 +0000 (03:43 +0100)
This avoids problems with IID clearing ss->eval and
eval not being available when we return

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

index 0afa0a281b60acece9abd16b0c8630e0989144d3..7249a113862f87ebe8cd6563f0bb3fa08e937ddb 100644 (file)
@@ -364,7 +364,6 @@ void SearchStack::init() {
 
   currentMove = threatMove = bestMove = MOVE_NONE;
   reduction = Depth(0);
-  eval = VALUE_NONE;
 }
 
 // SearchStack::initKillers() initializes killers for a search stack entry
@@ -771,8 +770,7 @@ namespace {
 
     // Step 5. Evaluate the position statically
     // At root we do this only to get reference value for child nodes
-    if (!isCheck)
-        ss->eval = evaluate(pos, ei);
+    ss->eval = isCheck ? VALUE_NONE : evaluate(pos, ei);
 
     // Step 6. Razoring (omitted at root)
     // Step 7. Static null move pruning (omitted at root)
@@ -1097,6 +1095,8 @@ namespace {
         refinedValue = refine_eval(tte, ss->eval, ply); // Enhance accuracy with TT value if possible
         update_gains(pos, (ss-1)->currentMove, (ss-1)->eval, ss->eval);
     }
+    else
+        ss->eval = VALUE_NONE;
 
     // Step 6. Razoring (is omitted in PV nodes)
     if (   !PvNode
@@ -1450,7 +1450,6 @@ namespace {
 
     TM.incrementNodeCounter(pos.thread());
     ss->bestMove = ss->currentMove = MOVE_NONE;
-    ss->eval = VALUE_NONE;
 
     // Check for an instant draw or maximum ply reached
     if (pos.is_draw() || ply >= PLY_MAX - 1)
@@ -1473,6 +1472,7 @@ namespace {
     if (isCheck)
     {
         bestValue = futilityBase = -VALUE_INFINITE;
+        ss->eval = VALUE_NONE;
         deepChecks = enoughMaterial = false;
     }
     else
@@ -2753,6 +2753,8 @@ namespace {
 
         // Find a quick score for the move
         init_ss_array(ss, PLY_MAX_PLUS_2);
+        ss[0].eval = VALUE_NONE;
+        ss[0].currentMove = cur->move;
         pos.do_move(cur->move, st);
         moves[count].move = cur->move;
         moves[count].score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1);