Skip to content

Latest commit

 

History

History
78 lines (61 loc) · 3.56 KB

README.md

File metadata and controls

78 lines (61 loc) · 3.56 KB

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!