From 632f1c21cd271e7c4c242fdafa328a55ec63b9cb Mon Sep 17 00:00:00 2001 From: "Robert Nurnberg @ elitebook" Date: Thu, 7 Mar 2024 22:01:40 +0100 Subject: [PATCH] Fix wrong constant usage in go mate Fixes an oversight in https://github.com/official-stockfish/Stockfish/pull/5094 In theory, master could stop search when run with `go mate 247` and return a TB loss (not a mate score). Also fixes the spelling of opponenWorsening. closes https://github.com/official-stockfish/Stockfish/pull/5096 No functional change --- src/search.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 335149d5..533cf61b 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -407,7 +407,7 @@ void Search::Worker::iterative_deepening() { && ((rootMoves[0].score >= VALUE_MATE_IN_MAX_PLY && VALUE_MATE - rootMoves[0].score <= 2 * limits.mate) || (rootMoves[0].score != -VALUE_INFINITE - && rootMoves[0].score <= VALUE_TB_LOSS_IN_MAX_PLY + && rootMoves[0].score <= VALUE_MATED_IN_MAX_PLY && VALUE_MATE + rootMoves[0].score <= 2 * limits.mate))) threads.stop = true; @@ -539,7 +539,7 @@ Value Search::Worker::search( Move ttMove, move, excludedMove, bestMove; Depth extension, newDepth; Value bestValue, value, ttValue, eval, maxValue, probCutBeta; - bool givesCheck, improving, priorCapture, opponenWorsening; + bool givesCheck, improving, priorCapture, opponentWorsening; bool capture, moveCountPruning, ttCapture; Piece movedPiece; int moveCount, captureCount, quietCount; @@ -748,7 +748,7 @@ Value Search::Worker::search( ? ss->staticEval > (ss - 2)->staticEval : (ss - 4)->staticEval != VALUE_NONE && ss->staticEval > (ss - 4)->staticEval; - opponenWorsening = ss->staticEval + (ss - 1)->staticEval > 2 && (depth != 2 || !improving); + opponentWorsening = ss->staticEval + (ss - 1)->staticEval > 2 && (depth != 2 || !improving); // Step 7. Razoring (~1 Elo) // If eval is really low check with qsearch if it can exceed alpha, if it can't, @@ -764,7 +764,7 @@ Value Search::Worker::search( // Step 8. Futility pruning: child node (~40 Elo) // The depth condition is important for mate finding. if (!ss->ttPv && depth < 11 - && eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponenWorsening) + && eval - futility_margin(depth, cutNode && !ss->ttHit, improving, opponentWorsening) - (ss - 1)->statScore / 314 >= beta && eval >= beta && eval < 30016 // smaller than TB wins @@ -1046,7 +1046,8 @@ moves_loop: // When in check, search starts here extension = 2 + (value < singularBeta - 78 && !ttCapture); depth += depth < 16; } - if (PvNode && !ttCapture && ss->multipleExtensions <= 5 && value < singularBeta - 50) + if (PvNode && !ttCapture && ss->multipleExtensions <= 5 + && value < singularBeta - 50) extension = 2; }