Solver optimizations & allow action pools
This commit is contained in:
+12
-7
@@ -21,9 +21,15 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
}
|
||||
}
|
||||
|
||||
public Simulator(ActionType[] actionPool, int maxStepCount)
|
||||
public Simulator(ActionType[] actionPool, int maxStepCount, SimulationState? filteringState = null)
|
||||
{
|
||||
actionPoolObjects = actionPool.Select(x => (x.Base(), x)).ToArray();
|
||||
var pool = actionPool.Select(x => (x.Base(), x));
|
||||
if (filteringState is { } state)
|
||||
{
|
||||
State = state;
|
||||
pool = pool.Where(x => x.Item1.IsPossible(this));
|
||||
}
|
||||
actionPoolObjects = pool.OrderBy(x => x.x).ToArray();
|
||||
this.maxStepCount = maxStepCount;
|
||||
}
|
||||
|
||||
@@ -32,7 +38,7 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
// It's just a bunch of if statements, I would assume this is actually quite simple to follow
|
||||
#pragma warning disable MA0051 // Method is too long
|
||||
private bool CanUseAction(ActionType action, BaseAction baseAction, bool strict)
|
||||
private bool CouldUseAction(ActionType action, BaseAction baseAction, bool strict)
|
||||
#pragma warning restore MA0051 // Method is too long
|
||||
{
|
||||
if (CalculateSuccessRate(baseAction.SuccessRate(this)) != 1)
|
||||
@@ -46,7 +52,7 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
{
|
||||
// always use Trained Eye if it's available
|
||||
if (action == ActionType.TrainedEye)
|
||||
return baseAction.CanUse(this);
|
||||
return baseAction.CouldUse(this);
|
||||
|
||||
// don't allow quality moves under Muscle Memory for difficult crafts
|
||||
if (Input.Recipe.ClassJobLevel == 90 &&
|
||||
@@ -123,7 +129,7 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
return false;
|
||||
}
|
||||
|
||||
return baseAction.CanUse(this);
|
||||
return baseAction.CouldUse(this);
|
||||
}
|
||||
|
||||
// https://github.com/alostsock/crafty/blob/cffbd0cad8bab3cef9f52a3e3d5da4f5e3781842/crafty/src/craft_state.rs#L137
|
||||
@@ -134,9 +140,8 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
|
||||
var ret = new ActionSet();
|
||||
foreach (var (data, action) in actionPoolObjects)
|
||||
if (CanUseAction(action, data, strict))
|
||||
if (CouldUseAction(action, data, strict))
|
||||
ret.AddAction(action);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user