Skip to content

FlappyBirdAI utilizes NEAT Python to train an AI to master Flappy Bird. Employing genetic algorithms, this project evolves neural networks over generations to improve gameplay performance automatically. Ideal for developers and AI enthusiasts exploring game AI and evolutionary algorithms in Python.

Notifications You must be signed in to change notification settings

Techiral/Flappy-Bird-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlappyBirdAI - Master Flappy Bird with NEAT Python

Flappy Bird in action

GitHub stars GitHub forks GitHub issues GitHub license

Overview

Welcome to FlappyBirdAI, an innovative project utilizing NEAT (NeuroEvolution of Augmenting Topologies) Python to teach an AI how to play Flappy Bird. This repository leverages a genetic algorithm to optimize neural network configurations through successive generations, enhancing the AI's performance over time.

Project Features

  • Genetic Algorithms: Uses NEAT Python for evolutionary learning.
  • Interactive Learning: Watch the AI improve with each generation.
  • Detailed Visualization: Real-time display of AI playing Flappy Bird.

NEAT Python Documentation

Explore the comprehensive documentation for the NEAT module here.

Reference Blog

For an in-depth understanding of how this project works, refer to this blog post by Chris Nielsen.

Video Tutorial

Lakshya from Techiral offers a detailed tutorial on this project. Watch it on YouTube.

Repository Structure

  • CONFIG.txt: Configuration file for NEAT.
  • FB.gif: Animated demonstration of the AI playing Flappy Bird.
  • FBAI.py: Main Python script containing the AI code.
  • README.md: Project documentation.

How to Run the Project

  1. Clone the repository:
    git clone https://github.com/Techiral/Flappy-Bird-AI.git
  2. Navigate to the project directory:
    cd Flappy-Bird-AI
  3. Install the required libraries:
    pip install -r requirements.txt
  4. Run the script:
    python FBAI.py

Code Overview

The core of the project is the FBAI.py script, which uses Pygame for the game's graphical interface and NEAT for the evolutionary algorithm. Here's a brief overview of key components:

Bird Class

Defines the behavior and properties of the bird, including movement, jumping, and drawing.

Pipe Class

Manages the pipes' positions, movements, and collision detection.

Base Class

Handles the moving base at the bottom of the screen.

Main Functions

  • blitRotateCenter: Rotates and blits images centered.
  • draw_window: Draws the game window with the bird, pipes, and base.
  • eval_genomes: Evaluate each generation of genomes.
  • run: Sets up the NEAT configuration and runs the evolutionary process.

Engage with Us

  • Star this repository to show your support.
  • Fork this repository to contribute and enhance the project.
  • Open issues to report bugs or request features.

Stay Connected

Elevate your coding skills by diving into the world of AI and evolutionary algorithms with FlappyBirdAI. Happy coding!

About

FlappyBirdAI utilizes NEAT Python to train an AI to master Flappy Bird. Employing genetic algorithms, this project evolves neural networks over generations to improve gameplay performance automatically. Ideal for developers and AI enthusiasts exploring game AI and evolutionary algorithms in Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages