nicknochnack / KerasRL-OpenAI-Atari-SpaceInvadersv0

A notebook walking through how to use Keras RL to solve Atari environments.
23 stars 39 forks source link

Invalid render mode `None`. Supported modes: `human`, `rgb_array`. #3

Open RezJr opened 1 year ago

RezJr commented 1 year ago

episodes = 5 for episode in range(1, episodes+1): state = env.reset() done = False score = 0

while not done:
    env.render()
    action = random.choice([0,1,2,3,4,5])
    n_state, reward, done, info = env.step(action)
    score+=reward
print('Episode:{} Score:{}'.format(episode, score))

env.close()

:: --------------------------------------------------------------------------- Error Traceback (most recent call last) Cell In[5], line 8 5 score = 0 7 while not done: ----> 8 env.render() 9 action = random.choice([0,1,2,3,4,5]) 10 n_state, reward, done, info = env.step(action)

File ~\anaconda3\lib\site-packages\gym\wrappers\order_enforcing.py:51, in OrderEnforcing.render(self, *args, *kwargs) 46 if not self._disable_render_order_enforcing and not self._has_reset: 47 raise ResetNeeded( 48 "Cannot call env.render() before calling env.reset(), if this is a intended action, " 49 "set disable_render_order_enforcing=True on the OrderEnforcer wrapper." 50 ) ---> 51 return self.env.render(args, **kwargs)

File ~\anaconda3\lib\site-packages\gym\wrappers\env_checker.py:55, in PassiveEnvChecker.render(self, *args, kwargs) 53 return env_render_passive_checker(self.env, *args, *kwargs) 54 else: ---> 55 return self.env.render(args, kwargs)

File ~\anaconda3\lib\site-packages\ale_py\env\gym.py:302, in AtariEnv.render(self) 300 pass 301 else: --> 302 raise error.Error( 303 f"Invalid render mode {self._render_mode}. " 304 "Supported modes: human, rgb_array." 305 )

Error: Invalid render mode None. Supported modes: human, rgb_array.