From 1b6459195c82395d861cddf3f2056ed1c9a3bd5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Demetz?= Date: Sat, 13 Jan 2018 09:01:23 +0100 Subject: [PATCH 1/1] Simplify verification search (#1362) 1. avoid recursive call of verification. For the interested side to move recursion makes no sense. For the other side it could make sense in case of mutual zugzwang, but I was not able to figure out any concrete problematic position. Allows the removal of 2 local variables. 2. avoid further reduction by removing R += ONE_PLY; Benchmark with zugzwang-suite (see #1338), max 45 secs per position: Patch solves 33 out of 37 Master solves 31 out of 37 STC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 76188 W: 13866 L: 13840 D: 48482 http://tests.stockfishchess.org/tests/view/5a5612ed0ebc590297da516c LTC: LLR: 2.95 (-2.94,2.94) [-3.00,1.00] Total: 40479 W: 5247 L: 5152 D: 30080 http://tests.stockfishchess.org/tests/view/5a56f7d30ebc590299e4550e bench: 5340015 --- src/search.cpp | 13 +++++-------- src/thread.cpp | 4 +--- src/thread.h | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index a4b2e7e4..2fd84207 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -676,7 +676,7 @@ namespace { if ( !PvNode && eval >= beta && ss->staticEval >= beta - 36 * depth / ONE_PLY + 225 - && (ss->ply >= thisThread->nmp_ply || ss->ply % 2 == thisThread->pair)) + && (ss->ply >= thisThread->nmp_ply || ss->ply % 2 != thisThread->nmp_odd)) { assert(eval - beta >= 0); @@ -698,21 +698,18 @@ namespace { if (nullValue >= VALUE_MATE_IN_MAX_PLY) nullValue = beta; - if (depth < 12 * ONE_PLY && abs(beta) < VALUE_KNOWN_WIN) + if (abs(beta) < VALUE_KNOWN_WIN && (depth < 12 * ONE_PLY || thisThread->nmp_ply)) return nullValue; // Do verification search at high depths - R += ONE_PLY; // disable null move pruning for side to move for the first part of the remaining search tree - int nmp_ply = thisThread->nmp_ply; - int pair = thisThread->pair; thisThread->nmp_ply = ss->ply + 3 * (depth-R) / 4; - thisThread->pair = (ss->ply % 2) == 0; + thisThread->nmp_odd = ss->ply % 2; Value v = depth-R < ONE_PLY ? qsearch(pos, ss, beta-1, beta) : search(pos, ss, beta-1, beta, depth-R, false, true); - thisThread->pair = pair; - thisThread->nmp_ply = nmp_ply; + + thisThread->nmp_odd = thisThread->nmp_ply = 0; if (v >= beta) return nullValue; diff --git a/src/thread.cpp b/src/thread.cpp index 8e9720c5..97beb580 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -187,12 +187,10 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states, for (Thread* th : *this) { - th->nodes = th->tbHits = 0; + th->nodes = th->tbHits = th->nmp_ply = th->nmp_odd = 0; th->rootDepth = th->completedDepth = DEPTH_ZERO; th->rootMoves = rootMoves; th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th); - th->nmp_ply = 0; - th->pair = -1; } setupStates->back() = tmp; diff --git a/src/thread.h b/src/thread.h index 70ae35db..13974497 100644 --- a/src/thread.h +++ b/src/thread.h @@ -61,7 +61,7 @@ public: Material::Table materialTable; Endgames endgames; size_t PVIdx; - int selDepth, nmp_ply, pair; + int selDepth, nmp_ply, nmp_odd; std::atomic nodes, tbHits; Position rootPos; -- 2.39.2