Evolutionary Neural Network • Game from Scratch • Python & Pygame
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.
AI bird learning to play via generations.
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 over generations
Weight statistics during evolution
You can view the full source code, training loop, and game implementation on GitHub.
View on GitHub