When I call env.reset() on 'SuperMatioBros2-vo', I get an OSError. Here is my code -
## Setting up the game
import gym
from nes_py.wrappers import JoypadSpace
import gym_super_mario_bros
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT, COMPLEX_MOVEMENT
env = gym_super_mario_bros.make('SuperMarioBros2-v0')
env = JoypadSpace(env, COMPLEX_MOVEMENT)
done = True
for step in range(2500):
if done:
state = env.reset()
state, reward, done, info = env.step(env.action_space.sample())
env.render()
env.close()
env.reset()
Here is the error that I have been receiving -
OSError Traceback (most recent call last)
<ipython-input-6-c5672cf456ee> in <module>
----> 1 env.reset()
~anaconda3libsite-packages
es_pywrappersjoypad_space.py in reset(self)
76 def reset(self):
77 """Reset the environment and return the initial observation."""
---> 78 return self.env.reset()
79
80 def get_keys_to_action(self):
~anaconda3libsite-packagesgymwrappersime_limit.py in reset(self, **kwargs)
23 def reset(self, **kwargs):
24 self._elapsed_steps = 0
---> 25 return self.env.reset(**kwargs)
~anaconda3libsite-packages
es_py
es_env.py in reset(self)
256 # reset the emulator
257 if self._has_backup:
--> 258 self._restore()
259 else:
260 _LIB.Reset(self._env)
~anaconda3libsite-packages
es_py
es_env.py in _restore(self)
218 def _restore(self):
219 """Restore the backup state into the NES emulator."""
--> 220 _LIB.Restore(self._env)
221
222 def _will_reset(self):
OSError: exception: access violation reading 0x000000000003C200
However, this issue doesn't seem to arise with the Cartpole environment -
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
if done:
state = env.reset()
env.close()
env.reset()
I am using env.reset() for a different purpose in my code. But this is what I came up with inorder to build a minimum reproducible example.
question from:
https://stackoverflow.com/questions/65890165/openai-gym-env-reset-throwing-oserror 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…