Store position static score in TT as soon as possible
authorMarco Costalba <mcostalba@gmail.com>
Tue, 20 Jul 2010 21:36:38 +0000 (22:36 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 21 Jul 2010 11:08:45 +0000 (12:08 +0100)
So to maximize the possibility to avoid to recalculate it
in the future. A small speed-up of 0.8%

Idea by Ralph Stoesser.

No functional change.

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

index a3687c0760ef9d9be5a61d56e56f01aa5b900133..83ce84d87c64cfd16e0e7f646a6893b7f7bcc5c5 100644 (file)
@@ -1090,7 +1090,10 @@ namespace {
             ei.kingDanger[pos.side_to_move()] = tte->king_danger();
         }
         else
+        {
             ss->eval = evaluate(pos, ei);
+            TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ei.kingDanger[pos.side_to_move()]);
+        }
 
         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);
@@ -1108,10 +1111,6 @@ namespace {
         && !value_is_mate(beta)
         && !pos.has_pawn_on_7th(pos.side_to_move()))
     {
-        // Pass ss->eval to qsearch() and avoid an evaluate call
-        if (!tte)
-            TT.store(posKey, VALUE_NONE, VALUE_TYPE_NONE, DEPTH_NONE, MOVE_NONE, ss->eval, ei.kingDanger[pos.side_to_move()]);
-
         Value rbeta = beta - razor_margin(depth);
         Value v = qsearch<NonPV>(pos, ss, rbeta-1, rbeta, Depth(0), ply);
         if (v < rbeta)