- Let's start with importing the necessary libraries, as follows:
import gymimport randomimport numpy as npimport matplotlib.pyplot as pltfrom collections import dequefrom keras.models import Sequentialfrom keras.optimizers import Adamfrom keras.layers import Dense, Flattenfrom keras.layers.convolutional import Conv2Dfrom keras import backend as K
- First, we will plot an example input image of the game:
Figure 11.1: Example input image of Breakout by OpenAI
env = gym.make('BreakoutDeterministic-v4')observation = env.reset()for i in range(3): # The ball is released after 2 frames if i > 1: print(observation.shape) plt.imshow(observation) ...