Skip to content

Commit

Permalink
Remove the checkmated eval when in check idea
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Jan 18, 2025
1 parent 09f401a commit 973fbd7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,31 +571,31 @@ public int QuiescenceSearch(int ply, int alpha, int beta, CancellationToken canc

Game.UpdateStaticEvalInStack(ply, staticEval);

int eval = -EvaluationConstants.CheckMateBaseEvaluation + ply;
int eval = staticEval;

var isInCheck = position.IsInCheck();

if (!isInCheck)
{
eval =
(ttNodeType == NodeType.Exact
|| (ttNodeType == NodeType.Alpha && ttScore < staticEval)
|| (ttNodeType == NodeType.Beta && ttScore > staticEval))
? ttScore
: staticEval;
if (ttNodeType == NodeType.Exact
|| (ttNodeType == NodeType.Alpha && ttScore < staticEval)
|| (ttNodeType == NodeType.Beta && ttScore > staticEval))
{
eval = ttScore;
}

// Standing pat beta-cutoff (updating alpha after this check)
if (eval >= beta)
{
PrintMessage(ply - 1, "Pruning before starting quiescence search");
return eval;
}
}

// Better move
if (eval > alpha)
{
alpha = eval;
}
// Better move
if (eval > alpha)
{
alpha = eval;
}

Span<Move> moves = stackalloc Move[Constants.MaxNumberOfPossibleMovesInAPosition];
Expand Down

0 comments on commit 973fbd7

Please sign in to comment.