Moved algorithm into SolverConfig, multi configuration support

This commit is contained in:
Asriel Camora
2023-07-23 02:27:08 +04:00
parent bac96201d2
commit c344815e50
5 changed files with 51 additions and 25 deletions
+28 -2
View File
@@ -2,6 +2,15 @@ using System.Runtime.InteropServices;
namespace Craftimizer.Solver.Crafty;
public enum SolverAlgorithm
{
Oneshot,
OneshotForked,
Stepwise,
StepwiseForked,
StepwiseFurcated,
}
[StructLayout(LayoutKind.Auto)]
public readonly record struct SolverConfig
{
@@ -21,14 +30,16 @@ public readonly record struct SolverConfig
public float ScoreCPBonus { get; init; }
public float ScoreFewerStepsBonus { get; init; }
public SolverAlgorithm Algorithm { get; init; }
public SolverConfig()
{
Iterations = 100000;
ScoreStorageThreshold = 1f;
MaxScoreWeightingConstant = 0.1f;
ExplorationConstant = 4;
MaxStepCount = 25;
MaxRolloutStepCount = MaxStepCount;
MaxStepCount = 30;
MaxRolloutStepCount = 99;
ForkCount = Math.Max(Environment.ProcessorCount, 32);
FurcatedActionCount = ForkCount / 2;
StrictActions = true;
@@ -38,5 +49,20 @@ public readonly record struct SolverConfig
ScoreDurabilityBonus = .05f;
ScoreCPBonus = .05f;
ScoreFewerStepsBonus = .05f;
Algorithm = SolverAlgorithm.StepwiseFurcated;
}
public static readonly SolverConfig SimulatorDefault = new SolverConfig() with
{
};
public static readonly SolverConfig SynthHelperDefault = new SolverConfig() with
{
Iterations = 300000,
ForkCount = Environment.ProcessorCount - 1, // Keep one for the game thread
FurcatedActionCount = Environment.ProcessorCount / 2,
Algorithm = SolverAlgorithm.StepwiseForked
};
}