This is the code for the SF Python meetup group tutorial on reinforcement learning. We will build the game of Pong using Pygame and then build a Deep Q Network using Tensorflow. Then we will train the network to play the game. The DQN is a convolutional neural network that reads in pixel data from the game and the game score.
- Run
python3 -m venv env
- Run
source env/bin/activate
- Run
pip install -r requirements.txt
- Install Continuum miniconda (https://conda.io/miniconda.html)
- Run
conda env create
- Run
source activate pong
This should install all necessary dependencies in a painless way.
NOTE for windows users: you have to edit the environment.yml
and change python version from 3.6 to 3.5. This is because Tensorflow does not offer a windows python 3.6 version.
For manual install, here are the required dependencies and links to install them:
- numpy>=1.7
- pygame>=1.9.3 (https://www.pygame.org/download.shtml)
- tensorflow>=1.0.0 (https://www.tensorflow.org/install/)
Once you've completed the exercises, you can run it like in terminal:
python RL.py
The longer you let it run, the better it will get.
Solution code is provided in the solutions folder.
Code originally developed by malreddysid, updated by llSourcell. We've adapted it to TF 1.0, Anaconda python, removed OpenCV dependency and adapted it to be used for an exercise.