Precompute base progress/quality increases

This commit is contained in:
Asriel Camora
2023-06-20 17:07:16 -07:00
parent 1d0d4cf8ce
commit cdd4f5923e
8 changed files with 55 additions and 38 deletions
+6 -6
View File
@@ -13,10 +13,9 @@ internal static class Program
//TypeLayout.PrintLayout<Solver.Crafty.SimulationNode>(true);
//return;
var input = new SimulationInput()
{
Stats = new CharacterStats { Craftsmanship = 4041, Control = 3905, CP = 609, Level = 90 },
Recipe = new RecipeInfo()
var input = new SimulationInput(
new CharacterStats { Craftsmanship = 4041, Control = 3905, CP = 609, Level = 90 },
new RecipeInfo()
{
IsExpert = false,
ClassJobLevel = 90,
@@ -29,8 +28,9 @@ internal static class Program
QualityDivider = 115,
ProgressModifier = 80,
ProgressDivider = 130,
}
};
},
0
);
var actions = new List<ActionType>();
var s = Stopwatch.StartNew();
+5 -5
View File
@@ -26,11 +26,11 @@ public class SimulatorWindow : Window
MaximumSize = new Vector2(float.MaxValue, float.MaxValue)
};
State = new(new()
{
Stats = new CharacterStats { Craftsmanship = 4041, Control = 3905, CP = 609, Level = 90, CLvl = CalculateCLvl(90) },
Recipe = CreateRecipeInfo(LuminaSheets.RecipeSheet.GetRow(35499)!)
});
State = new(new(
new CharacterStats { Craftsmanship = 4041, Control = 3905, CP = 609, Level = 90, CLvl = CalculateCLvl(90) },
CreateRecipeInfo(LuminaSheets.RecipeSheet.GetRow(35499)!),
0
));
Simulation = new(State);
}
+1 -7
View File
@@ -6,17 +6,11 @@ internal abstract class BaseBuffAction : BaseAction
{
public abstract EffectType Effect { get; }
public virtual byte Duration => 1;
public virtual EffectType[] ConflictingEffects => Array.Empty<EffectType>();
public override int DurabilityCost => 0;
public override void UseSuccess()
{
if (ConflictingEffects.Length != 0)
foreach(var effect in ConflictingEffects)
Simulation.RemoveEffect(effect);
public override void UseSuccess() =>
Simulation.AddEffect(Effect, Duration);
}
public override string GetTooltip(bool addUsability)
{
+6 -1
View File
@@ -10,5 +10,10 @@ internal sealed class WasteNot : BaseBuffAction
public override EffectType Effect => EffectType.WasteNot;
public override byte Duration => 4;
public override EffectType[] ConflictingEffects => new[] { EffectType.WasteNot2 };
public override void UseSuccess()
{
base.UseSuccess();
Simulation.RemoveEffect(EffectType.WasteNot2);
}
}
+6 -1
View File
@@ -10,5 +10,10 @@ internal sealed class WasteNot2 : BaseBuffAction
public override EffectType Effect => EffectType.WasteNot2;
public override byte Duration => 8;
public override EffectType[] ConflictingEffects => new[] { EffectType.WasteNot };
public override void UseSuccess()
{
base.UseSuccess();
Simulation.RemoveEffect(EffectType.WasteNot);
}
}
+27 -3
View File
@@ -2,9 +2,33 @@ namespace Craftimizer.Simulator;
public readonly record struct SimulationInput
{
public CharacterStats Stats { get; init; }
public RecipeInfo Recipe { get; init; }
public Random Random { get; init; }
public CharacterStats Stats { get; }
public RecipeInfo Recipe { get; }
public Random Random { get; }
public int BaseProgressGain { get; }
public int BaseQualityGain { get; }
public SimulationInput(CharacterStats stats, RecipeInfo recipe, int seed)
{
Stats = stats;
Recipe = recipe;
Random = new Random(seed);
// https://github.com/NotRanged/NotRanged.github.io/blob/0f4aee074f969fb05aad34feaba605057c08ffd1/app/js/ffxivcraftmodel.js#L88
{
var baseIncrease = (Stats.Craftsmanship * 10f / Recipe.ProgressDivider) + 2;
if (Stats.CLvl <= Recipe.RLvl)
baseIncrease *= Recipe.ProgressModifier / 100f;
BaseProgressGain = (int)baseIncrease;
}
{
var baseIncrease = (Stats.Control * 10f / Recipe.QualityDivider) + 35;
if (Stats.CLvl <= Recipe.RLvl)
baseIncrease *= Recipe.QualityModifier / 100f;
BaseQualityGain = (int)baseIncrease;
}
}
public Condition[] AvailableConditions => ConditionUtils.GetPossibleConditions(Recipe.ConditionsFlag);
}
+2 -13
View File
@@ -233,13 +233,7 @@ public class Simulator
_ => 1.00f
};
// https://github.com/NotRanged/NotRanged.github.io/blob/0f4aee074f969fb05aad34feaba605057c08ffd1/app/js/ffxivcraftmodel.js#L88
var baseIncrease = (Input.Stats.Craftsmanship * 10f / Input.Recipe.ProgressDivider) + 2;
if (Input.Stats.CLvl <= Input.Recipe.RLvl)
baseIncrease *= Input.Recipe.ProgressModifier / 100f;
baseIncrease = MathF.Floor(baseIncrease);
var progressGain = (int)(baseIncrease * efficiency * conditionModifier * buffModifier);
var progressGain = (int)(Input.BaseProgressGain * efficiency * conditionModifier * buffModifier);
return progressGain;
}
@@ -265,12 +259,7 @@ public class Simulator
_ => 1.00f,
};
var baseIncrease = (Input.Stats.Control * 10f / Input.Recipe.QualityDivider) + 35;
if (Input.Stats.CLvl <= Input.Recipe.RLvl)
baseIncrease *= Input.Recipe.QualityModifier / 100f;
baseIncrease = MathF.Floor(baseIncrease);
var qualityGain = (int)(baseIncrease * efficiency * conditionModifier * buffModifier);
var qualityGain = (int)(Input.BaseQualityGain * efficiency * conditionModifier * buffModifier);
return qualityGain;
}
+2 -2
View File
@@ -324,7 +324,7 @@ public class Solver
return (actions, state);
}
Debugger.Break();
//Debugger.Break();
var solver = new Solver(state, true);
while (!solver.Simulator.IsComplete)
{
@@ -344,7 +344,7 @@ public class Solver
solver = new Solver(state, true);
}
Debugger.Break();
//Debugger.Break();
return (actions, state);
}