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: compute_reward for batch input #153

Merged
merged 1 commit into from Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions gymnasium_robotics/envs/maze/maze.py
Expand Up @@ -349,10 +349,11 @@ 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:
d = np.linalg.norm(achieved_goal - desired_goal, axis=-1)
if self.reward_type == "dense":
return np.exp(-np.linalg.norm(desired_goal - achieved_goal))
return np.exp(-d)
elif self.reward_type == "sparse":
return 1.0 if np.linalg.norm(achieved_goal - desired_goal) <= 0.45 else 0.0
return -(d > 0.45).astype(np.float32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

fp64 not fp32


def compute_terminated(
self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info
Expand Down