Skip to content

Commit

Permalink
Reuse TT score instead of TT static eval in QSearch when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Jan 1, 2025
1 parent c5469fb commit 1889876
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Move> moves = stackalloc Move[Constants.MaxNumberOfPossibleMovesInAPosition];
Expand All @@ -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;

Expand Down

0 comments on commit 1889876

Please sign in to comment.