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:
You can refer to the code using this GitHub link: https://github.com/jalajthanaki/SpaceInvaders_gamingbot/blob/master/convnet.py.
We are defining the DQN algorithm in the dqn.py
script. You can refer to the code snippet shown in the following screenshot:
For training, we have defined our training logic in train.py
. You can refer to the code snippet shown in the following screenshot: