In this recipe, we will demonstrate how to leverage deep learning models to play games. In our example, we show how to apply a Deep-Q Network for playing breakout with the Keras framework.
Learning to play games with deep reinforcement learning
How to do it...
- Let's start with importing the necessary libraries, as follows:
import gym
import random
import numpy as np
import matplotlib.pyplot as plt
from collections import deque
from keras.models import Sequential
from keras.optimizers import Adam
from keras.layers import Dense, Flatten
from keras.layers.convolutional import Conv2D
from 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...