Optimize trace build, add trace sim code
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
<Configurations>Debug;Release;Trace</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="BenchmarkDotNet.Artifacts\**" />
|
||||
<EmbeddedResource Remove="BenchmarkDotNet.Artifacts\**" />
|
||||
<None Remove="BenchmarkDotNet.Artifacts\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.13.8" />
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.92">
|
||||
@@ -22,4 +28,14 @@
|
||||
<ProjectReference Include="..\Simulator\Craftimizer.Simulator.csproj" />
|
||||
<ProjectReference Include="..\Solver\Craftimizer.Solver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(IS_BENCH)'=='1'">
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Trace'">
|
||||
<Optimize>True</Optimize>
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
+85
-46
@@ -1,4 +1,3 @@
|
||||
using BenchmarkDotNet.Running;
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Craftimizer.Solver;
|
||||
@@ -10,19 +9,16 @@ internal static class Program
|
||||
{
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
#if !IS_TRACE
|
||||
Environment.SetEnvironmentVariable("IS_BENCH", "1");
|
||||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
|
||||
return;
|
||||
|
||||
//TypeLayout.PrintLayout<ArenaNode<SimulationNode>>(true);
|
||||
//return;
|
||||
|
||||
BenchmarkDotNet.Running.BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
|
||||
#else
|
||||
var input = new SimulationInput(
|
||||
new CharacterStats
|
||||
new()
|
||||
{
|
||||
Craftsmanship = 4078,
|
||||
Control = 3897,
|
||||
CP = 704,
|
||||
Craftsmanship = 4041,
|
||||
Control = 3905,
|
||||
CP = 609,
|
||||
Level = 90,
|
||||
CanUseManipulation = true,
|
||||
HasSplendorousBuff = false,
|
||||
@@ -44,47 +40,90 @@ internal static class Program
|
||||
ProgressDivider = 130,
|
||||
}
|
||||
);
|
||||
|
||||
var config = new SolverConfig()
|
||||
{
|
||||
Iterations = 100_000,
|
||||
ForkCount = 32,
|
||||
FurcatedActionCount = 16,
|
||||
MaxStepCount = 30,
|
||||
Algorithm = SolverAlgorithm.Stepwise,
|
||||
Iterations = 30000
|
||||
};
|
||||
|
||||
var sim = new SimulatorNoRandom(new(input));
|
||||
(_, var state) = sim.Execute(new(input), ActionType.MuscleMemory);
|
||||
(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
//(_, state) = sim.Execute(state, ActionType.Manipulation);
|
||||
//(_, state) = sim.Execute(state, ActionType.Veneration);
|
||||
//(_, state) = sim.Execute(state, ActionType.WasteNot);
|
||||
//(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
//(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
//(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
//(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
//(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
//(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo);
|
||||
//(_, state) = sim.Execute(state, ActionType.Manipulation);
|
||||
//(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
//(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
//(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo);
|
||||
//(_, state) = sim.Execute(state, ActionType.GreatStrides);
|
||||
//(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
//(_, state) = sim.Execute(state, ActionType.FocusedTouchCombo);
|
||||
//(_, state) = sim.Execute(state, ActionType.GreatStrides);
|
||||
//(_, state) = sim.Execute(state, ActionType.ByregotsBlessing);
|
||||
//(_, state) = sim.Execute(state, ActionType.CarefulSynthesis);
|
||||
//(_, state) = sim.Execute(state, ActionType.CarefulSynthesis);
|
||||
|
||||
Console.WriteLine($"{state.Quality} {state.CP} {state.Progress} {state.Durability}");
|
||||
//return;
|
||||
var solver = new Solver.Solver(config, state);
|
||||
solver.OnLog += Console.WriteLine;
|
||||
solver.OnNewAction += s => Console.WriteLine(s);
|
||||
var solver = new Solver.Solver(config, new(input));
|
||||
solver.OnNewAction += s => Console.WriteLine($">{s}");
|
||||
solver.Start();
|
||||
var (_, s) = await solver.GetTask().ConfigureAwait(false);
|
||||
Console.WriteLine($"Qual: {s.Quality}/{s.Input.Recipe.MaxQuality}");
|
||||
#endif
|
||||
return;
|
||||
|
||||
////TypeLayout.PrintLayout<ArenaNode<SimulationNode>>(true);
|
||||
////return;
|
||||
|
||||
//var input = new SimulationInput(
|
||||
// new CharacterStats
|
||||
// {
|
||||
// Craftsmanship = 4078,
|
||||
// Control = 3897,
|
||||
// CP = 704,
|
||||
// Level = 90,
|
||||
// CanUseManipulation = true,
|
||||
// HasSplendorousBuff = false,
|
||||
// IsSpecialist = false,
|
||||
// CLvl = 560,
|
||||
// },
|
||||
// new RecipeInfo()
|
||||
// {
|
||||
// IsExpert = false,
|
||||
// ClassJobLevel = 90,
|
||||
// RLvl = 640,
|
||||
// ConditionsFlag = 15,
|
||||
// MaxDurability = 70,
|
||||
// MaxQuality = 14040,
|
||||
// MaxProgress = 6600,
|
||||
// QualityModifier = 70,
|
||||
// QualityDivider = 115,
|
||||
// ProgressModifier = 80,
|
||||
// ProgressDivider = 130,
|
||||
// }
|
||||
//);
|
||||
|
||||
//var config = new SolverConfig()
|
||||
//{
|
||||
// Iterations = 100_000,
|
||||
// ForkCount = 32,
|
||||
// FurcatedActionCount = 16,
|
||||
// MaxStepCount = 30,
|
||||
//};
|
||||
|
||||
//var sim = new SimulatorNoRandom(new(input));
|
||||
//(_, var state) = sim.Execute(new(input), ActionType.MuscleMemory);
|
||||
//(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
////(_, state) = sim.Execute(state, ActionType.Manipulation);
|
||||
////(_, state) = sim.Execute(state, ActionType.Veneration);
|
||||
////(_, state) = sim.Execute(state, ActionType.WasteNot);
|
||||
////(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
////(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
////(_, state) = sim.Execute(state, ActionType.Groundwork);
|
||||
////(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
////(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
////(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo);
|
||||
////(_, state) = sim.Execute(state, ActionType.Manipulation);
|
||||
////(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
////(_, state) = sim.Execute(state, ActionType.PrudentTouch);
|
||||
////(_, state) = sim.Execute(state, ActionType.AdvancedTouchCombo);
|
||||
////(_, state) = sim.Execute(state, ActionType.GreatStrides);
|
||||
////(_, state) = sim.Execute(state, ActionType.Innovation);
|
||||
////(_, state) = sim.Execute(state, ActionType.FocusedTouchCombo);
|
||||
////(_, state) = sim.Execute(state, ActionType.GreatStrides);
|
||||
////(_, state) = sim.Execute(state, ActionType.ByregotsBlessing);
|
||||
////(_, state) = sim.Execute(state, ActionType.CarefulSynthesis);
|
||||
////(_, state) = sim.Execute(state, ActionType.CarefulSynthesis);
|
||||
|
||||
//Console.WriteLine($"{state.Quality} {state.CP} {state.Progress} {state.Durability}");
|
||||
////return;
|
||||
//var solver = new Solver.Solver(config, state);
|
||||
//solver.OnLog += Console.WriteLine;
|
||||
//solver.OnNewAction += s => Console.WriteLine(s);
|
||||
//solver.Start();
|
||||
//var (_, s) = await solver.GetTask().ConfigureAwait(false);
|
||||
//Console.WriteLine($"Qual: {s.Quality}/{s.Input.Recipe.MaxQuality}");
|
||||
}
|
||||
|
||||
private static void Benchmark(Func<SolverSolution> search)
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
<ProjectReference Include="..\Simulator\Craftimizer.Simulator.csproj" />
|
||||
<ProjectReference Include="..\Solver\Craftimizer.Solver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
|
||||
<PropertyGroup Condition="'$(IS_BENCH)'=='1'">
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
<DefineConstants Condition="'$(Configuration)' == 'Trace'">$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
<PropertyGroup Condition="'$(IS_BENCH)'=='1'">
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Trace'">
|
||||
<Optimize>True</Optimize>
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -20,9 +20,13 @@
|
||||
<ProjectReference Include="..\Simulator\Craftimizer.Simulator.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
<DefineConstants Condition="'$(Configuration)' == 'Trace'">$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
<PropertyGroup Condition="'$(IS_BENCH)'=='1'">
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)'=='Trace'">
|
||||
<Optimize>True</Optimize>
|
||||
<DefineConstants>$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user