Implementing the Space Invaders gaming bot
In this section, we will be coding the Space Invaders game using DQN and Q-learning. For coding, we will be using the gym
, TensorFlow
, and virtualenv
libraries. You can refer to the entire code by using this GitHub link: https://github.com/jalajthanaki/SpaceInvaders_gamingbot.
We are using a convolutional neural network (CNN). Here, we have defined the CNN in a separate file. The name of this file is convnet.py
. Take a look at the following screenshot: at the following figure:

Figure 11.16: Code snippet for Convnrt.py
You can refer to the code using this GitHub link: https://github.com/jalajthanaki/SpaceInvaders_gamingbot/blob/master/convnet.py ...
Get Machine Learning Solutions now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.