Skip to content

Commit

Permalink
🔍 Extend on TT hit at low depths when TT cutoff doesn't happen but TT…
Browse files Browse the repository at this point in the history
… depth > depth (#1342)
  • Loading branch information
eduherminio authored Jan 9, 2025
1 parent d43a726 commit f3b7787
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ public int Threads
[SPSA<int>(-8192, 0, 512)]
public int HistoryPrunning_Margin { get; set; } = -1940;

[SPSA<int>(0, 10, 0.5)]
public int TTHit_NoCutoffExtension_MaxDepth { get; set; } = 6;

#endregion
}

Expand Down
17 changes: 12 additions & 5 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,19 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool cutnode, Cance
// TT cutoffs
if (!pvNode
&& ttScore != EvaluationConstants.NoHashEntry
&& ttDepth >= depth
&& (ttElementType == NodeType.Exact
|| (ttElementType == NodeType.Alpha && ttScore <= alpha)
|| (ttElementType == NodeType.Beta && ttScore >= beta)))
&& ttDepth >= depth)
{
return ttScore;
if (ttElementType == NodeType.Exact
|| (ttElementType == NodeType.Alpha && ttScore <= alpha)
|| (ttElementType == NodeType.Beta && ttScore >= beta))
{
return ttScore;
}
else if (depth <= Configuration.EngineSettings.TTHit_NoCutoffExtension_MaxDepth)
{
// Extension idea from Stormphrax
++depth;
}
}

// Internal iterative reduction (IIR)
Expand Down
8 changes: 8 additions & 0 deletions src/Lynx/UCIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ private void HandleSetOption(ReadOnlySpan<char> command)
}
break;
}
case "tthit_nocutoffextension_maxdepth":
{
if (length > 4 && int.TryParse(command[commandItems[4]], out var value))
{
Configuration.EngineSettings.TTHit_NoCutoffExtension_MaxDepth = value;
}
break;
}

#endregion

Expand Down

0 comments on commit f3b7787

Please sign in to comment.