Skip to content

Using Neuroevolution to create an unbeatable Flappy Bird AI

Notifications You must be signed in to change notification settings

kumudlakara/FlappyBird-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FlappyBird-AI

This project uses NeuroEvolution to play the Flappy Bird game. Neural Networks are evolved using Genetic Algorithm to ultimately become unbeatable at the game.

Requirements

  • Python3.6+
  • NEAT (Neuroevolution of Augemening Topologies)
  • Pygame

How it Works

The game starts off with a generation of 40 birds. Each bird is assigned an initial neural network of its own that governs how the bird performs in the game. The bird only has one action that it can perform and that is "jump". The neural networks focus on making the bird jump at the perfect time. As the game progresses certain birds are eliminated and the best genomes progress further through mutation and combination. This ulitmately gives us birds which are perfect at the game.

A fitness function is defined which penalises the birds that are not successful in passing through the pipes and rewards the ones which pass through the pipes successfully hence promoting the desired behaviour among the species. The fitness function hence is proportional to the score. Using NEAT the neural networks associated with the birds undergo mutation and combination to evolve more efficient and complex neural networks hence ultimately becoming unbeatable.

The Flappy Bird game itself is not too complex of an environment hence setting a generation size of say 100-200 would infact train very quickly because with each genome in the generation we would have pretty much covered all possible behaviours in the game hence improving upon the most favourable behaviour becomes very easy. This approach however cannot be extended to more complex games and environments. For those cases we would have to take a large generation size aswell as train for a good duration before getting favourable results.

Configuration

  • The imgs folder contains the images that have been used to render the Flappy Bird environment
  • The config-feedforward.txt is the config file for NEAT
  • The flappy-bird-main.py contains the main code for the game

All the above files and folders need to be within the same directory and the config-feedforward.txt needs to be linked to the flappy-bird-main.py.

About

Using Neuroevolution to create an unbeatable Flappy Bird AI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages