Customizable solver config, remove simulator emplace/displace methods

This commit is contained in:
Asriel Camora
2023-06-21 10:38:08 -07:00
parent 11b4b7f6d9
commit f3445f3cb9
12 changed files with 103 additions and 90 deletions
+16 -44
View File
@@ -4,18 +4,20 @@ namespace Craftimizer.Simulator;
public class Simulator
{
public SimulationInput Input { get; private set; }
public int ActionCount { get; private set; }
public int StepCount { get; private set; }
public int Progress { get; private set; }
public int Quality { get; private set; }
public int Durability { get; private set; }
public int CP { get; private set; }
public Condition Condition { get; private set; }
public Effects ActiveEffects;
public ActionStates ActionStates;
protected SimulationState State;
public bool IsFirstStep => StepCount == 0;
public SimulationInput Input => State.Input;
public ref int ActionCount => ref State.ActionCount;
public ref int StepCount => ref State.StepCount;
public ref int Progress => ref State.Progress;
public ref int Quality => ref State.Quality;
public ref int Durability => ref State.Durability;
public ref int CP => ref State.CP;
public ref Condition Condition => ref State.Condition;
public ref Effects ActiveEffects => ref State.ActiveEffects;
public ref ActionStates ActionStates => ref State.ActionStates;
public bool IsFirstStep => State.StepCount == 0;
public CompletionState CompletionState
{
@@ -32,45 +34,15 @@ public class Simulator
public IEnumerable<ActionType> AvailableActions => ActionUtils.AvailableActions(this);
#pragma warning disable CS8618 // Emplace sets all the fields already
public Simulator(SimulationState state)
#pragma warning restore CS8618
{
Emplace(state);
State = state;
}
private void Emplace(SimulationState state)
{
Input = state.Input;
ActionCount = state.ActionCount;
StepCount = state.StepCount;
Progress = state.Progress;
Quality = state.Quality;
Durability = state.Durability;
CP = state.CP;
Condition = state.Condition;
ActiveEffects = state.ActiveEffects;
ActionStates = state.ActionStates;
}
private SimulationState Displace() => new()
{
Input = Input,
ActionCount = ActionCount,
StepCount = StepCount,
Progress = Progress,
Quality = Quality,
Durability = Durability,
CP = CP,
Condition = Condition,
ActiveEffects = ActiveEffects,
ActionStates = ActionStates,
};
public (ActionResponse Response, SimulationState NewState) Execute(SimulationState state, ActionType action)
{
Emplace(state);
return (Execute(action), Displace());
State = state;
return (Execute(action), State);
}
private ActionResponse Execute(ActionType action)