Fix Atari wrapper bug: tried to step environment that needs reset (#1297)

* fix 1060

* update changelog
This commit is contained in:
Quentin Gallouédec 2023-01-26 00:31:20 +01:00 committed by GitHub
parent b702884c23
commit 637988c9cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -23,6 +23,7 @@ New Features:
Bug Fixes: Bug Fixes:
^^^^^^^^^^ ^^^^^^^^^^
- Fixed Atari wrapper that missed the reset condition (@luizapozzobon)
Deprecations: Deprecations:
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
@ -1218,4 +1219,4 @@ And all the contributors:
@Gregwar @ycheng517 @quantitative-technologies @bcollazo @git-thor @TibiGG @cool-RR @MWeltevrede @Gregwar @ycheng517 @quantitative-technologies @bcollazo @git-thor @TibiGG @cool-RR @MWeltevrede
@Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875 @yuanmingqi @Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875 @yuanmingqi
@anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong @anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong
@DavyMorgan @DavyMorgan @luizapozzobon

View file

@ -106,7 +106,13 @@ class EpisodicLifeEnv(gym.Wrapper):
obs = self.env.reset(**kwargs) obs = self.env.reset(**kwargs)
else: else:
# no-op step to advance from terminal/lost life state # no-op step to advance from terminal/lost life state
obs, _, _, _ = self.env.step(0) obs, _, done, _ = self.env.step(0)
# The no-op step can lead to a game over, so we need to check it again
# to see if we should reset the environment and avoid the
# monitor.py `RuntimeError: Tried to step environment that needs reset`
if done:
obs = self.env.reset(**kwargs)
self.lives = self.env.unwrapped.ale.lives() self.lives = self.env.unwrapped.ale.lives()
return obs return obs
@ -150,9 +156,6 @@ class MaxAndSkipEnv(gym.Wrapper):
return max_frame, total_reward, done, info return max_frame, total_reward, done, info
def reset(self, **kwargs) -> GymObs:
return self.env.reset(**kwargs)
class ClipRewardEnv(gym.RewardWrapper): class ClipRewardEnv(gym.RewardWrapper):
""" """