Skip to content

Commit

Permalink
fix goal and reset options to i,j (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: rodrigodelazcano <[email protected]>
  • Loading branch information
rodrigodelazcano and rodrigodelazcano authored Sep 16, 2023
1 parent c4be8b5 commit a966c67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
14 changes: 7 additions & 7 deletions gymnasium_robotics/envs/maze/maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ def reset(
else:
if "goal_cell" in options and options["goal_cell"] is not None:
# assert that goal cell is valid
assert self.maze.map_length > options["goal_cell"][1]
assert self.maze.map_width > options["goal_cell"][0]
assert self.maze.map_length > options["goal_cell"][0]
assert self.maze.map_width > options["goal_cell"][1]
assert (
self.maze.maze_map[options["goal_cell"][1]][options["goal_cell"][0]]
self.maze.maze_map[options["goal_cell"][0]][options["goal_cell"][1]]
!= 1
), f"Goal can't be placed in a wall cell, {options['goal_cell']}"

Expand All @@ -231,11 +231,11 @@ def reset(

if "reset_cell" in options and options["reset_cell"] is not None:
# assert that goal cell is valid
assert self.maze.map_length > options["reset_cell"][1]
assert self.maze.map_width > options["reset_cell"][0]
assert self.maze.map_length > options["reset_cell"][0]
assert self.maze.map_width > options["reset_cell"][1]
assert (
self.maze.maze_map[options["reset_cell"][1]][
options["reset_cell"][0]
self.maze.maze_map[options["reset_cell"][0]][
options["reset_cell"][1]
]
!= 1
), f"Reset can't be placed in a wall cell, {options['reset_cell']}"
Expand Down
20 changes: 13 additions & 7 deletions gymnasium_robotics/envs/maze/maze_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ def reset(
seed: Optional[int] = None,
options: Optional[Dict[str, Optional[np.ndarray]]] = None,
):
"""Reset the maze simulation.
Args:
options (dict[str, np.ndarray]): the options dictionary can contain two items, "goal_cell" and "reset_cell" that will set the initial goal and reset location (i,j) in the self.maze.map list of list maze structure.
"""
super().reset(seed=seed)

if options is None:
Expand All @@ -303,10 +309,10 @@ def reset(
else:
if "goal_cell" in options and options["goal_cell"] is not None:
# assert that goal cell is valid
assert self.maze.map_length > options["goal_cell"][1]
assert self.maze.map_width > options["goal_cell"][0]
assert self.maze.map_length > options["goal_cell"][0]
assert self.maze.map_width > options["goal_cell"][1]
assert (
self.maze.maze_map[options["goal_cell"][1]][options["goal_cell"][0]]
self.maze.maze_map[options["goal_cell"][0]][options["goal_cell"][1]]
!= 1
), f"Goal can't be placed in a wall cell, {options['goal_cell']}"

Expand All @@ -320,11 +326,11 @@ def reset(

if "reset_cell" in options and options["reset_cell"] is not None:
# assert that goal cell is valid
assert self.maze.map_length > options["reset_cell"][1]
assert self.maze.map_width > options["reset_cell"][0]
assert self.maze.map_length > options["reset_cell"][0]
assert self.maze.map_width > options["reset_cell"][1]
assert (
self.maze.maze_map[options["reset_cell"][1]][
options["reset_cell"][0]
self.maze.maze_map[options["reset_cell"][0]][
options["reset_cell"][1]
]
!= 1
), f"Reset can't be placed in a wall cell, {options['reset_cell']}"
Expand Down

0 comments on commit a966c67

Please sign in to comment.