We will first code the dqn.py file. This requires the following steps:
- Import the necessary packages: We will import the required packages as follows:
import gymimport itertoolsimport numpy as npimport osimport randomimport sysimport matplotlib.pyplot as pltimport tensorflow as tffrom collections import deque, namedtuplefrom model import *from funcs import *
- Set the game and choose the valid actions: We will then set the game. Let's choose the BreakoutDeterministic-v4 game for now, which is a later version of Breakout v0. This game has four actions, numbered zero to three, and they represent 0: no-operation (noop), 1: fire, 2: move left, and 3: move right:
GAME = "BreakoutDeterministic-v4" # "BreakoutDeterministic-v0" ...