Flappy Bird AI

Evolutionary Neural Network • Game from Scratch • Python & Pygame

Project Overview

In this solo project, I recreated Flappy Bird entirely from scratch using Pygame, then implemented a custom neural network library (no external ML frameworks) that learns to play the game.

Instead of gradient descent or backpropagation, I used an evolutionary approach with mutation. Networks are evaluated based on fitness (game score), the best network is selected, and all others mutate its weights and biases to form the next generation. Over time, networks learn effective flight strategies.

Flappy Bird AI Demo

AI bird learning to play via generations.

Technical Design

Results

Over generations, performance improved significantly: early generations would crash instantly, while later generations consistently survived dozens of pipes. By logging best, worst, and average fitness as well as weight/bias statistics, I visualized learning progress.

Fitness trends

Fitness over generations

Weight trends

Weight statistics during evolution

Future Improvements

Explore the Code

You can view the full source code, training loop, and game implementation on GitHub.

View on GitHub