diff --git a/src/search.cpp b/src/search.cpp index ff6bf335d06..f5705bdfa7f 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -552,7 +552,7 @@ namespace { Key posKey; Move ttMove, move, excludedMove, bestMove; Depth extension, newDepth; - Value bestValue, value, ttValue, eval, maxValue, probCutBeta; + Value bestValue, value, ttValue, eval, maxValue, probCutBeta, initialAlpha; bool givesCheck, improving, didLMR, priorCapture; bool capture, doFullDepthSearch, moveCountPruning, ttCapture; Piece movedPiece; @@ -567,6 +567,7 @@ namespace { moveCount = captureCount = quietCount = ss->moveCount = 0; bestValue = -VALUE_INFINITE; maxValue = VALUE_INFINITE; + initialAlpha = alpha; // Check for the available remaining time if (thisThread == Threads.main()) @@ -1296,7 +1297,12 @@ namespace { update_pv(ss->pv, move, (ss+1)->pv); if (PvNode && value < beta) // Update alpha! Always alpha < beta - alpha = value; + { + if (beta < VALUE_INFINITE && initialAlpha > -VALUE_INFINITE) + alpha = std::max(value, (beta - 1 + initialAlpha) / 2); + else + alpha = value; + } else { assert(value >= beta); // Fail high