Skip to content

Commit

Permalink
Adjust depth for aspiration window fails (liamt19#47)
Browse files Browse the repository at this point in the history
bench: 5357760
  • Loading branch information
liamt19 authored Jun 23, 2024
1 parent db99487 commit 1c9aa1e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Logic/Threads/SearchThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ public void Search()
rm.PreviousScore = rm.Score;
}

int usedDepth = RootDepth;

for (PVIndex = 0; PVIndex < multiPV; PVIndex++)
{
if (SearchPool.StopThreads)
Expand All @@ -388,7 +390,7 @@ public void Search()
int score = RootMoves[PVIndex].AverageScore;
SelDepth = 0;

if (RootDepth >= 5)
if (usedDepth >= 5)
{
window = AspirationWindowMargin;
alpha = Math.Max(AlphaStart, score - window);
Expand All @@ -397,7 +399,7 @@ public void Search()

while (true)
{
score = Logic.Search.Searches.Negamax<RootNode>(info.Position, ss, alpha, beta, Math.Max(1, RootDepth), false);
score = Logic.Search.Searches.Negamax<RootNode>(info.Position, ss, alpha, beta, Math.Max(1, usedDepth), false);

StableSort(ref RootMoves, PVIndex);

Expand All @@ -408,10 +410,12 @@ public void Search()
{
beta = (alpha + beta) / 2;
alpha = Math.Max(alpha - window, AlphaStart);
usedDepth = RootDepth;
}
else if (score >= beta)
{
beta = Math.Min(beta + window, BetaStart);
usedDepth = Math.Max(usedDepth - 1, RootDepth - 5);
}
else
break;
Expand Down Expand Up @@ -445,7 +449,7 @@ public void Search()
return;
}


if (lastBestRootMove.Move == RootMoves[0].Move)
{
stability++;
Expand Down

0 comments on commit 1c9aa1e

Please sign in to comment.