Skip to content

Aaronschristo/FlappyAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlappyAI

Flappy Bird played by a NEAT (NeuroEvolution of Augmenting Topologies) neural network. Birds learn to navigate pipes through evolutionary reinforcement over generations.

How It Works

A population of 100 birds is spawned each generation. Each bird is controlled by a feed-forward neural network with 3 inputs and 1 output:

Input Description
y Bird's current vertical position
abs(y - pipe_y) Vertical distance to the next bottom pipe
abs(y - upPipe_y) Vertical distance to the next top pipe

If the output is > 0, the bird jumps.

Fitness scoring:

  • +0.1 per frame survived
  • +5 for passing a pipe
  • -1 for dying

The NEAT algorithm evolves the network topology and weights over 50 generations, keeping the top 2 genomes each generation (elitism) and discarding the bottom 80%.

Requirements

Setup

pip install -r requirements.txt

Running

python flappy.py

Note: The game requires graphics and audio assets (graphics/ and audio/ directories with sprite sheets and sound effects) that are not included in this repository. Without them, the game will crash on launch. You'll need to provide your own Flappy Bird-style assets or download them from a free sprite resource.

Configuration

NEAT parameters are in config-feedforward. Key settings:

Parameter Value Description
pop_size 100 Birds per generation
num_inputs 3 Neural network inputs
num_outputs 1 Neural network output
fitness_threshold 1,000,000 Stops early if reached
elitism 2 Top genomes preserved each generation
survival_threshold 0.2 Bottom 80% are killed

Testing

This project has no test suite. Run the game and observe the NEAT training output in the console to verify it works.

About

self learning flappy bird AI using NEAT-Python

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages