From: Guenther Demetz Date: Tue, 6 Dec 2022 18:09:33 +0000 (+0100) Subject: Correctly output lowerbound/upperbound scores X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=cb0c7a98485fbef4e5d6ed5f5b08201113ce0b4e;p=stockfish Correctly output lowerbound/upperbound scores 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 --- diff --git a/src/search.cpp b/src/search.cpp index 343c098a..04f73e1c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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; diff --git a/src/search.h b/src/search.h index 60f2762a..b620202d 100644 --- a/src/search.h +++ b/src/search.h @@ -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;