X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;fp=src%2Fsearch.cpp;h=27c2c84e9dd580d8bbc26622a09cabb2767ef5da;hp=10a36cbf26131b6ac449a92885b18579c6d27aaa;hb=d9ec82e7438716671168d78eee26fae327249e8c;hpb=c53d2ec253557d8a679197becb7ba9a6aa393ecc diff --git a/src/search.cpp b/src/search.cpp index 10a36cbf..27c2c84e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -1468,14 +1468,19 @@ Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) { ss->staticEval = bestValue = (ss - 1)->currentMove != MOVE_NULL ? evaluate(pos) : -(ss - 1)->staticEval; - // Stand pat. Return immediately if static value is at least beta + // Stand pat. Return immediately if bestValue is at least beta at non-Pv nodes. + // At PvNodes set bestValue between alpha and beta instead if (bestValue >= beta) { - if (!ss->ttHit) - tte->save(posKey, value_to_tt(bestValue, ss->ply), false, BOUND_LOWER, DEPTH_NONE, - MOVE_NONE, ss->staticEval); + if (!PvNode || abs(bestValue) >= VALUE_TB_WIN_IN_MAX_PLY) + { + if (!ss->ttHit) + tte->save(posKey, value_to_tt(bestValue, ss->ply), false, BOUND_LOWER, + DEPTH_NONE, MOVE_NONE, ss->staticEval); - return bestValue; + return bestValue; + } + bestValue = std::min((alpha + beta) / 2, beta - 1); } if (bestValue > alpha)