From 819f23a6d9016b6e6327a27443957903ffdddce0 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Thu, 28 Nov 2024 02:46:19 -0800 Subject: [PATCH] Exclude Raphael from synth helper --- Craftimizer/Utils/DynamicBars.cs | 2 +- Craftimizer/Windows/Settings.cs | 137 ++++++++++++++++--------------- 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/Craftimizer/Utils/DynamicBars.cs b/Craftimizer/Utils/DynamicBars.cs index a77e4fe..493e21f 100644 --- a/Craftimizer/Utils/DynamicBars.cs +++ b/Craftimizer/Utils/DynamicBars.cs @@ -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}"; diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index c674aee..7058caf 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -118,7 +118,7 @@ private static void DrawOption(string label, string tooltip, string value, Actio ImGuiUtils.TooltipWrapped(tooltip); } - private static void DrawOption(string label, string tooltip, Func getName, Func getTooltip, T value, Action setter, ref bool isDirty) where T : struct, Enum + private static void DrawOption(string label, string tooltip, Func getName, Func getTooltip, T value, Action setter, ref bool isDirty, params T[] excludedValues) where T : struct, Enum { ImGui.SetNextItemWidth(OptionWidth); using (var combo = ImRaii.Combo(label, getName(value))) @@ -127,6 +127,8 @@ private static void DrawOption(string label, string tooltip, Func { foreach (var type in Enum.GetValues()) { + if (excludedValues.Contains(type)) + continue; if (ImGui.Selectable(getName(type), value.Equals(type))) { setter(type); @@ -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; @@ -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) @@ -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", @@ -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) @@ -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; @@ -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; @@ -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;