Skip to content

Commit

Permalink
Exclude Raphael from synth helper
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 28, 2024
1 parent 150c2c9 commit 819f23a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Craftimizer/Utils/DynamicBars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static void DrawProgressBarTooltip(Solver.Solver solver)
{
string tooltip;
if (solver.IsIndeterminate)
tooltip = "Initializing Solver";
tooltip = "Initializing";
else
{
tooltip = $"Solver Progress: {solver.ProgressValue:N0} / {solver.ProgressMax:N0}";
Expand Down
137 changes: 71 additions & 66 deletions Craftimizer/Windows/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static void DrawOption(string label, string tooltip, string value, Actio
ImGuiUtils.TooltipWrapped(tooltip);
}

private static void DrawOption<T>(string label, string tooltip, Func<T, string> getName, Func<T, string> getTooltip, T value, Action<T> setter, ref bool isDirty) where T : struct, Enum
private static void DrawOption<T>(string label, string tooltip, Func<T, string> getName, Func<T, string> getTooltip, T value, Action<T> setter, ref bool isDirty, params T[] excludedValues) where T : struct, Enum
{
ImGui.SetNextItemWidth(OptionWidth);
using (var combo = ImRaii.Combo(label, getName(value)))
Expand All @@ -127,6 +127,8 @@ private static void DrawOption<T>(string label, string tooltip, Func<T, string>
{
foreach (var type in Enum.GetValues<T>())
{
if (excludedValues.Contains(type))
continue;
if (ImGui.Selectable(getName(type), value.Equals(type)))
{
setter(type);
Expand Down Expand Up @@ -504,7 +506,7 @@ ref isDirty
Config.Save();
}

private static void DrawSolverConfig(ref SolverConfig configRef, SolverConfig defaultConfig, out bool isDirty)
private static void DrawSolverConfig(ref SolverConfig configRef, SolverConfig defaultConfig, bool disableOptimal, out bool isDirty)
{
isDirty = false;

Expand All @@ -522,13 +524,14 @@ private static void DrawSolverConfig(ref SolverConfig configRef, SolverConfig de
"Algorithm",
"The algorithm to use when solving for a macro. Different " +
"algorithms provide different pros and cons for using them. " +
"By far, the Stepwise Genetic algorithm provides the best " +
"results, especially for very difficult crafts.",
"By far, the Optimal and Stepwise Genetic algorithms provide " +
"the best results, especially for very difficult crafts.",
GetAlgorithmName,
GetAlgorithmTooltip,
config.Algorithm,
v => config = config with { Algorithm = v },
ref isDirty
ref isDirty,
disableOptimal ? [SolverAlgorithm.Raphael] : []
);

if (config.Algorithm != SolverAlgorithm.Raphael)
Expand Down Expand Up @@ -682,9 +685,9 @@ ref isDirty
}
}

using (var panel = ImRaii2.GroupPanel("Advanced", -1, out _))
if (config.Algorithm != SolverAlgorithm.Raphael)
{
if (config.Algorithm != SolverAlgorithm.Raphael)
using (var panel = ImRaii2.GroupPanel("Advanced", -1, out _))
{
DrawOption(
"Max Rollout Step Count",
Expand All @@ -708,70 +711,72 @@ ref isDirty
ref isDirty
);
}
else
}

// TODO: Provide better option name than this lol
//DrawOption(
// "Unsound Branch Pruning",
// "TBD",
// config.UnsoundBranchPruning,
// v => config = config with { UnsoundBranchPruning = v },
// ref isDirty
//);

if (config.Algorithm != SolverAlgorithm.Raphael)
{
using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _))
{
DrawOption(
"Unsound Branch Pruning",
"TBD",
config.UnsoundBranchPruning,
v => config = config with { UnsoundBranchPruning = v },
"Progress",
"Amount of weight to give to the craft's progress.",
config.ScoreProgress,
0,
100,
v => config = config with { ScoreProgress = v },
ref isDirty
);
}
}

using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _))
{
DrawOption(
"Progress",
"Amount of weight to give to the craft's progress.",
config.ScoreProgress,
0,
100,
v => config = config with { ScoreProgress = v },
ref isDirty
);

DrawOption(
"Quality",
"Amount of weight to give to the craft's quality.",
config.ScoreQuality,
0,
100,
v => config = config with { ScoreQuality = v },
ref isDirty
);
DrawOption(
"Quality",
"Amount of weight to give to the craft's quality.",
config.ScoreQuality,
0,
100,
v => config = config with { ScoreQuality = v },
ref isDirty
);

DrawOption(
"Durability",
"Amount of weight to give to the craft's remaining durability.",
config.ScoreDurability,
0,
100,
v => config = config with { ScoreDurability = v },
ref isDirty
);
DrawOption(
"Durability",
"Amount of weight to give to the craft's remaining durability.",
config.ScoreDurability,
0,
100,
v => config = config with { ScoreDurability = v },
ref isDirty
);

DrawOption(
"CP",
"Amount of weight to give to the craft's remaining CP.",
config.ScoreCP,
0,
100,
v => config = config with { ScoreCP = v },
ref isDirty
);
DrawOption(
"CP",
"Amount of weight to give to the craft's remaining CP.",
config.ScoreCP,
0,
100,
v => config = config with { ScoreCP = v },
ref isDirty
);

DrawOption(
"Steps",
"Amount of weight to give to the craft's number of steps. The lower " +
"the step count, the higher the score.",
config.ScoreSteps,
0,
100,
v => config = config with { ScoreSteps = v },
ref isDirty
);
DrawOption(
"Steps",
"Amount of weight to give to the craft's number of steps. The lower " +
"the step count, the higher the score.",
config.ScoreSteps,
0,
100,
v => config = config with { ScoreSteps = v },
ref isDirty
);
}
}

if (isDirty)
Expand Down Expand Up @@ -952,7 +957,7 @@ ref isDirty
ImGuiHelpers.ScaledDummy(5);

var solverConfig = Config.RecipeNoteSolverConfig;
DrawSolverConfig(ref solverConfig, SolverConfig.RecipeNoteDefault, out var isSolverDirty);
DrawSolverConfig(ref solverConfig, SolverConfig.RecipeNoteDefault, false, out var isSolverDirty);
if (isSolverDirty)
{
Config.RecipeNoteSolverConfig = solverConfig;
Expand All @@ -974,7 +979,7 @@ private void DrawTabMacroEditor()
var isDirty = false;

var solverConfig = Config.EditorSolverConfig;
DrawSolverConfig(ref solverConfig, SolverConfig.EditorDefault, out var isSolverDirty);
DrawSolverConfig(ref solverConfig, SolverConfig.EditorDefault, false, out var isSolverDirty);
if (isSolverDirty)
{
Config.EditorSolverConfig = solverConfig;
Expand Down Expand Up @@ -1059,7 +1064,7 @@ ref isDirty
ImGuiHelpers.ScaledDummy(5);

var solverConfig = Config.SynthHelperSolverConfig;
DrawSolverConfig(ref solverConfig, SolverConfig.SynthHelperDefault, out var isSolverDirty);
DrawSolverConfig(ref solverConfig, SolverConfig.SynthHelperDefault, true, out var isSolverDirty);
if (isSolverDirty)
{
Config.SynthHelperSolverConfig = solverConfig;
Expand Down

0 comments on commit 819f23a

Please sign in to comment.