explaingit

yenchenlin/deeplearningflappybird

6,798PythonAudience · researcherComplexity · 3/5Setup · moderate

TLDR

A Python project that trains an AI to play Flappy Bird from scratch using deep reinforcement learning, watching raw pixel input and learning purely through trial and error with no hand-written rules.

Mindmap

mindmap
  root((Flappy Bird AI))
    What it does
      AI learns from pixels
      Deep Q-Learning
      Trial and error training
    Tech Stack
      Python
      TensorFlow 0.7
      pygame
      OpenCV
    Use Cases
      Learn reinforcement learning
      Watch trained AI play
      Experiment with networks
    Audience
      AI learners
      Researchers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Learn how deep Q-learning works by running this hands-on Flappy Bird training experiment

USE CASE 2

Watch a pre-trained AI play Flappy Bird using the included checkpoints without waiting for training to finish

USE CASE 3

Adapt the neural network architecture or training parameters to experiment with reinforcement learning concepts

USE CASE 4

Use this as a starting template to apply deep Q-learning to a different simple game environment

Tech stack

PythonTensorFlowpygameOpenCV

Getting it running

Difficulty · moderate Time to first run · 30min

Requires TensorFlow 0.7, which is very old, use a Python virtual environment with a compatible version.

In plain English

This project teaches a computer to play Flappy Bird on its own, without any hand-written rules. Instead of telling the program what to do, it lets the AI figure out the game by trial and error, watching raw pixels on the screen and learning from experience. The core idea is called Deep Q-Learning. The program uses a type of neural network, similar to how image-recognition software works, to look at the game screen and decide whether to flap or do nothing. Every time it takes an action, it remembers what happened: the screen before, what it did, the score change, and the screen after. It stores thousands of these memories and trains on random batches of them repeatedly, gradually improving its judgment about which action leads to a better outcome. To get the network to start learning something useful, the project first runs the game for 10,000 steps with completely random actions, just to fill up the memory bank before any real training begins. After that, the AI slowly shifts from random choices toward what it has learned, reducing its randomness from about 10% down to nearly zero over three million game frames. The game screen is preprocessed before feeding it into the network: each frame is converted to grayscale, shrunk to 80 by 80 pixels, and four consecutive frames are stacked together so the network can sense motion. The network itself has three convolutional layers for detecting visual patterns, followed by a fully connected layer with 256 nodes, and a final output that scores each possible action. Running it requires Python, TensorFlow 0.7, pygame, and OpenCV. After cloning the repository, a single command starts training from scratch. Pre-trained checkpoints are included so you can also watch a trained bird play immediately without waiting for training to finish. The project is based on a published DeepMind paper on playing Atari games, adapted here specifically for Flappy Bird.

Copy-paste prompts

Prompt 1
I cloned deeplearningflappybird. Walk me through what happens during the 10,000 random-action warmup phase and why it is necessary for deep Q-learning.
Prompt 2
Help me modify the deeplearningflappybird convolutional network architecture and observe how the change affects training speed.
Prompt 3
I want to load the pre-trained checkpoint in deeplearningflappybird and watch the AI play. Show me the exact command and explain what the network learned.
Prompt 4
Adapt the deeplearningflappybird code to train an AI on Pong instead of Flappy Bird, replacing the game environment.
Open on GitHub → Explain another repo

← yenchenlin on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.