Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Fix] Correct assertions in Maze environment reset #179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading