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

Updated Dense Reward for Maze tasks #216

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions gymnasium_robotics/envs/maze/maze.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ def add_xy_position_noise(self, xy_pos: np.ndarray) -> np.ndarray:
def compute_reward(
self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info
) -> float:
distance = np.linalg.norm(achieved_goal - desired_goal, axis=-1)
distance = np.linalg.norm(achieved_goal - desired_goal, ord = 2, axis=-1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was ord=2, added? That is the default behavior anyway

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, wanted to put it out explicitly.

if self.reward_type == "dense":
return np.exp(-distance)
return -distance
elif self.reward_type == "sparse":
return (distance <= 0.45).astype(np.float64)

Expand Down
4 changes: 2 additions & 2 deletions gymnasium_robotics/envs/maze/maze_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ def add_xy_position_noise(self, xy_pos: np.ndarray) -> np.ndarray:
def compute_reward(
self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info
) -> float:
distance = np.linalg.norm(achieved_goal - desired_goal, axis=-1)
distance = np.linalg.norm(achieved_goal - desired_goal, ord = 2, axis=-1)
if self.reward_type == "dense":
return np.exp(-distance)
return -distance
elif self.reward_type == "sparse":
return (distance <= 0.45).astype(np.float64)

Expand Down
Loading