Skip to content

Commit

Permalink
Update Maze environments (#170)
Browse files Browse the repository at this point in the history
* ezpickle

* auto reset-goal in empty cells

* reset_target default to false

---------

Co-authored-by: rodrigodelazcano <[email protected]>
  • Loading branch information
rodrigodelazcano and rodrigodelazcano authored Sep 5, 2023
1 parent 166e998 commit eceb17e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gymnasium_robotics/envs/maze/ant_maze_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def __init__(
maze_map: List[List[Union[str, int]]] = U_MAZE,
reward_type: str = "sparse",
continuing_task: bool = True,
reset_target: bool = True,
reset_target: bool = False,
**kwargs,
):
# Get the ant.xml path from the Gymnasium package
Expand Down Expand Up @@ -258,13 +258,13 @@ def __init__(
)

self.render_mode = render_mode

EzPickle.__init__(
self,
render_mode,
maze_map,
reward_type,
continuing_task,
reset_target,
**kwargs,
)

Expand Down
10 changes: 10 additions & 0 deletions gymnasium_robotics/envs/maze/maze_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@ def make_maze(
# If there are no given "r", "g" or "c" cells in the maze data structure,
# any empty cell can be a reset or goal location at initialization.
maze._combined_locations = empty_locations
elif not maze._unique_reset_locations and not maze._combined_locations:
# If there are no given "r" or "c" cells in the maze data structure,
# any empty cell can be a reset location at initialization.
maze._unique_reset_locations = empty_locations
elif not maze._unique_goal_locations and not maze._combined_locations:
# If there are no given "g" or "c" cells in the maze data structure,
# any empty cell can be a gaol location at initialization.
maze._unique_goal_locations = empty_locations

maze._unique_goal_locations += maze._combined_locations
maze._unique_reset_locations += maze._combined_locations

Expand Down Expand Up @@ -375,6 +384,7 @@ def compute_terminated(

def update_goal(self, achieved_goal: np.ndarray) -> None:
"""Update goal position if continuing task and within goal radius."""

if (
self.continuing_task
and self.reset_target
Expand Down
1 change: 1 addition & 0 deletions gymnasium_robotics/envs/maze/point_maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def __init__(
render_mode,
reward_type,
continuing_task,
reset_target,
**kwargs,
)

Expand Down

0 comments on commit eceb17e

Please sign in to comment.