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

Fix lunar lander determinism #979

Merged
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
9 changes: 8 additions & 1 deletion gymnasium/envs/box2d/lunar_lander.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ class LunarLander(gym.Env, EzPickle):
The recommended value for `turbulence_power` is between 0.0 and 2.0.

## Version History
- v3: Reset wind and turbulence offset (`C`) whenever the environment is reset to ensure statistical independence between consecutive episodes (related [GitHub issue](https://github.com/Farama-Foundation/Gymnasium/issues/954)).
- v3: Reset wind and turbulence offset (`C`) whenever the environment is reset to ensure statistical independence
between consecutive episodes (related [GitHub issue](https://github.com/Farama-Foundation/Gymnasium/issues/954)).
Fix non-deterministic behaviour due to not fully destroying the world (related [GitHub issue](https://github.com/Farama-Foundation/Gymnasium/issues/728)).
- v2: Count energy spent and in v0.24, added turbulence with wind power and turbulence_power parameters
- v1: Legs contact with ground added in state vector; contact with ground give +10 reward points,
and -10 if then lose contact; reward renormalized to 200; harder initial random push.
Expand Down Expand Up @@ -328,6 +330,11 @@ def reset(
):
super().reset(seed=seed)
self._destroy()

# Bug's workaround for: https://github.com/Farama-Foundation/Gymnasium/issues/728
# Not sure why the self._destroy() is not enough to clean(reset) the total world environment elements, need more investigation on the root cause,
# we must create a totally new world for self.reset(), or the bug#728 will happen
self.world = Box2D.b2World(gravity=(0, self.gravity))
self.world.contactListener_keepref = ContactDetector(self)
self.world.contactListener = self.world.contactListener_keepref
self.game_over = False
Expand Down
Loading