Skip to content

Commit

Permalink
Don't do standing pat when in check
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Jan 18, 2025
1 parent 4309715 commit 3663401
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,10 @@ public int QuiescenceSearch(int ply, int alpha, int beta, CancellationToken canc
Debug.Assert(staticEval != EvaluationConstants.NoHashEntry, "Assertion failed", "All TT entries should have a static eval");

Game.UpdateStaticEvalInStack(ply, staticEval);
bool isInCheck = position.IsInCheck();

// Beta-cutoff (updating alpha after this check)
if (staticEval >= beta)
// Standing pat beta-cutoff (updating alpha after this check)
if (!isInCheck && staticEval >= beta)
{
PrintMessage(ply - 1, "Pruning before starting quiescence search");
return staticEval;
Expand Down Expand Up @@ -682,7 +683,7 @@ public int QuiescenceSearch(int ply, int alpha, int beta, CancellationToken canc
{
Debug.Assert(bestMove is null);

var finalEval = Position.EvaluateFinalPosition(ply, position.IsInCheck());
var finalEval = Position.EvaluateFinalPosition(ply, isInCheck);
_tt.RecordHash(position, finalEval, 0, ply, finalEval, NodeType.Exact);

return finalEval;
Expand Down

0 comments on commit 3663401

Please sign in to comment.