Allow selecting algorithm and hiding combos
This commit is contained in:
@@ -15,6 +15,15 @@ public class Macro
|
||||
public List<ActionType> Actions { get; set; } = new();
|
||||
}
|
||||
|
||||
public enum SolverAlgorithm
|
||||
{
|
||||
Oneshot,
|
||||
OneshotForked,
|
||||
Stepwise,
|
||||
StepwiseForked,
|
||||
StepwiseFurcated,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Configuration : IPluginConfiguration
|
||||
{
|
||||
@@ -22,8 +31,10 @@ public class Configuration : IPluginConfiguration
|
||||
|
||||
public bool OverrideUncraftability { get; set; } = true;
|
||||
public bool HideUnlearnedActions { get; set; } = true;
|
||||
public bool HideCombos { get; set; } = true;
|
||||
public List<Macro> Macros { get; set; } = new();
|
||||
public SolverConfig SolverConfig { get; set; } = new();
|
||||
public SolverAlgorithm SolverAlgorithm { get; set; } = SolverAlgorithm.StepwiseFurcated;
|
||||
public bool ConditionRandomness { get; set; } = true;
|
||||
|
||||
public Simulator.Simulator CreateSimulator(SimulationState state) =>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using System;
|
||||
@@ -59,7 +58,7 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
||||
|
||||
private void ResetSimulator()
|
||||
{
|
||||
Simulator = Service.Configuration.CreateSimulator(LatestState);
|
||||
Simulator = Configuration.CreateSimulator(LatestState);
|
||||
ReexecuteAllActions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
||||
static SimulatorWindow()
|
||||
{
|
||||
SortedActions = Enum.GetValues<ActionType>()
|
||||
.Where(a => a.Category() != ActionCategory.Combo)
|
||||
.GroupBy(a => a.Category())
|
||||
.Select(g => (g.Key, g.OrderBy(a => a.Level()).ToArray()))
|
||||
.ToArray();
|
||||
@@ -80,6 +79,9 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
||||
|
||||
foreach (var (category, actions) in SortedActions)
|
||||
{
|
||||
if (category == ActionCategory.Combo && Configuration.HideCombos)
|
||||
continue;
|
||||
|
||||
var i = 0;
|
||||
ImGuiUtils.BeginGroupPanel(category.GetDisplayName(), ActionColumnSize);
|
||||
foreach (var action in actions)
|
||||
@@ -87,7 +89,7 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
||||
var baseAction = action.Base();
|
||||
|
||||
var cannotUse = action.Level() > Input.Stats.Level || (action == ActionType.Manipulation && !Input.Stats.CanUseManipulation);
|
||||
if (cannotUse && Service.Configuration.HideUnlearnedActions)
|
||||
if (cannotUse && Configuration.HideUnlearnedActions)
|
||||
continue;
|
||||
|
||||
var shouldNotUse = !baseAction.CanUse(Simulator) || Simulator.IsComplete;
|
||||
|
||||
@@ -4,6 +4,7 @@ using Craftimizer.Solver.Crafty;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -72,7 +73,15 @@ public sealed partial class SimulatorWindow : Window, IDisposable
|
||||
|
||||
SolverInitialActionCount = Actions.Count;
|
||||
SolverTaskToken = new();
|
||||
SolverTask = Task.Run(() => SolverUtils.SearchStepwise<SolverConcurrent>(Service.Configuration.SolverConfig, solverState, SolverActionQueue.Enqueue, SolverTaskToken.Token));
|
||||
Func<SolverConfig, SimulationState, Action<ActionType>?, CancellationToken, (List<ActionType> Actions, SimulationState State)> solverMethod = Configuration.SolverAlgorithm switch
|
||||
{
|
||||
SolverAlgorithm.Oneshot => Solver.Crafty.Solver.SearchOneshot,
|
||||
SolverAlgorithm.OneshotForked => Solver.Crafty.Solver.SearchOneshotForked,
|
||||
SolverAlgorithm.Stepwise => Solver.Crafty.Solver.SearchStepwise,
|
||||
SolverAlgorithm.StepwiseForked => Solver.Crafty.Solver.SearchStepwiseForked,
|
||||
SolverAlgorithm.StepwiseFurcated or _ => Solver.Crafty.Solver.SearchStepwiseFurcated,
|
||||
};
|
||||
SolverTask = Task.Run(() => solverMethod(Configuration.SolverConfig, solverState, SolverActionQueue.Enqueue, SolverTaskToken.Token));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user