/pong_reinforcement_learning

This is the code for the SF Python meetup group tutorial on reinforcement learning

Primary LanguagePython

Overview

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.

Installation on python3

  1. Run python3 -m venv env
  2. Run source env/bin/activate
  3. Run pip install -r requirements.txt

Installation on Anaconda

  1. Install Continuum miniconda (https://conda.io/miniconda.html)
  2. Run conda env create
  3. 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:

Usage

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.

Solutions

Solution code is provided in the solutions folder.

Credits

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.

References