This project implements an artificial intelligence that learns to play Flappy Bird using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm. The AI starts with no knowledge of the game and evolves through generations to develop optimal strategies for navigating through pipes.
- 🐦 NEAT-based neural network evolution
- 🎮 Pygame visualization of the learning process
- 📊 Real-time statistics display (generation count, alive birds, score)
- 🧠 Configurable neural network parameters
- 📈 Fitness tracking and visualization
- Python 3.x
- Pygame
- NEAT-Python
- Graphviz (for network visualization)
- Matplotlib (for statistics plotting)
The NEAT algorithm parameters can be adjusted in the config-feedforward.txt file. Key parameters include:
- Population size
- Mutation rates
- Activation functions
- Network topology settings
- The algorithm starts with a population of birds with random neural networks.
- Each bird plays the game, with its neural network making jump decisions based on:
- Current y-position
- Distance to top pipe
- Distance to bottom pipe
- Birds are rewarded for staying alive and passing pipes.
- The best-performing birds are selected for reproduction.
- The process repeats for multiple generations, with networks improving over time.
The AI typically learns to play effectively within 10-20 generations, achieving scores of 50+ consistently.
flappy_bird.py: Main game and NEAT implementationconfig-feedforward.txt: NEAT configurationvisualize.py: Visualization utilitiesimgs/: Game assets folder
- NEAT-Python library
- Flappy Bird game concept
- Pygame community