Remove score storage threshold
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user