diff --git a/src/Lynx/Search/NegaMax.cs b/src/Lynx/Search/NegaMax.cs index dc94d51d0..3f4679ac9 100644 --- a/src/Lynx/Search/NegaMax.cs +++ b/src/Lynx/Search/NegaMax.cs @@ -564,17 +564,24 @@ public int QuiescenceSearch(int ply, int alpha, int beta, CancellationToken canc Game.UpdateStaticEvalInStack(ply, staticEval); + int eval = + (ttNodeType == NodeType.Exact + || (ttNodeType == NodeType.Alpha && ttScore < staticEval) + || (ttNodeType == NodeType.Beta && ttScore > staticEval)) + ? ttScore + : staticEval; + // Beta-cutoff (updating alpha after this check) - if (staticEval >= beta) + if (eval >= beta) { PrintMessage(ply - 1, "Pruning before starting quiescence search"); - return staticEval; + return eval; } // Better move - if (staticEval > alpha) + if (eval > alpha) { - alpha = staticEval; + alpha = eval; } Span moves = stackalloc Move[Constants.MaxNumberOfPossibleMovesInAPosition]; @@ -587,7 +594,7 @@ public int QuiescenceSearch(int ply, int alpha, int beta, CancellationToken canc var nodeType = NodeType.Alpha; Move? bestMove = null; - int bestScore = staticEval; + int bestScore = eval; bool isAnyCaptureValid = false;