Skip to content

A flappy bird game on Unity played by an AI using a simple neural network and a genetic algorithm

License

Notifications You must be signed in to change notification settings

Okaerikoto/FlappyBirdAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlappyBirdAi

A flappy bird game on Unity played by an AI using a simple neural network and a genetic algorithm

screen capture

Requirements

Tested on Unity 2018.3.0f2

Detailed description

When executed, the game trains birds to play the flappy bird game.

Each bird owns a fully connected neural network with two input neurons, one hidden layer of 6 neurons and 1 input neuron. The 2 input neurons are respectively the x and y distance of the bird to the next pipes gap center. If the output neuron is positive, then the bird flaps.
Each bird has a score, which is proportional to the time it stayed alive. A bird dies if it gets out of the game screen.

The birds neural network is trained thanks to a genetic algorithm as follow. The first generation of 10 birds gets neural networks initialized with random weights. Once they are all dead, we generate a new generation of 10 birds, that inherits the weights of the bird of the previous generation who got the highest score, with random offsets on some weights. This process is repeated until one bird can play the game without dying.

The demo can be seen in ./pictures/Demo.mp4

Note

This work was inspired by this page.

About

A flappy bird game on Unity played by an AI using a simple neural network and a genetic algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages