diff --git a/AUTHORS b/AUTHORS index 8e4241384..fe573fe50 100644 --- a/AUTHORS +++ b/AUTHORS @@ -180,6 +180,7 @@ Michel Van den Bergh (vdbergh) Miguel Lahoz (miguel-l) Mikael Bäckman (mbootsector) Mike Babigian (Farseer) +Miloslav Macůrek (maelic13) Mira Miroslav Fontán (Hexik) Moez Jellouli (MJZ1977) diff --git a/src/search.cpp b/src/search.cpp index d6ec50aba..bc922119c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -2005,9 +2005,16 @@ void update_quiet_histories( Move Skill::pick_best(const RootMoves& rootMoves, usize multiPV) { static PRNG rng(now()); // PRNG sequence should be non-deterministic - // RootMoves are already sorted by score in descending order - Value topScore = rootMoves[0].score; - int delta = std::min(topScore - rootMoves[multiPV - 1].score, int(PawnValue)); + // With tablebases at the root, rootMoves are ordered by tbRank rather than by + // score, so compute the score range explicitly to keep 'delta' non-negative. + Value topScore = rootMoves[0].score; + Value minScore = rootMoves[0].score; + for (usize i = 1; i < multiPV; ++i) + { + topScore = std::max(topScore, rootMoves[i].score); + minScore = std::min(minScore, rootMoves[i].score); + } + int delta = std::min(topScore - minScore, int(PawnValue)); int maxScore = -VALUE_INFINITE; double weakness = 120 - 2 * level;