From 5ab53f56b940a64837689c169d8844c99b6cb08f Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Fri, 14 Jul 2023 23:45:34 +0400 Subject: [PATCH] Expand macros generated by solver --- Benchmark/Program.cs | 48 ++++++++++--------- Craftimizer/Windows/SimulatorWindowActions.cs | 16 +++++-- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Benchmark/Program.cs b/Benchmark/Program.cs index da6ca6a..7f5adb8 100644 --- a/Benchmark/Program.cs +++ b/Benchmark/Program.cs @@ -54,20 +54,26 @@ internal static class Program var sim = new SimulatorNoRandom(new(input)); (_, var state) = sim.Execute(new(input), ActionType.MuscleMemory); (_, state) = sim.Execute(state, ActionType.PrudentTouch); - (_, state) = sim.Execute(state, ActionType.Manipulation); - (_, state) = sim.Execute(state, ActionType.Veneration); - (_, state) = sim.Execute(state, ActionType.WasteNot); - (_, state) = sim.Execute(state, ActionType.Groundwork); - (_, state) = sim.Execute(state, ActionType.Groundwork); - (_, state) = sim.Execute(state, ActionType.Groundwork); - (_, state) = sim.Execute(state, ActionType.Innovation); - (_, state) = sim.Execute(state, ActionType.PrudentTouch); - (_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo); - (_, state) = sim.Execute(state, ActionType.Manipulation); - (_, state) = sim.Execute(state, ActionType.Innovation); - (_, state) = sim.Execute(state, ActionType.PrudentTouch); - (_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo); - (_, state) = sim.Execute(state, ActionType.GreatStrides); + //(_, state) = sim.Execute(state, ActionType.Manipulation); + //(_, state) = sim.Execute(state, ActionType.Veneration); + //(_, state) = sim.Execute(state, ActionType.WasteNot); + //(_, state) = sim.Execute(state, ActionType.Groundwork); + //(_, state) = sim.Execute(state, ActionType.Groundwork); + //(_, state) = sim.Execute(state, ActionType.Groundwork); + //(_, state) = sim.Execute(state, ActionType.Innovation); + //(_, state) = sim.Execute(state, ActionType.PrudentTouch); + //(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo); + //(_, state) = sim.Execute(state, ActionType.Manipulation); + //(_, state) = sim.Execute(state, ActionType.Innovation); + //(_, state) = sim.Execute(state, ActionType.PrudentTouch); + //(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo); + //(_, state) = sim.Execute(state, ActionType.GreatStrides); + //(_, state) = sim.Execute(state, ActionType.Innovation); + //(_, state) = sim.Execute(state, ActionType.FocusedTouchCombo); + //(_, state) = sim.Execute(state, ActionType.GreatStrides); + //(_, state) = sim.Execute(state, ActionType.ByregotsBlessing); + //(_, state) = sim.Execute(state, ActionType.CarefulSynthesis); + //(_, state) = sim.Execute(state, ActionType.CarefulSynthesis); Console.WriteLine($"{state.Quality} {state.CP} {state.Progress} {state.Durability}"); //return; @@ -75,21 +81,17 @@ internal static class Program Console.WriteLine($"Qual: {s.Quality}/{s.Input.Recipe.MaxQuality}"); return; - for (var i = 0; i < 7; ++i) - { - Console.WriteLine($"{i + 1}"); - var c = config with { FurcatedActionCount = i + 1 }; - Benchmark(() => Solver.Crafty.Solver.SearchStepwiseFurcated(c, input).State); - } + Solver.Crafty.Solver.SearchStepwiseFurcated(config, input); + //Benchmark(() => ); } - private static void Benchmark(Func search) + private static void Benchmark(Func search) { var s = Stopwatch.StartNew(); List q = new(); - for (var i = 0; i < 60; ++i) + for (var i = 0; i < 15; ++i) { - var state = search(); + var state = search().State; //Console.WriteLine($"Qual: {state.Quality}/{state.Input.Recipe.MaxQuality}"); q.Add(state.Quality); diff --git a/Craftimizer/Windows/SimulatorWindowActions.cs b/Craftimizer/Windows/SimulatorWindowActions.cs index 6370274..6a02f62 100644 --- a/Craftimizer/Windows/SimulatorWindowActions.cs +++ b/Craftimizer/Windows/SimulatorWindowActions.cs @@ -1,3 +1,4 @@ +using Craftimizer.Simulator; using Craftimizer.Simulator.Actions; using Dalamud.Interface.Windowing; using System; @@ -15,9 +16,18 @@ public sealed partial class SimulatorWindow : Window, IDisposable private void AppendGeneratedAction(ActionType action) { - var tooltip = action.Base().GetTooltip(Simulator, false); - var (response, state) = Simulator.Execute(LatestState, action); - Actions.Add((action, tooltip, response, state)); + var actionBase = action.Base(); + if (actionBase is BaseComboAction comboActionBase) + { + AppendGeneratedAction(comboActionBase.ActionTypeA); + AppendGeneratedAction(comboActionBase.ActionTypeB); + } + else + { + var tooltip = actionBase.GetTooltip(Simulator, false); + var (response, state) = Simulator.Execute(LatestState, action); + Actions.Add((action, tooltip, response, state)); + } } private void RemoveAction(int actionIndex)