Simulator changes

This commit is contained in:
Asriel Camora
2023-06-25 01:01:47 -07:00
parent 62efffa3e7
commit 866e30a5bc
4 changed files with 21 additions and 8 deletions
+7 -2
View File
@@ -10,11 +10,11 @@ public sealed class SimulationInput
public int BaseProgressGain { get; } public int BaseProgressGain { get; }
public int BaseQualityGain { get; } public int BaseQualityGain { get; }
public SimulationInput(CharacterStats stats, RecipeInfo recipe, int startingQuality = 0, int? seed = null) public SimulationInput(CharacterStats stats, RecipeInfo recipe, int startingQuality, Random random)
{ {
Stats = stats; Stats = stats;
Recipe = recipe; Recipe = recipe;
Random = seed == null ? new() : new(seed.Value); Random = random;
StartingQuality = startingQuality; StartingQuality = startingQuality;
// https://github.com/NotRanged/NotRanged.github.io/blob/0f4aee074f969fb05aad34feaba605057c08ffd1/app/js/ffxivcraftmodel.js#L88 // https://github.com/NotRanged/NotRanged.github.io/blob/0f4aee074f969fb05aad34feaba605057c08ffd1/app/js/ffxivcraftmodel.js#L88
@@ -32,5 +32,10 @@ public sealed class SimulationInput
} }
} }
public SimulationInput(CharacterStats stats, RecipeInfo recipe, int startingQuality = 0, int? seed = null) : this(stats, recipe, startingQuality, seed == null ? new Random() : new Random(seed.Value))
{
}
public Condition[] AvailableConditions => ConditionUtils.GetPossibleConditions(Recipe.ConditionsFlag); public Condition[] AvailableConditions => ConditionUtils.GetPossibleConditions(Recipe.ConditionsFlag);
} }
+2
View File
@@ -55,6 +55,8 @@ public class Simulator
{ {
if (baseAction.Level > Input.Stats.Level) if (baseAction.Level > Input.Stats.Level)
return ActionResponse.ActionNotUnlocked; return ActionResponse.ActionNotUnlocked;
if (action == ActionType.Manipulation && !Input.Stats.CanUseManipulation)
return ActionResponse.ActionNotUnlocked;
if (baseAction.CPCost(this) > CP) if (baseAction.CPCost(this) > CP)
return ActionResponse.NotEnoughCP; return ActionResponse.NotEnoughCP;
return ActionResponse.CannotUseAction; return ActionResponse.CannotUseAction;
+11
View File
@@ -0,0 +1,11 @@
namespace Craftimizer.Simulator;
public class SimulatorNoRandom : Simulator
{
public SimulatorNoRandom(SimulationState state) : base(state)
{
}
public sealed override bool RollSuccessRaw(float successRate) => successRate == 1;
public sealed override void StepCondition() { }
}
+1 -6
View File
@@ -2,11 +2,10 @@ using Craftimizer.Simulator;
using Craftimizer.Simulator.Actions; using Craftimizer.Simulator.Actions;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Sim = Craftimizer.Simulator.Simulator;
namespace Craftimizer.Solver.Crafty; namespace Craftimizer.Solver.Crafty;
public sealed class Simulator : Sim public sealed class Simulator : SimulatorNoRandom
{ {
private readonly int maxStepCount; private readonly int maxStepCount;
@@ -21,10 +20,6 @@ public sealed class Simulator : Sim
this.maxStepCount = maxStepCount; this.maxStepCount = maxStepCount;
} }
// Disable randomization
public override bool RollSuccessRaw(float successRate) => successRate == 1;
public override void StepCondition() { }
public static readonly ActionType[] AcceptedActions = new[] public static readonly ActionType[] AcceptedActions = new[]
{ {
ActionType.TrainedFinesse, ActionType.TrainedFinesse,