diff --git a/src/search.c b/src/search.c index 57aebc22..b4bbfe10 100644 --- a/src/search.c +++ b/src/search.c @@ -147,8 +147,9 @@ static int Quiescence(Thread *thread, Stack *ss, int alpha, int beta) { eval = CorrectEval(thread, ss, eval, pos->rule50); // Use ttScore as eval if it is more informative - if (abs(ttScore) < TBWIN_IN_MAX && TTScoreIsMoreInformative(ttBound, ttScore, eval)) - eval = ttScore; + int nonTerminalScore = CLAMP(eval, -TBWIN_IN_MAX + 1, TBWIN_IN_MAX - 1); + if (TTScoreIsMoreInformative(ttBound, nonTerminalScore, eval)) + eval = nonTerminalScore; // If eval beats beta we assume some move will also beat it if (eval >= beta) @@ -337,8 +338,9 @@ static int AlphaBeta(Thread *thread, Stack *ss, int alpha, int beta, Depth depth ss->staticEval = eval = CorrectEval(thread, ss, eval, pos->rule50); // Use ttScore as eval if it is more informative - if (abs(ttScore) < TBWIN_IN_MAX && TTScoreIsMoreInformative(ttBound, ttScore, eval)) - eval = ttScore; + int nonTerminalScore = CLAMP(eval, -TBWIN_IN_MAX + 1, TBWIN_IN_MAX - 1); + if (TTScoreIsMoreInformative(ttBound, nonTerminalScore, eval)) + eval = nonTerminalScore; // Improving if not in check, and current eval is higher than 2 plies ago bool improving = !inCheck && eval > (ss-2)->staticEval;