Flappy Bird played by a NEAT (NeuroEvolution of Augmenting Topologies) neural network. Birds learn to navigate pipes through evolutionary reinforcement over generations.
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.1per frame survived+5for passing a pipe-1for 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%.
- Python 3.8+
- Pygame
- NEAT-Python
pip install -r requirements.txtpython flappy.pyNote: 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.
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 |
This project has no test suite. Run the game and observe the NEAT training output in the console to verify it works.