]> git.sesse.net Git - stockfish/commitdiff
Correctly output lowerbound/upperbound scores
authorGuenther Demetz <guenther.demetz@wuerth-phoenix.com>
Tue, 6 Dec 2022 18:09:33 +0000 (19:09 +0100)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Thu, 8 Dec 2022 19:43:21 +0000 (20:43 +0100)
fixes the lowerbound/upperbound output by avoiding
scores outside the alpha,beta bracket. Since SF search
uses fail-soft we can't simply take the returned value
as score.

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

No functional change

src/search.cpp
src/search.h

index 343c098a587dbb6cf3d8b8eb6aae946d178d733b..04f73e1c0a28da06dd764352656a6725386524d3 100644 (file)
@@ -1245,10 +1245,16 @@ moves_loop: // When in check, search starts here
           // PV move or new best move?
           if (moveCount == 1 || value > alpha)
           {
-              rm.score = value;
+              rm.score =  rm.uciScore = value;
               rm.selDepth = thisThread->selDepth;
-              rm.scoreLowerbound = value >= beta;
-              rm.scoreUpperbound = value <= alpha;
+              if (value >= beta) {
+                 rm.scoreLowerbound = true;
+                 rm.uciScore = beta;
+              }
+              else if (value <= alpha) {
+                 rm.scoreUpperbound = true;
+                 rm.uciScore = alpha;
+              }
               rm.pv.resize(1);
 
               assert((ss+1)->pv);
@@ -1841,7 +1847,7 @@ string UCI::pv(const Position& pos, Depth depth) {
           continue;
 
       Depth d = updated ? depth : std::max(1, depth - 1);
-      Value v = updated ? rootMoves[i].score : rootMoves[i].previousScore;
+      Value v = updated ? rootMoves[i].uciScore : rootMoves[i].previousScore;
 
       if (v == -VALUE_INFINITE)
           v = VALUE_ZERO;
index 60f2762a6f499044c17764910e6fd41bbf2aadd5..b620202d9178836f24619192409242b67166f564 100644 (file)
@@ -71,6 +71,7 @@ struct RootMove {
   Value score = -VALUE_INFINITE;
   Value previousScore = -VALUE_INFINITE;
   Value averageScore = -VALUE_INFINITE;
+  Value uciScore = -VALUE_INFINITE;
   bool scoreLowerbound = false;
   bool scoreUpperbound = false;
   int selDepth = 0;