Skip to content

Commit

Permalink
🐛 Add support for negative wtime and btime (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio authored Dec 31, 2023
1 parent 1b0da54 commit 12ece97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Lynx/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<SearchResult> BestMove(GoCommand goCommand)
millisecondsIncrement = goCommand.BlackIncrement;
}

if (millisecondsLeft > 0)
if (millisecondsLeft != 0) // Cutechess sometimes sends negative wtime/btime
{
if (goCommand.MovesToGo == default)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Lynx/UCI/Commands/GUI/GoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public sealed partial class GoCommand : GUIBaseCommand
{
public const string Id = "go";

[GeneratedRegex(@"(?<wtime>(?<=wtime\s+)\d+)|(?<btime>(?<=btime\s+)\d+)|(?<winc>(?<=winc\s+)\d+)|(?<binc>(?<=binc\s+)\d+)|(?<movestogo>(?<=movestogo\s+)\d+)|(?<depth>(?<=depth\s+)\d+)|(?<movetime>(?<=movetime\s+)\d+)|(?<infinite>infinite)|(?<ponder>ponder)")]
/// <summary>
/// Note that wtime and btime need to support negative numbers because of cutechess
/// </summary>
/// <returns></returns>
[GeneratedRegex(@"(?<wtime>(?<=wtime\s+)-?\d+)|(?<btime>(?<=btime\s+)-?\d+)|(?<winc>(?<=winc\s+)\d+)|(?<binc>(?<=binc\s+)\d+)|(?<movestogo>(?<=movestogo\s+)\d+)|(?<depth>(?<=depth\s+)\d+)|(?<movetime>(?<=movetime\s+)\d+)|(?<infinite>infinite)|(?<ponder>ponder)")]
private static partial Regex Regex();

public int WhiteTime { get; }
Expand Down

0 comments on commit 12ece97

Please sign in to comment.