Skip to content

Fix issue 42 where uci options can't be changed after engine initialization #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Ceres.Features/UCI/UCIManager.SetOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void ProcessSetOption(string command)
float moveOverheadMilliseconds = 0;
SetFloat(value, 0, int.MaxValue, ref moveOverheadMilliseconds);
moveOverheadSeconds = moveOverheadMilliseconds / 1000f;
if (CeresEngine is not null)
CeresEngine.SearchParams.MoveOverheadSeconds = moveOverheadSeconds;
break;

case "smartpruningfactor":
Expand All @@ -192,6 +194,8 @@ void ProcessSetOption(string command)
futilityPruningDisabled = false;
else
OutStream.Write($"Ceres does not support {factor}, only value 0 (indicating turned off) or 1.33 (indicating default) for SmartPruningFactor");
if (CeresEngine is not null)
CeresEngine.SearchParams.FutilityPruningStopSearchEnabled = !futilityPruningDisabled;
break;

case "verbosemovestats":
Expand Down Expand Up @@ -236,39 +240,39 @@ void ProcessSetOption(string command)


case "cpuct":
SetFloat(value, 0, float.MaxValue, ref cpuct);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCT : ref cpuct));
break;

case "cpuctbase":
SetFloat(value, 1, float.MaxValue, ref cpuctBase);
SetFloat(value, 1, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCTBase : ref cpuctBase));
break;

case "cpuctfactor":
SetFloat(value, 0, float.MaxValue, ref cpuctFactor);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCTFactor : ref cpuctFactor));
break;

case "cpuctatroot":
SetFloat(value, 0, float.MaxValue, ref cpuctAtRoot);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCTAtRoot : ref cpuctAtRoot));
break;

case "cpuctbaseatroot":
SetFloat(value, 1, float.MaxValue, ref cpuctBaseAtRoot);
SetFloat(value, 1, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCTBaseAtRoot : ref cpuctBaseAtRoot));
break;

case "cpuctfactoratroot":
SetFloat(value, 0, float.MaxValue, ref cpuctFactorAtRoot);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.CPUCTFactorAtRoot : ref cpuctFactorAtRoot));
break;

case "policytemperature":
SetFloat(value, 0.1f, float.MaxValue, ref policySoftmax);
SetFloat(value, 0.1f, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.PolicySoftmax : ref policySoftmax));
break;

case "fpu":
SetFloat(value, 0, float.MaxValue, ref fpu);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.FPUValue : ref fpu));
break;

case "fpuatroot":
SetFloat(value, 0, float.MaxValue, ref fpuAtRoot);
SetFloat(value, 0, float.MaxValue, ref (CeresEngine is not null ? ref CeresEngine.ChildSelectParams.FPUValueAtRoot : ref fpuAtRoot));
break;
}
}
Expand Down