# devgabrielluiz/flappybird architecture

> Architecture diagram of the GitHub repository devgabrielluiz/flappybird, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devgabrielluiz/flappybird
- Repository: https://github.com/devgabrielluiz/flappybird

## Overview

This repository is a Pygame Flappy Bird game with two runnable modes: manual keyboard play and NEAT-driven autonomous play. Each script contains its own game loop and game entities; the AI version additionally scores genomes, obtains pipe-relative inputs, and runs population evolution. The graph separates shared game mechanics, gameplay orchestration, and AI evolution. Edges are limited to relationships visible in the excerpts or README; image assets are shown as inputs, while NEAT and Pygame are external dependencies.

Main entry points: [`FlappyBird_with_IA.py`](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py) (AI game loop), [`FlappyBird.py`](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py) (Manual game loop), [`imgs`](https://github.com/devgabrielluiz/flappybird/tree/main/imgs) (Game images), [`configIA.txt`](https://github.com/devgabrielluiz/flappybird/blob/main/configIA.txt) (NEAT configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_manual["Manual Game"]
  node_manual_loop["Manual game loop<br/>[FlappyBird.py]"]
end

subgraph group_mechanics["Game Mechanics"]
  node_manual_bird["Bird physics<br/>[FlappyBird.py]"]
  node_manual_pipe["Pipe and collision<br/>[FlappyBird.py]"]
  node_manual_ground["Scrolling ground<br/>[FlappyBird.py]"]
  node_manual_render["Game rendering<br/>[FlappyBird.py]"]
  node_ai_bird["Bird physics"]
  node_ai_pipe["Pipe and collision"]
  node_ai_ground["Scrolling ground"]
  node_ai_render["Game rendering"]
end

subgraph group_evolution["NEAT Learning"]
  node_ai_loop["AI game loop"]
  node_ai_network["Network decisions"]
  node_evolution_runner["Population evolution"]
  node_config["NEAT configuration<br/>[configIA.txt]"]
end

node_player(("Player"))
node_pygame["Pygame"]
node_neat["NEAT library"]
node_assets["Game images"]

node_player -->|"presses keys"| node_manual_loop
node_manual_loop -->|"moves"| node_manual_bird
node_manual_loop -->|"checks collisions"| node_manual_pipe
node_manual_loop -->|"moves"| node_manual_ground
node_manual_loop -->|"draws frame"| node_manual_render
node_manual_bird -->|"provides mask"| node_manual_pipe
node_manual_loop -->|"uses"| node_pygame
node_manual_loop -->|"loads"| node_assets
node_ai_loop -->|"moves"| node_ai_bird
node_ai_loop -->|"checks collisions"| node_ai_pipe
node_ai_loop -->|"moves"| node_ai_ground
node_ai_loop -->|"draws frame"| node_ai_render
node_ai_loop -->|"activates"| node_ai_network
node_ai_bird -->|"provides mask"| node_ai_pipe
node_ai_loop -->|"uses"| node_pygame
node_ai_loop -->|"loads"| node_assets
node_evolution_runner -->|"runs fitness"| node_ai_loop
node_evolution_runner -->|"configures population"| node_neat
node_evolution_runner -->|"loads"| node_config
node_ai_network -->|"creates network"| node_neat
node_ai_loop -->|"updates fitness"| node_evolution_runner

click node_assets "https://github.com/devgabrielluiz/flappybird/tree/main/imgs"
click node_manual_loop "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py"
click node_manual_bird "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py"
click node_manual_pipe "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py"
click node_manual_ground "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py"
click node_manual_render "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py"
click node_ai_loop "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_ai_bird "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_ai_pipe "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_ai_ground "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_ai_render "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_ai_network "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_evolution_runner "https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py"
click node_config "https://github.com/devgabrielluiz/flappybird/blob/main/configIA.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manual_loop toneBlue
class node_manual_bird,node_manual_pipe,node_manual_ground,node_manual_render,node_ai_bird,node_ai_pipe,node_ai_ground,node_ai_render toneAmber
class node_ai_loop,node_ai_network,node_evolution_runner,node_config toneMint
class node_player,node_pygame,node_neat toneIndigo
class node_assets toneTeal
```

## Components

### Manual Game

- [Manual game loop](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py): `FlappyBird.py`

### Game Mechanics

- [Bird physics](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py): `FlappyBird.py`
- [Pipe and collision](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py): `FlappyBird.py`
- [Scrolling ground](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py): `FlappyBird.py`
- [Game rendering](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird.py): `FlappyBird.py`
- [Bird physics](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [Pipe and collision](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [Scrolling ground](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [Game rendering](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`

### NEAT Learning

- [AI game loop](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [Network decisions](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [Population evolution](https://github.com/devgabrielluiz/flappybird/blob/main/FlappyBird_with_IA.py): `FlappyBird_with_IA.py`
- [NEAT configuration](https://github.com/devgabrielluiz/flappybird/blob/main/configIA.txt): `configIA.txt`

### Other components

- **Player**
- **Pygame**
- **NEAT library**
- [Game images](https://github.com/devgabrielluiz/flappybird/tree/main/imgs): `imgs`

## Connections

- Player → Manual game loop: presses keys (evidence: `FlappyBird.py`)
- Manual game loop → Bird physics: moves (evidence: `FlappyBird.py`)
- Manual game loop → Pipe and collision: checks collisions (evidence: `FlappyBird.py`)
- Manual game loop → Scrolling ground: moves (evidence: `FlappyBird.py`)
- Manual game loop → Game rendering: draws frame (evidence: `FlappyBird.py`)
- Bird physics → Pipe and collision: provides mask (evidence: `FlappyBird.py`)
- Manual game loop → Pygame: uses (evidence: `FlappyBird.py`)
- Manual game loop → Game images: loads (evidence: `FlappyBird.py`)
- AI game loop → Bird physics: moves (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Pipe and collision: checks collisions (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Scrolling ground: moves (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Game rendering: draws frame (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Network decisions: activates (evidence: `FlappyBird_with_IA.py`)
- Bird physics → Pipe and collision: provides mask (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Pygame: uses (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Game images: loads (evidence: `FlappyBird_with_IA.py`)
- Population evolution → AI game loop: runs fitness (evidence: `FlappyBird_with_IA.py`)
- Population evolution → NEAT library: configures population (evidence: `FlappyBird_with_IA.py`)
- Population evolution → NEAT configuration: loads (evidence: `FlappyBird_with_IA.py`)
- Network decisions → NEAT library: creates network (evidence: `FlappyBird_with_IA.py`)
- AI game loop → Population evolution: updates fitness (evidence: `FlappyBird_with_IA.py`)
