Fix out of range exception

This commit is contained in:
Asriel Camora
2024-07-04 10:13:41 -07:00
parent 65d01aeed0
commit 7363b81ce5
2 changed files with 15 additions and 11 deletions
+1
View File
@@ -372,6 +372,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
if (!effect.IsIndefinite()) if (!effect.IsIndefinite())
{ {
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - durationShift); ImGui.SetCursorPosY(ImGui.GetCursorPosY() - durationShift);
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + 1);
ImGuiUtils.TextCentered($"{effects.GetDuration(effect)}", size.X); ImGuiUtils.TextCentered($"{effects.GetDuration(effect)}", size.X);
} }
} }
+14 -11
View File
@@ -191,18 +191,21 @@ public sealed class MCTS
var currentCompletionState = expandedNode.State.SimulationCompletionState; var currentCompletionState = expandedNode.State.SimulationCompletionState;
var currentActions = expandedNode.State.AvailableActions; var currentActions = expandedNode.State.AvailableActions;
byte actionCount = 0; if (currentState.ActionCount < config.MaxStepCount)
var actions = actionBuffer[..Math.Min(config.MaxStepCount - currentState.ActionCount, config.MaxRolloutStepCount)];
while (SimulationNode.GetCompletionState(currentCompletionState, currentActions) == CompletionState.Incomplete &&
actionCount < actions.Length)
{ {
var nextAction = currentActions.SelectRandom(random); var actions = actionBuffer[..Math.Min(config.MaxStepCount - currentState.ActionCount, config.MaxRolloutStepCount)];
actions[actionCount++] = nextAction; byte actionCount = 0;
currentState = simulator.ExecuteUnchecked(currentState, nextAction); while (SimulationNode.GetCompletionState(currentCompletionState, currentActions) == CompletionState.Incomplete &&
currentCompletionState = simulator.CompletionState; actionCount < actions.Length)
if (currentCompletionState != CompletionState.Incomplete) {
break; var nextAction = currentActions.SelectRandom(random);
currentActions = simulator.AvailableActionsHeuristic(true); actions[actionCount++] = nextAction;
currentState = simulator.ExecuteUnchecked(currentState, nextAction);
currentCompletionState = simulator.CompletionState;
if (currentCompletionState != CompletionState.Incomplete)
break;
currentActions = simulator.AvailableActionsHeuristic(true);
}
} }
var score = SimulationNode.CalculateScoreForState(currentState, currentCompletionState, config) ?? 0; var score = SimulationNode.CalculateScoreForState(currentState, currentCompletionState, config) ?? 0;