]> git.sesse.net Git - stockfish/commitdiff
Use SearchStack to pass excludedMove
authorMarco Costalba <mcostalba@gmail.com>
Wed, 2 Jun 2010 12:22:48 +0000 (13:22 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 2 Jun 2010 12:22:48 +0000 (13:22 +0100)
No functional change.

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

index 6ee1ea02a17b1e45d9dc603a75ec23a6d8e0d50e..14063e0ef84b03369a4587363647f6e55d90317a 100644 (file)
@@ -285,7 +285,7 @@ namespace {
   Value root_search(Position& pos, SearchStack* ss, RootMoveList& rml, Value* alphaPtr, Value* betaPtr);
 
   template <NodeType PvNode>
-  Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, bool allowNullmove, int threadID,  Move excludedMove = MOVE_NONE);
+  Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, bool allowNullmove, int threadID);
 
   template <NodeType PvNode>
   Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int threadID);
@@ -1032,7 +1032,7 @@ namespace {
 
   template <NodeType PvNode>
   Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth,
-               bool allowNullmove, int threadID, Move excludedMove) {
+               bool allowNullmove, int threadID) {
 
     assert(alpha >= -VALUE_INFINITE && alpha <= VALUE_INFINITE);
     assert(beta > alpha && beta <= VALUE_INFINITE);
@@ -1044,7 +1044,8 @@ namespace {
     EvalInfo ei;
     StateInfo st;
     const TTEntry* tte;
-    Move ttMove, move;
+    Key posKey;
+    Move ttMove, move, excludedMove;
     Depth ext, newDepth;
     Value bestValue, value, oldAlpha;
     Value refinedValue, nullValue, futilityValueScaled; // Non-PV specific
@@ -1058,6 +1059,7 @@ namespace {
     // Step 1. Initialize node and poll. Polling can abort search
     TM.incrementNodeCounter(threadID);
     ss->init(ply);
+    (ss + 1)->excludedMove = MOVE_NONE;
     (ss + 2)->initKillers();
 
     if (threadID == 0 && ++NodesSincePoll > NodesBetweenPolls)
@@ -1083,7 +1085,8 @@ namespace {
 
     // We don't want the score of a partial search to overwrite a previous full search
     // TT value, so we use a different position key in case of an excluded move exists.
-    Key posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key();
+    excludedMove = ss->excludedMove;
+    posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key();
 
     tte = TT.retrieve(posKey);
     ttMove = (tte ? tte->move() : MOVE_NONE);
@@ -1263,7 +1266,9 @@ namespace {
           if (abs(ttValue) < VALUE_KNOWN_WIN)
           {
               Value b = ttValue - SingularExtensionMargin;
-              Value v = search<NonPV>(pos, ss, b - 1, b, depth / 2, false, threadID, move);
+              ss->excludedMove = move;
+              Value v = search<NonPV>(pos, ss, b - 1, b, depth / 2, false, threadID);
+              ss->excludedMove = MOVE_NONE;
 
               if (v < ttValue - SingularExtensionMargin)
                   ext = OnePly;
@@ -2221,6 +2226,7 @@ namespace {
     {
         ss->init(i);
         ss->initKillers();
+        ss->excludedMove = MOVE_NONE;
     }
   }
 
index 3def04eb058f8bdd346cbeaf47281c9c26e3ec26..73a1dcf0d508410a3116103b7d3314b2db9fc310 100644 (file)
@@ -54,6 +54,7 @@ struct SearchStack {
   Move currentMove;
   Move mateKiller;
   Move threatMove;
+  Move excludedMove;
   Move killers[KILLER_MAX];
   Depth reduction;
   Value eval;