Skip to content

Commit

Permalink
Add !isInCheck condition
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Nov 16, 2023
1 parent 916881b commit c0e8263
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
NodeType ttElementType = default;
int ttEvaluation = default;

bool isInCheck = position.IsInCheck();

if (!isRoot)
{
(ttEvaluation, ttBestMove, ttElementType) = _tt.ProbeHash(_ttMask, position, depth, ply, alpha, beta);
Expand All @@ -50,12 +52,14 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
return ttEvaluation;
}

// Internal iterative reduction (IIR)
// Internal Iterative Reduction (IIR)
// If this position isn't found in TT, it has never been searched before,
// so the search will be potentially expensive.
// Therefore, we search with reduced depth for now, expecting to record a TT move
// which we'll be able to use later for the full depth search
if (ttElementType == default && depth >= Configuration.EngineSettings.IIR_MinDepth)
if (ttElementType == default
&& depth >= Configuration.EngineSettings.IIR_MinDepth
&& !isInCheck)
{
--depth;
}
Expand All @@ -64,8 +68,6 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool parentWasNullM
// Before any time-consuming operations
_searchCancellationTokenSource.Token.ThrowIfCancellationRequested();

bool isInCheck = position.IsInCheck();

if (isInCheck)
{
++depth;
Expand Down

0 comments on commit c0e8263

Please sign in to comment.