Chapter 05
Breakout Playground
NotebookPython 34 cells
In [33]python · cell 1
python
%matplotlib inline
import gym
import numpy as np
from matplotlib import pyplot as pltIn [34]python · cell 2
python
env = gym.envs.make("Breakout-v0")Output
[2016-11-16 23:36:18,386] Making new env: Breakout-v0
In [35]python · cell 3
python
print("Action space size: {}".format(env.action_space.n))
print(env.get_action_meanings()) # env.unwrapped.get_action_meanings() for gym 0.8.0 or later
observation = env.reset()
print("Observation space shape: {}".format(observation.shape))
plt.figure()
plt.imshow(env.render(mode='rgb_array'))
[env.step(2) for x in range(1)]
plt.figure()
plt.imshow(env.render(mode='rgb_array'))
env.render(close=True)Output
Action space size: 6 ['NOOP', 'FIRE', 'RIGHT', 'LEFT', 'RIGHTFIRE', 'LEFTFIRE'] Observation space shape: (210, 160, 3)
<matplotlib.figure.Figure at 0x109103630>
<matplotlib.figure.Figure at 0x1092c2470>
In [73]python · cell 4
python
# Check out what a cropped image looks like
plt.imshow(observation[34:-16,:,:])Output
<matplotlib.image.AxesImage at 0x108de7748>
<matplotlib.figure.Figure at 0x10c069f28>
