Update solver

This commit is contained in:
Asriel Camora
2025-08-18 23:56:40 -07:00
parent b9da027283
commit d10332fb9d
5 changed files with 24 additions and 62 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Raphael.Net" Version="2.1.1" />
<PackageReference Include="Raphael.Net" Version="3.0.0" />
</ItemGroup>
<ItemGroup>
+16 -46
View File
@@ -205,56 +205,26 @@ public sealed class Solver : IDisposable
void Log(string s) =>
OnLog?.Invoke(s);
if (!Config.MinimizeSteps)
Raphael.SolverConfig config = new()
{
Raphael.SolverConfig config = new()
{
Adversarial = Config.Adversarial,
BackloadProgress = true,
UnsoundBranchPruning = true,
LogLevel = Raphael.LevelFilter.Debug,
ThreadCount = (ushort)Config.MaxThreadCount,
};
Adversarial = Config.Adversarial,
BackloadProgress = Config.BackloadProgress,
LogLevel = Raphael.LevelFilter.Debug,
ThreadCount = (ushort)Config.MaxThreadCount,
};
using var solver = new Raphael.Solver(in config, in input, pool);
using var solver = new Raphael.Solver(in config, in input, pool);
solver.OnFinish += OnFinish;
solver.OnSuggestSolution += OnSuggestSolution;
solver.OnProgress += OnProgress;
solver.OnLog += Log;
solver.OnFinish += OnFinish;
solver.OnSuggestSolution += OnSuggestSolution;
solver.OnProgress += OnProgress;
solver.OnLog += Log;
progressStage = 0;
progress = 0;
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
Token.ThrowIfCancellationRequested();
}
var state = solution != null ? (SimulationState?)ExecuteActions(solution) : null;
if (solution == null || state?.Quality != state?.Input.Recipe.MaxQuality)
{
Raphael.SolverConfig config = new()
{
Adversarial = Config.Adversarial,
BackloadProgress = Config.BackloadProgress,
UnsoundBranchPruning = false,
LogLevel = Raphael.LevelFilter.Debug,
ThreadCount = (ushort)Config.MaxThreadCount,
};
using var solver = new Raphael.Solver(in config, in input, pool);
solver.OnFinish += OnFinish;
solver.OnSuggestSolution += OnSuggestSolution;
solver.OnProgress += OnProgress;
solver.OnLog += Log;
progressStage = 0;
progress = 0;
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
Token.ThrowIfCancellationRequested();
}
progressStage = 0;
progress = 0;
await using var registration = Token.Register(solver.Cancel).ConfigureAwait(true);
await Task.Run(solver.Solve, Token).ConfigureAwait(true);
Token.ThrowIfCancellationRequested();
if (solution == null)
return new([], State);
-1
View File
@@ -38,7 +38,6 @@ public readonly record struct SolverConfig
// Raphael/A* configuration
public bool Adversarial { get; init; }
public bool BackloadProgress { get; init; }
public bool MinimizeSteps { get; init; }
public int MaxThreadCount { get; init; }
public ActionType[] ActionPool { get; init; }