Remove score storage threshold

This commit is contained in:
Asriel Camora
2024-07-01 09:49:27 -07:00
parent a20b5014cb
commit 480cc15cc7
5 changed files with 1 additions and 55 deletions
+1 -13
View File
@@ -538,18 +538,6 @@ public sealed class Settings : Window, IDisposable
using (var panel = ImRaii2.GroupPanel("Advanced", -1, out _))
{
DrawOption(
"Score Storage Threshold",
"If a craft achieves this certain arbitrary score, the solver will " +
"throw away all other possible combinations in favor of that one. " +
"Only change this value if you absolutely know what you're doing.",
config.ScoreStorageThreshold,
0,
1,
v => config = config with { ScoreStorageThreshold = v },
ref isDirty
);
DrawOption(
"Max Rollout Step Count",
"The maximum number of crafting steps every iteration can consider. " +
@@ -575,7 +563,7 @@ public sealed class Settings : Window, IDisposable
using (var panel = ImRaii2.GroupPanel("Score Weights (Advanced)", -1, out _))
{
ImGui.TextWrapped("All values should add up to 1. Otherwise, the Score Storage Threshold should be changed.");
ImGui.TextWrapped("All values should add up to 1.");
ImGuiHelpers.ScaledDummy(10);
DrawOption(
-10
View File
@@ -1,7 +1,6 @@
using Craftimizer.Simulator.Actions;
using Craftimizer.Simulator;
using System.Diagnostics.Contracts;
using System.Numerics;
using System.Runtime.CompilerServices;
using Node = Craftimizer.Solver.ArenaNode<Craftimizer.Solver.SimulationNode>;
using System.Runtime.Intrinsics;
@@ -206,16 +205,7 @@ public sealed class MCTS
currentActions = simulator.AvailableActionsHeuristic(true);
}
// store the result if a max score was reached
var score = SimulationNode.CalculateScoreForState(currentState, currentCompletionState, config) ?? 0;
if (currentCompletionState == CompletionState.ProgressComplete)
{
if (score >= config.ScoreStorageThreshold && score >= MaxScore)
{
var terminalNode = ExecuteActions(simulator, expandedNode, actions[..actionCount], true);
return (terminalNode, score);
}
}
return (expandedNode, score);
}
-2
View File
@@ -14,7 +14,6 @@ public readonly record struct MCTSConfig
public float MaxScoreWeightingConstant { get; init; }
public float ExplorationConstant { get; init; }
public float ScoreStorageThreshold { get; init; }
public float ScoreProgress { get; init; }
public float ScoreQuality { get; init; }
@@ -32,7 +31,6 @@ public readonly record struct MCTSConfig
MaxScoreWeightingConstant = config.MaxScoreWeightingConstant;
ExplorationConstant = config.ExplorationConstant;
ScoreStorageThreshold = config.ScoreStorageThreshold;
ScoreProgress = config.ScoreProgress;
ScoreQuality = config.ScoreQuality;
-28
View File
@@ -188,18 +188,6 @@ public sealed class Solver : IDisposable
var bestActions = tasks.Select(t => t.Result).OrderByDescending(r => r.MaxScore).Take(Config.FurcatedActionCount).ToArray();
var bestAction = bestActions[0];
if (bestAction.MaxScore >= Config.ScoreStorageThreshold)
{
var (_, furcatedActionIdx, solution) = bestAction;
(IEnumerable<ActionType> activeActions, _) = activeStates[furcatedActionIdx];
activeActions = activeActions.Concat(solution.Actions);
foreach (var action in activeActions.Skip(definiteActionCount))
InvokeNewAction(action);
return solution with { ActionEnumerable = activeActions };
}
var newStates = new List<SolverSolution>(Config.FurcatedActionCount);
for (var i = 0; i < bestActions.Length; ++i)
{
@@ -312,14 +300,6 @@ public sealed class Solver : IDisposable
var (maxScore, solution) = tasks.Select(t => t.Result).MaxBy(r => r.MaxScore);
if (maxScore >= Config.ScoreStorageThreshold)
{
actions.AddRange(solution.Actions);
foreach (var action in solution.Actions)
InvokeNewAction(action);
return solution with { Actions = actions };
}
var chosenAction = solution.Actions[0];
InvokeNewAction(chosenAction);
@@ -355,14 +335,6 @@ public sealed class Solver : IDisposable
var solution = solver.Solution();
if (solver.MaxScore >= Config.ScoreStorageThreshold)
{
actions.AddRange(solution.Actions);
foreach (var action in solution.Actions)
InvokeNewAction(action);
return Task.FromResult(solution with { Actions = actions });
}
var chosenAction = solution.Actions[0];
InvokeNewAction(chosenAction);
-2
View File
@@ -17,7 +17,6 @@ public enum SolverAlgorithm
public readonly record struct SolverConfig
{
public int Iterations { get; init; }
public float ScoreStorageThreshold { get; init; }
public float MaxScoreWeightingConstant { get; init; }
public float ExplorationConstant { get; init; }
public int MaxStepCount { get; init; }
@@ -39,7 +38,6 @@ public readonly record struct SolverConfig
public SolverConfig()
{
Iterations = 100_000;
ScoreStorageThreshold = 1f;
MaxScoreWeightingConstant = 0.1f;
ExplorationConstant = 4;
MaxStepCount = 30;