Skip to content

Commit

Permalink
πŸ› Fix staticeval handling
Browse files Browse the repository at this point in the history
Add delay every 100 fens so that the buffer doesn't get full and evals are lost
  • Loading branch information
eduherminio committed Jun 19, 2024
1 parent 392225d commit 649deda
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Lynx/UCIHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ private async ValueTask HandleStaticEval(string rawCommand, CancellationToken ca
return;
}

int lineCounter = 0;
foreach (var line in await File.ReadAllLinesAsync(fullPath, cancellationToken))
{
var fen = line[..line.IndexOfAny([';', '[', '"'])];
Expand All @@ -584,6 +585,13 @@ private async ValueTask HandleStaticEval(string rawCommand, CancellationToken ca
}

await _engineToUci.Writer.WriteAsync($"{line}: {eval}", cancellationToken);

#pragma warning disable S2583 // Conditionally executed code should be reachable
if (++lineCounter % 100 == 0)
{
Thread.Sleep(50);
}
#pragma warning restore S2583 // Conditionally executed code should be reachable
}
}
catch (Exception e)
Expand Down

0 comments on commit 649deda

Please sign in to comment.