-
-
Save soroushmehr/74b3777ef330397ec57e5076558183d6 to your computer and use it in GitHub Desktop.
OpenAI Gym render in Jupyter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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