From b5be15310bbd1094c1f158a24abbfecade737d99 Mon Sep 17 00:00:00 2001 From: Survy Vaish Date: Mon, 1 Jan 2024 13:21:49 -0800 Subject: [PATCH] Fix _action_to_direction usage To use the _action_to_direction dict, we need to first convert the numerical action (0, 1, 2, 3) to an Enum. --- template/{{environment_name}}/envs/grid_world.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/template/{{environment_name}}/envs/grid_world.py b/template/{{environment_name}}/envs/grid_world.py index cda19dc..08df753 100644 --- a/template/{{environment_name}}/envs/grid_world.py +++ b/template/{{environment_name}}/envs/grid_world.py @@ -38,10 +38,10 @@ def __init__(self, render_mode=None, size=5): i.e. 0 corresponds to "right", 1 to "up" etc. """ self._action_to_direction = { - Actions.right: np.array([1, 0]), - Actions.up: np.array([0, 1]), - Actions.left: np.array([-1, 0]), - Actions.down: np.array([0, -1]), + Actions.right.value: np.array([1, 0]), + Actions.up.value: np.array([0, 1]), + Actions.left.value: np.array([-1, 0]), + Actions.down.value: np.array([0, -1]), } assert render_mode is None or render_mode in self.metadata["render_modes"]