Remove crafty namespace from solver
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Craftimizer.Solver.Crafty;
|
||||
using Craftimizer.Solver;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Craftimizer.Benchmark;
|
||||
@@ -77,11 +77,11 @@ internal static class Program
|
||||
|
||||
Console.WriteLine($"{state.Quality} {state.CP} {state.Progress} {state.Durability}");
|
||||
//return;
|
||||
var (_, s) = Solver.Crafty.Solver.SearchStepwiseFurcated(config, state, a => Console.WriteLine(a), default);
|
||||
var (_, s) = Solver.Solver.SearchStepwiseFurcated(config, state, a => Console.WriteLine(a), default);
|
||||
Console.WriteLine($"Qual: {s.Quality}/{s.Input.Recipe.MaxQuality}");
|
||||
return;
|
||||
|
||||
Solver.Crafty.Solver.SearchStepwiseFurcated(config, new(input), null, default);
|
||||
Solver.Solver.SearchStepwiseFurcated(config, new(input), null, default);
|
||||
//Benchmark(() => );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Craftimizer.Solver.Crafty;
|
||||
using Craftimizer.Solver;
|
||||
using Dalamud.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -21,7 +21,7 @@ public static class AlgorithmUtils
|
||||
{
|
||||
try
|
||||
{
|
||||
Solver.Crafty.Solver.Search(me, state, actionCallback, token);
|
||||
Solver.Solver.Search(me, state, actionCallback, token);
|
||||
}
|
||||
catch (AggregateException e)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Craftimizer.Solver.Crafty;
|
||||
using Craftimizer.Solver;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Windowing;
|
||||
using ImGuiNET;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public struct ActionSet
|
||||
{
|
||||
@@ -2,7 +2,7 @@ using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
// Adapted from https://github.com/dtao/ConcurrentList/blob/4fcf1c76e93021a41af5abb2d61a63caeba2adad/ConcurrentList/ConcurrentList.cs
|
||||
public struct ArenaBuffer<T> where T : struct
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public sealed class ArenaNode<T> where T : struct
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using CompState = Craftimizer.Simulator.CompletionState;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public enum CompletionState : byte
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Intrinsics;
|
||||
using System.Runtime.Intrinsics.X86;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
internal static class Intrinsics
|
||||
{
|
||||
[Pure]
|
||||
@@ -50,7 +50,7 @@ internal static class Intrinsics
|
||||
var vcmp = Avx.CompareEqual(vfilt, vmax);
|
||||
var mask = unchecked((uint)Avx2.MoveMask(vcmp.AsByte()));
|
||||
|
||||
var inverseIdx = BitOperations.LeadingZeroCount(mask << ((8 - len) << 2)) >> 2;
|
||||
var inverseIdx = BitOperations.LeadingZeroCount(mask << (8 - len << 2)) >> 2;
|
||||
|
||||
return len - 1 - inverseIdx;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
// Adapted from https://github.com/dtao/ConcurrentList/blob/4fcf1c76e93021a41af5abb2d61a63caeba2adad/ConcurrentList/ConcurrentList.cs
|
||||
public struct NodeScoresBuffer
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public sealed class RootScores
|
||||
@@ -2,7 +2,7 @@ using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
[StructLayout(LayoutKind.Auto)]
|
||||
public struct SimulationNode
|
||||
@@ -75,7 +75,7 @@ public struct SimulationNode
|
||||
);
|
||||
|
||||
var fewerStepsScore =
|
||||
config.ScoreFewerStepsBonus * (1f - ((float)(state.ActionCount + 1) / config.MaxStepCount));
|
||||
config.ScoreFewerStepsBonus * (1f - (float)(state.ActionCount + 1) / config.MaxStepCount);
|
||||
|
||||
return progressScore + qualityScore + durabilityScore + cpScore + fewerStepsScore;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Craftimizer.Simulator.Actions;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public sealed class Simulator : SimulatorNoRandom
|
||||
{
|
||||
@@ -129,7 +129,7 @@ public sealed class Simulator : SimulatorNoRandom
|
||||
if (wouldFinish)
|
||||
{
|
||||
// don't allow finishing the craft if there is significant quality remaining
|
||||
if (Quality < (Input.Recipe.MaxQuality / 5))
|
||||
if (Quality < Input.Recipe.MaxQuality / 5)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -188,7 +188,7 @@ public sealed class Simulator : SimulatorNoRandom
|
||||
}
|
||||
|
||||
public static CompletionState CalculateCompletionState(SimulationState state, int maxStepCount) =>
|
||||
(state.ActionCount + 1) >= maxStepCount ?
|
||||
state.ActionCount + 1 >= maxStepCount ?
|
||||
CompletionState.MaxActionCountReached :
|
||||
(CompletionState)CalculateCompletionState(state);
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using System.Diagnostics.Contracts;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using Node = Craftimizer.Solver.Crafty.ArenaNode<Craftimizer.Solver.Crafty.SimulationNode>;
|
||||
using Node = Craftimizer.Solver.ArenaNode<Craftimizer.Solver.SimulationNode>;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
// https://github.com/alostsock/crafty/blob/cffbd0cad8bab3cef9f52a3e3d5da4f5e3781842/crafty/src/simulator.rs
|
||||
public sealed class Solver
|
||||
@@ -155,7 +155,7 @@ public sealed class Solver
|
||||
vInt = Vector.Max(vInt, Vector<int>.One);
|
||||
var v = Vector.ConvertToSingle(vInt);
|
||||
|
||||
var exploitation = (W * (s / v)) + (w * m);
|
||||
var exploitation = W * (s / v) + w * m;
|
||||
var exploration = CVector * Intrinsics.ReciprocalSqrt(v);
|
||||
var evalScores = exploitation + exploration;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public enum SolverAlgorithm
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
|
||||
namespace Craftimizer.Solver.Crafty;
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
public readonly record struct SolverSolution(List<ActionType> Actions, SimulationState State);
|
||||
Reference in New Issue
Block a user