Skip to content

Commit

Permalink
workaround openai/gym3#8
Browse files Browse the repository at this point in the history
  • Loading branch information
epignatelli committed Jan 11, 2023
1 parent 3295547 commit 4698066
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion helx/environment/gym.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,20 @@ def state(self) -> Array:
return self._current_observation

def reset(self, seed: int | None = None) -> Timestep:
obs, _ = self._env.reset(seed=seed)
try:
obs, _ = self._env.reset(seed=seed)
except TypeError:
# TODO(epignatelli): remove try/except when gym3 is updated.
# see: https://github.com/openai/gym3/issues/8
obs, _ = self._env.reset()
self._current_observation = jnp.asarray(obs)
return Timestep(obs, None, StepType.TRANSITION)

def step(self, action: Action) -> Timestep:
action_ = np.asarray(action)
next_step = self._env.step(action_)
self._current_observation = jnp.asarray(next_step[0])
gym.core.ObsType
return Timestep.from_gym(next_step)

def seed(self, seed: int) -> None:
Expand Down

0 comments on commit 4698066

Please sign in to comment.