]> git.sesse.net Git - stockfish/commitdiff
Skip evaluate() call after a null move
authorMarco Costalba <mcostalba@gmail.com>
Sun, 4 Nov 2012 09:21:40 +0000 (10:21 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 4 Nov 2012 09:48:14 +0000 (10:48 +0100)
Reuse the evaluation of the parent with inverted sign and
set margin to zero (this is an hack!).

This is done only in qsearch where almost 15% of calls are
from a null move. In normal search the number of nodes where

(ss-1)->currentMove == MOVE_NULL

is almost zero and so there is no need of using this trick.

The big advantage of this patch is a speed-up due to skipped
evaluate() calls, that are very costly.

Functionality is of course affected and we will need to proper
test it later. For now we just register a 3-4% speed up.

Suggested by Hongzhi Cheng.

bench: 5051328

src/search.cpp

index 253311ae11c9ff122a4f40db5ab4e3bc07ef81e5..075aa9b4422d01d490e2a1a25196e8befe7d6002 100644 (file)
@@ -1154,6 +1154,11 @@ split_point_start: // At split points actual search starts from here
             if (ss->staticEval == VALUE_NONE || ss->evalMargin == VALUE_NONE) // Due to a race
                 ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
         }
             if (ss->staticEval == VALUE_NONE || ss->evalMargin == VALUE_NONE) // Due to a race
                 ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
         }
+        else if ((ss-1)->currentMove == MOVE_NULL)
+        {
+            ss->staticEval = bestValue = -(ss-1)->staticEval;
+            ss->evalMargin = VALUE_ZERO; // Hack, we really don't know the value
+        }
         else
             ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
 
         else
             ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);