From 480cc15cc7f55c384cbdcb3ab355fc60a570f3f4 Mon Sep 17 00:00:00 2001 From: Asriel Camora Date: Mon, 1 Jul 2024 09:49:27 -0700 Subject: [PATCH] Remove score storage threshold --- Craftimizer/Windows/Settings.cs | 14 +------------- Solver/MCTS.cs | 10 ---------- Solver/MCTSConfig.cs | 2 -- Solver/Solver.cs | 28 ---------------------------- Solver/SolverConfig.cs | 2 -- 5 files changed, 1 insertion(+), 55 deletions(-) diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index 3bc0c9f..9397b33 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -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( diff --git a/Solver/MCTS.cs b/Solver/MCTS.cs index 8732110..6ff05c3 100644 --- a/Solver/MCTS.cs +++ b/Solver/MCTS.cs @@ -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; 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); } diff --git a/Solver/MCTSConfig.cs b/Solver/MCTSConfig.cs index 8f7f091..2778a13 100644 --- a/Solver/MCTSConfig.cs +++ b/Solver/MCTSConfig.cs @@ -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; diff --git a/Solver/Solver.cs b/Solver/Solver.cs index c6f6b20..aa82137 100644 --- a/Solver/Solver.cs +++ b/Solver/Solver.cs @@ -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 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(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); diff --git a/Solver/SolverConfig.cs b/Solver/SolverConfig.cs index 721157b..4a2f475 100644 --- a/Solver/SolverConfig.cs +++ b/Solver/SolverConfig.cs @@ -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;