Remove score storage threshold
This commit is contained in:
@@ -538,18 +538,6 @@ public sealed class Settings : Window, IDisposable
|
|||||||
|
|
||||||
using (var panel = ImRaii2.GroupPanel("Advanced", -1, out _))
|
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(
|
DrawOption(
|
||||||
"Max Rollout Step Count",
|
"Max Rollout Step Count",
|
||||||
"The maximum number of crafting steps every iteration can consider. " +
|
"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 _))
|
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);
|
ImGuiHelpers.ScaledDummy(10);
|
||||||
|
|
||||||
DrawOption(
|
DrawOption(
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Craftimizer.Simulator.Actions;
|
using Craftimizer.Simulator.Actions;
|
||||||
using Craftimizer.Simulator;
|
using Craftimizer.Simulator;
|
||||||
using System.Diagnostics.Contracts;
|
using System.Diagnostics.Contracts;
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Node = Craftimizer.Solver.ArenaNode<Craftimizer.Solver.SimulationNode>;
|
using Node = Craftimizer.Solver.ArenaNode<Craftimizer.Solver.SimulationNode>;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
@@ -206,16 +205,7 @@ public sealed class MCTS
|
|||||||
currentActions = simulator.AvailableActionsHeuristic(true);
|
currentActions = simulator.AvailableActionsHeuristic(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the result if a max score was reached
|
|
||||||
var score = SimulationNode.CalculateScoreForState(currentState, currentCompletionState, config) ?? 0;
|
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);
|
return (expandedNode, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ public readonly record struct MCTSConfig
|
|||||||
|
|
||||||
public float MaxScoreWeightingConstant { get; init; }
|
public float MaxScoreWeightingConstant { get; init; }
|
||||||
public float ExplorationConstant { get; init; }
|
public float ExplorationConstant { get; init; }
|
||||||
public float ScoreStorageThreshold { get; init; }
|
|
||||||
|
|
||||||
public float ScoreProgress { get; init; }
|
public float ScoreProgress { get; init; }
|
||||||
public float ScoreQuality { get; init; }
|
public float ScoreQuality { get; init; }
|
||||||
@@ -32,7 +31,6 @@ public readonly record struct MCTSConfig
|
|||||||
|
|
||||||
MaxScoreWeightingConstant = config.MaxScoreWeightingConstant;
|
MaxScoreWeightingConstant = config.MaxScoreWeightingConstant;
|
||||||
ExplorationConstant = config.ExplorationConstant;
|
ExplorationConstant = config.ExplorationConstant;
|
||||||
ScoreStorageThreshold = config.ScoreStorageThreshold;
|
|
||||||
|
|
||||||
ScoreProgress = config.ScoreProgress;
|
ScoreProgress = config.ScoreProgress;
|
||||||
ScoreQuality = config.ScoreQuality;
|
ScoreQuality = config.ScoreQuality;
|
||||||
|
|||||||
@@ -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 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);
|
var newStates = new List<SolverSolution>(Config.FurcatedActionCount);
|
||||||
for (var i = 0; i < bestActions.Length; ++i)
|
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);
|
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];
|
var chosenAction = solution.Actions[0];
|
||||||
InvokeNewAction(chosenAction);
|
InvokeNewAction(chosenAction);
|
||||||
|
|
||||||
@@ -355,14 +335,6 @@ public sealed class Solver : IDisposable
|
|||||||
|
|
||||||
var solution = solver.Solution();
|
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];
|
var chosenAction = solution.Actions[0];
|
||||||
InvokeNewAction(chosenAction);
|
InvokeNewAction(chosenAction);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ public enum SolverAlgorithm
|
|||||||
public readonly record struct SolverConfig
|
public readonly record struct SolverConfig
|
||||||
{
|
{
|
||||||
public int Iterations { get; init; }
|
public int Iterations { get; init; }
|
||||||
public float ScoreStorageThreshold { get; init; }
|
|
||||||
public float MaxScoreWeightingConstant { get; init; }
|
public float MaxScoreWeightingConstant { get; init; }
|
||||||
public float ExplorationConstant { get; init; }
|
public float ExplorationConstant { get; init; }
|
||||||
public int MaxStepCount { get; init; }
|
public int MaxStepCount { get; init; }
|
||||||
@@ -39,7 +38,6 @@ public readonly record struct SolverConfig
|
|||||||
public SolverConfig()
|
public SolverConfig()
|
||||||
{
|
{
|
||||||
Iterations = 100_000;
|
Iterations = 100_000;
|
||||||
ScoreStorageThreshold = 1f;
|
|
||||||
MaxScoreWeightingConstant = 0.1f;
|
MaxScoreWeightingConstant = 0.1f;
|
||||||
ExplorationConstant = 4;
|
ExplorationConstant = 4;
|
||||||
MaxStepCount = 30;
|
MaxStepCount = 30;
|
||||||
|
|||||||
Reference in New Issue
Block a user