Skip to content

Commit

Permalink
Ensure correct seeding behaviour. Using the self.np_random rather tha…
Browse files Browse the repository at this point in the history
…n the np.random. This makes sure:

1. Deterministic env resetting.
2. Different seeds for envs running in parallel, e.g. Vector Env of gymnasium.
  • Loading branch information
BruceGeLi committed Mar 16, 2024
1 parent c822f28 commit 5c80e3d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions metaworld/envs/mujoco/sawyer_xyz/sawyer_xyz_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,10 @@ def evaluate_state(self, obs, action):
raise NotImplementedError

def reset(self, seed=None, options=None):
if seed:
self.seed(seed)
self.curr_path_length = 0
obs, info = super().reset()
obs, info = super().reset(seed=seed)
self._prev_obs = obs[:18].copy()
obs[18:36] = self._prev_obs
obs = np.float64(obs)
Expand All @@ -544,7 +546,7 @@ def _get_state_rand_vec(self):
assert self._last_rand_vec is not None
return self._last_rand_vec
else:
rand_vec = np.random.uniform(
rand_vec = self.np_random.uniform(
self._random_reset_space.low,
self._random_reset_space.high,
size=self._random_reset_space.low.size,
Expand Down

0 comments on commit 5c80e3d

Please sign in to comment.