Starting the project
After this long detour into reinforcement learning and the DQN approach, we are finally ready to start coding, having all the basic understanding of how to operate an OpenAI Gym environment and how to set a DQN approximation of a Q function. We simply start importing all the necessary packages:
import gym
from gym import wrappers
import numpy as np
import random, tempfile, os
from collections import deque
import tensorflow as tf
The tempfile
module generates temporary files and directories that can be used as a temporary storage area for data files. The deque
command, from the collections
module, creates a double-ended queue, practically a list where you can append items at the start or at the end. Interestingly, it can be set to a predefined size. When full, older items are discarded in order to make the place for new entries.
We will structure this project using a series of classes representing the agent, the agent's brain (our DQN), the agent's memory, and the environment...