]> git.sesse.net Git - stockfish/blobdiff - src/search.cpp
Do not reset ss->eval in the beginning of the node
[stockfish] / src / search.cpp
index d1642827f540263686c57b5100b98d0e268aa2fc..7249a113862f87ebe8cd6563f0bb3fa08e937ddb 100644 (file)
@@ -342,8 +342,8 @@ void init_search() {
   // Init reductions array
   for (hd = 1; hd < 64; hd++) for (mc = 1; mc < 64; mc++)
   {
-      double    pvRed = log(double(hd)) * log(double(mc)) / 3.0;
-      double nonPVRed = log(double(hd)) * log(double(mc)) / 1.5;
+      double    pvRed = 0.33 + log(double(hd)) * log(double(mc)) / 4.5;
+      double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
       ReductionMatrix[PV][hd][mc]    = (int8_t) (   pvRed >= 1.0 ? floor(   pvRed * int(OnePly)) : 0);
       ReductionMatrix[NonPV][hd][mc] = (int8_t) (nonPVRed >= 1.0 ? floor(nonPVRed * int(OnePly)) : 0);
   }
@@ -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);