]> git.sesse.net Git - stockfish/commitdiff
Fix rootComplexity calculation
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 9 Apr 2023 07:18:29 +0000 (09:18 +0200)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sun, 9 Apr 2023 13:19:49 +0000 (15:19 +0200)
The calculation of rootComplexity can't call eval when in check.
Doing so triggers an assert if compiled in debug mode when
the rootpos is evaluated using classical eval.

Fixes https://github.com/official-stockfish/Stockfish/issues/4512

Passed STC:
https://tests.stockfishchess.org/tests/view/6432697431feee5c6d306876
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 41096 W: 11017 L: 10815 D: 19264
Ptnml(0-2): 113, 4172, 11780, 4366, 117

Running LTC:
https://tests.stockfishchess.org/tests/view/6432974d31feee5c6d306fc0
LLR: 1.76 (-2.94,2.94) <-1.75,0.25>
Total: 73200 W: 19792 L: 19728 D: 33680
Ptnml(0-2): 24, 6659, 23182, 6699, 36

closes https://github.com/official-stockfish/Stockfish/pull/4515

No functional change

src/evaluate.cpp
src/search.cpp
src/thread.cpp

index 703cf869cee1caa02bfa8b48369d2a16b4829c53..2d0df89c3e77f9d692e285cd5ec219b6619d6bf1 100644 (file)
@@ -1048,6 +1048,8 @@ make_v:
 
 Value Eval::evaluate(const Position& pos, int* complexity) {
 
+  assert(!pos.checkers());
+
   Value v;
   Value psq = pos.psq_eg_stm();
 
index fba9685b2e035deaef896e501841e450057eb51d..5d54a15d628070707d6f08db5b7e6483635b3d27 100644 (file)
@@ -295,10 +295,12 @@ void Thread::search() {
   if (mainThread)
   {
 
-      int rootComplexity;
-      Eval::evaluate(rootPos, &rootComplexity);
-
-      mainThread->complexity = std::min(1.03 + (rootComplexity - 241) / 1552.0, 1.45);
+      if (!rootPos.checkers())
+      {
+          int rootComplexity;
+          Eval::evaluate(rootPos, &rootComplexity);
+          mainThread->complexity = std::min(1.03 + (rootComplexity - 241) / 1552.0, 1.45);
+      }
 
       if (mainThread->bestPreviousScore == VALUE_INFINITE)
           for (int i = 0; i < 4; ++i)
index c680393e27752135aa95ea76943233bc539fb83e..202768c863cc9e1f6ca7d0f38de44fb9f1674a43 100644 (file)
@@ -160,6 +160,7 @@ void ThreadPool::clear() {
   main()->bestPreviousScore = VALUE_INFINITE;
   main()->bestPreviousAverageScore = VALUE_INFINITE;
   main()->previousTimeReduction = 1.0;
+  main()->complexity = 1.0;
 }