Game Speed

See the about section for more details.


Press S to download the AI's Tensorflow model

Move the slider to adjust the game speed

About

This AI was trained using N.E.A.T. This is a genetic algorithm that trains the AI by creating generations of agents and simulating them in a environment. Each bird has a Neural Network that will decide to make the bird flap based on its inputs. The birds with the best Neural Networks are selected for the next generation and slightly mutated to create new behavior.

This project was made using P5js to render the game and TensorFlow js to create the Neural Networks.

p5js logo tensorflow logo

The code for this project can be found Here.

Neural Network

Each bird has a Neural network that determines whether to flap or not. This network is a sequential model made up of three dense layers. An input layer with 5 neurons, a hidden layer with 8 neurons and a output layer with 2 neurons.

The five inputs the bird receives are:

  1. The Birds Y position
  2. The Birds velocity
  3. The Birds distance from the pipe
  4. The Y position of the top pipe
  5. The Y position of the bottom pipe

The output layer has a softmax activation and will return two values that will add up to one. The bird will flap if the first value is greater than the second and will not if the opposite is true.

Training Process

The training process for this AI involves:

  1. Create an initial population of N Birds with neural networks containing random weights
  2. Simulate the population in the environment until all birds have died.
  3. Create the next generation with the best preforming bird's Neural networks.
  4. Mutate a small portion of weights in each birds Neural network (E.g. 10%)with random values to create new behaviors.
  5. Repeat steps 2 - 4 until birds can successfully navigate the environment.