A neural network for Flappy Bird using reinforcement learning
This is my very first start at trying out any sort of machine learning or artificial intelligence. I am following Bluefever Software's tutorial which can be found here. His repo can be found here.
- Clone this repository:
$ git clone https://github.com/LV/FlappyBirdAI
- Go into the project directory and install the required packages:
$ pip3 install -r requirements.txt
- Run the program
$ python3 src/main.py
The premise of this game is to survive for as long as possible. Press space to jump. Press esc to quit the game.
There are two branches of the repository, master and no-ai. The no-ai branch is version of the game you can play where as the master branch will be where all the reinforcement learning will take place.
The neural network consists of two different inputs, five hidden layers, and one single output as demonstrated by the diagram below:
- Input 1 (i1) will consist of the distance (in pixels) to the end of the nearest upcoming pair of pipes.
- Input 2 (i2) will consist of the height between the bird and the middle of the upcoming pipe pair gaps.
The inputs are demonstrated by the following photo:
The following diagram demonstrates how the neural network works (the actual program uses 5 hidden layers instead of 3):