flappy.bird.AI.mp4
This repository contains a Flappy Bird game simulation where the bird is controlled by neural networks evolved using the NEAT (NeuroEvolution of Augmenting Topologies) algorithm. The objective is to evolve AI agents to master the game and achieve high scores.
In this project, we use NEAT to train neural networks that play Flappy Bird. The neural networks are evolved over multiple generations to improve their performance in navigating through pipes.
- Neural Network Training: Utilizes NEAT to evolve neural networks.
- Flappy Bird Simulation: Classic Flappy Bird game implemented with Pygame.
- Dynamic Difficulty: Increasing difficulty as the game progresses.
- Interactive Visualization: Real-time display of neural network performance.
- Python 3.x
- Pygame
- NEAT-Python
- Clone the Repository: git clone https://github.com/Hamadabcn/flappy-birdAI.git
- cd flappy-birdAI
- Install Dependencies: pip install pygame neat-python
The NEAT algorithm's behavior is controlled via the config.txt file. This file contains parameters that influence the training process, including fitness criteria, population size, and mutation rates.
- fitness_criterion: Criterion for evaluating fitness (max).
- fitness_threshold: Threshold for fitness to reach (100).
- pop_size: Population size (15).
- reset_on_extinction: Whether to reset on extinction (False).
- activation_default: Default activation function (tanh).
- num_inputs: Number of input nodes (3).
- num_outputs: Number of output nodes (1).
- compatibility_threshold: Threshold for species compatibility (3.0).
- species_fitness_func: Fitness function for species (max).
- max_stagnation: Maximum stagnation allowed (20).
- elitism: Number of elite genomes to keep (2).
- survival_threshold: Threshold for genome survival (0.2).
To start the simulation and train the neural networks:
- Ensure you are in the project directory.
- Run the main script: python main.py This will initialize the NEAT algorithm, start the Flappy Bird simulation, and evolve the neural networks over generations.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please submit a pull request or open an issue to suggest improvements.