Skip to content

Instantly share code, notes, and snippets.

@thomelane
Created September 11, 2018 00:40
Show Gist options
  • Save thomelane/79e97630ba46c45985a946cae4805885 to your computer and use it in GitHub Desktop.
Save thomelane/79e97630ba46c45985a946cae4805885 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)
@ysig
Copy link

ysig commented Jan 5, 2020

This is really slow in comparison with the default rendering technique. Also in my case (Windows 10 anaconda) it also opens an ipykernel_launcher

@kidJDOG
Copy link

kidJDOG commented Jul 2, 2020

This code gives me 'int' object is not subscriptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment