You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Therefore, reset() should (in the typical use case) be called with a seed right after initialization and then never again.
This implies that the reset with a seed, followed by a reset without a seed, must be deterministic.
However, when an environment does not respect this rule, the environment checker does not fail.
Code example
importgymnasiumasgymfromgymnasium.utils.env_checkerimportcheck_envimportrandomclassMyEnv(gym.Env):
def__init__(self):
super().__init__()
self.observation_space=gym.spaces.Discrete(5)
self.action_space=gym.spaces.Discrete(5)
defreset(self, seed=None, options=None):
super().reset(seed=seed)
ifseedisnotNone:
obs=self.np_random.integers(5)
else:
# generate a random observations, but not based on the inner rng -> bad => non deterministicobs=int(random.random() *5)
returnobs, {}
defstep(self, action):
obs=self.np_random.integers(5)
returnobs, 0, False, False, {}
register=gym.register(
id="MyEnv-v0",
entry_point=MyEnv,
max_episode_steps=1000,
)
check_env(gym.make("MyEnv-v0")) # Passes but:env=gym.make("MyEnv-v0")
env.reset(seed=0)
obs1, _=env.reset()
env.reset(seed=0)
obs2, _=env.reset()
assertobs1==obs2# Fails
qgallouedec
changed the title
[Bug Report] Bug title
[Bug Report] The env checker does not detect when the environment is not deterministic after the first reset.
Jun 13, 2024
Good point, currently the env_checker is relatively minimal on its determinism testing.
If you want to make a PR that beefs up the step and reset determinism testing then I would happily add it
Describe the bug
From the doc
This implies that the reset with a seed, followed by a reset without a seed, must be deterministic.
However, when an environment does not respect this rule, the environment checker does not fail.
Code example
System info
gymnasium 0.29.1 (also tested with 1.0.0a2)
MacOS
Additional context
Context: realized panda-gym was in the case described above: qgallouedec/panda-gym#94
Checklist
The text was updated successfully, but these errors were encountered: