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