Skip to content

Commit

Permalink
Fix ActionSet
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 2, 2023
1 parent 74195b5 commit 0c96ba7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Solver/ActionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct ActionSet
private static int FromAction(ActionType action)
{
var ret = Simulator.AcceptedActionsLUT[(byte)action];
if (ret == 0)
if (ret == -1)
throw new ArgumentOutOfRangeException(nameof(action), action, $"Action {action} is unsupported in {nameof(ActionSet)}.");
return ret;
}
Expand Down
2 changes: 2 additions & 0 deletions Solver/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public Simulator(SimulationState state, int maxStepCount) : base(state)
static Simulator()
{
AcceptedActionsLUT = new int[Enum.GetValues<ActionType>().Length];
for (var i = 0; i < AcceptedActionsLUT.Length; i++)
AcceptedActionsLUT[i] = -1;
for (var i = 0; i < AcceptedActions.Length; i++)
AcceptedActionsLUT[(byte)AcceptedActions[i]] = i;
}
Expand Down

0 comments on commit 0c96ba7

Please sign in to comment.