Skip to content

Instantly share code, notes, and snippets.

@soroushmehr
Forked from thomelane/jupyter_gym_render.py
Created July 25, 2019 17:26
Show Gist options
  • Select an option

  • Save soroushmehr/74b3777ef330397ec57e5076558183d6 to your computer and use it in GitHub Desktop.

Select an option

Save soroushmehr/74b3777ef330397ec57e5076558183d6 to your computer and use it in GitHub Desktop.
OpenAI Gym render in Jupyter
import gym
from IPython import display
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
env = gym.make('Breakout-v0')
env.reset()
img = plt.imshow(env.render(mode='rgb_array')) # only call this once
for _ in range(100):
img.set_data(env.render(mode='rgb_array')) # just update the data
display.display(plt.gcf())
display.clear_output(wait=True)
action = env.action_space.sample()
env.step(action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment