This project implements an AI to play the Flappy Bird game using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm. The AI learns to navigate between pipes and achieve higher scores through evolution over generations.
- Showcase
- Motivation
- Project Structure
- Requirements
- Installation
- Usage
- Game Elements
- NEAT Algorithm Overview
- License
- Acknowledgements
This project was created as an exploration of the NEAT algorithm and its applications in reinforcement learning.
- .gitattributes: Configuration file for Git attributes.
- LICENSE: MIT License for the project.
- README.md: This file.
- media/: Directory containing media files such as images and models.
- models/: Directory containing trained models and fitness graphs.
- Project/: Main project directory containing the game and AI implementation.
- neat_run.py: Script to run the NEAT algorithm and train the AI.
- neat.config.txt: Configuration file for the NEAT algorithm.
- run.py: Script to run the Flappy Bird game manually.
- visualize.py: Script to visualize training progress with graphs.
- assets/: Directory containing game assets like images and audio.
- game/: Directory containing game logic and classes.
- Python 3.8.1 or above
- Pygame
- NEAT-Python
- Matplotlib
- Clone the repository:
git clone https://github.com/yourusername/flappy-bird-ai.git
cd flappy-bird-ai- Install the required packages:
pip install pygame neat-python matplotlibTo run the Flappy Bird game manually:
python run.pyTo train the AI using the NEAT algorithm:
python neat_run.pyWhen the training is completed, the best model will be saved in the models/ directory.
To generate graphs showing training progress:
python visualize.pyThe graphs are saved in the models/ directory.
Responsible for the bird's movement, jumping, and collision detection.
Controls the pipes' movement and handles collisions with the bird.
Manages the moving base at the bottom of the screen.
Tracks and renders the score on the screen.
NEAT (NeuroEvolution of Augmenting Topologies) is a powerful AI algorithm that evolves neural networks using reinforcement learning. The process involves:
- Creating an initial population of birds, each with a unique genome and neural network.
- Evaluating birds based on survival time and pipe passages.
- Selecting top-performing birds, breeding them, and applying mutations.
- Repeating over generations to improve performance.
For more information, see the NEAT documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
- The
NEAT-Pythonlibrary for implementing the NEAT algorithm. - The
Pygamelibrary for creating the game. - The original Flappy Bird game for inspiration.
