From 5804bef824587c16da4a956c51f55a2adb626199 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 2 Jun 2010 13:22:48 +0100 Subject: [PATCH] Use SearchStack to pass excludedMove No functional change. Signed-off-by: Marco Costalba --- src/search.cpp | 16 +++++++++++----- src/search.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 6ee1ea02..14063e0e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -285,7 +285,7 @@ namespace { Value root_search(Position& pos, SearchStack* ss, RootMoveList& rml, Value* alphaPtr, Value* betaPtr); template - 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 Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int threadID); @@ -1032,7 +1032,7 @@ namespace { template 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(pos, ss, b - 1, b, depth / 2, false, threadID, move); + ss->excludedMove = move; + Value v = search(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; } } diff --git a/src/search.h b/src/search.h index 3def04eb..73a1dcf0 100644 --- a/src/search.h +++ b/src/search.h @@ -54,6 +54,7 @@ struct SearchStack { Move currentMove; Move mateKiller; Move threatMove; + Move excludedMove; Move killers[KILLER_MAX]; Depth reduction; Value eval; -- 2.39.2