# rahulrayy/pcg-platformer architecture

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

- Interactive diagram: https://gitdiagram.com/rahulrayy/pcg-platformer
- Repository: https://github.com/rahulrayy/pcg-platformer

## Overview

This is an Arcade infinite platformer launched by `main.py`: the player moves and jumps through a fixed opening segment into procedurally generated chunks, while the game updates physics, camera, and distance score. Chunk generation uses cellular automata and reachability checking before converting accepted tiles into sprites. The tree also contains additional validation and RL modules, but the README does not describe them and the sampled excerpts do not establish their runtime wiring, so they are not presented as part of the play workflow.

Main entry points: [`game/window.py`](https://github.com/rahulrayy/pcg-platformer/blob/master/game/window.py) (Game window), [`config.py`](https://github.com/rahulrayy/pcg-platformer/blob/master/config.py) (Game configuration), [`game/chunk_manager.py`](https://github.com/rahulrayy/pcg-platformer/blob/master/game/chunk_manager.py) (Chunk manager), [`level/generator.py`](https://github.com/rahulrayy/pcg-platformer/blob/master/level/generator.py) (Chunk generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game runtime"]
  node_main_entry["Launch entry<br/>[main.py]"]
  node_game_window["Game window<br/>[window.py]"]
  node_player["Player controls<br/>[player.py]"]
  node_physics["Physics engine<br/>[physics.py]"]
  node_camera["Camera<br/>[camera.py]"]
  node_chunk_manager["Chunk manager<br/>[chunk_manager.py]"]
  node_score["Distance score<br/>[score.py]"]
end

subgraph group_level["Level generation"]
  node_opening["Opening segment<br/>[opening_segment.py]"]
  node_generator["Chunk generator<br/>[generator.py]"]
  node_cellular["Cellular automata"]
  node_chunk["Chunk model<br/>[chunk.py]"]
  node_tilemap["Tile sprite conversion<br/>[tilemap.py]"]
end

subgraph group_validation["Reachability validation"]
  node_bfs["BFS reachability"]
end

subgraph group_shared["Shared configuration"]
  node_config["Game configuration<br/>[config.py]"]
end

node_player_actor(("Player"))

node_player_actor -->|"starts game"| node_main_entry
node_main_entry -->|"creates window"| node_game_window
node_game_window -->|"creates opening"| node_opening
node_game_window -->|"converts opening"| node_tilemap
node_game_window -->|"manages chunks"| node_chunk_manager
node_game_window -->|"creates player"| node_player
node_game_window -->|"updates physics"| node_physics
node_game_window -->|"updates camera"| node_camera
node_game_window -->|"updates score"| node_score
node_chunk_manager -->|"generates chunks"| node_generator
node_chunk_manager -->|"checks reachability"| node_bfs
node_chunk_manager -->|"converts chunks"| node_tilemap
node_generator -->|"creates tile grid"| node_cellular
node_generator -->|"builds chunk"| node_chunk
node_opening -->|"builds chunk"| node_chunk
node_tilemap -->|"reads tiles"| node_chunk
node_bfs -->|"checks tiles"| node_chunk
node_camera -->|"reads settings"| node_config
node_chunk_manager -->|"reads settings"| node_config
node_physics -->|"reads settings"| node_config
node_player -->|"reads settings"| node_config
node_score -->|"reads settings"| node_config
node_opening -->|"reads dimensions"| node_config
node_generator -->|"reads dimensions"| node_config
node_cellular -->|"reads dimensions"| node_config
node_tilemap -->|"reads tile size"| node_config

click node_main_entry "https://github.com/rahulrayy/pcg-platformer/blob/master/main.py"
click node_game_window "https://github.com/rahulrayy/pcg-platformer/blob/master/game/window.py"
click node_player "https://github.com/rahulrayy/pcg-platformer/blob/master/game/player.py"
click node_physics "https://github.com/rahulrayy/pcg-platformer/blob/master/game/physics.py"
click node_camera "https://github.com/rahulrayy/pcg-platformer/blob/master/game/camera.py"
click node_chunk_manager "https://github.com/rahulrayy/pcg-platformer/blob/master/game/chunk_manager.py"
click node_score "https://github.com/rahulrayy/pcg-platformer/blob/master/game/score.py"
click node_opening "https://github.com/rahulrayy/pcg-platformer/blob/master/level/opening_segment.py"
click node_generator "https://github.com/rahulrayy/pcg-platformer/blob/master/level/generator.py"
click node_cellular "https://github.com/rahulrayy/pcg-platformer/blob/master/level/cellular_automata.py"
click node_chunk "https://github.com/rahulrayy/pcg-platformer/blob/master/level/chunk.py"
click node_tilemap "https://github.com/rahulrayy/pcg-platformer/blob/master/level/tilemap.py"
click node_bfs "https://github.com/rahulrayy/pcg-platformer/blob/master/validation/bfs_reachability.py"
click node_config "https://github.com/rahulrayy/pcg-platformer/blob/master/config.py"

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_main_entry,node_game_window,node_player,node_physics,node_camera,node_chunk_manager,node_score toneBlue
class node_opening,node_generator,node_cellular,node_chunk,node_tilemap toneAmber
class node_bfs toneMint
class node_config toneRose
class node_player_actor toneIndigo
```

## Components

### Game runtime

- [Launch entry](https://github.com/rahulrayy/pcg-platformer/blob/master/main.py): `main.py`
- [Game window](https://github.com/rahulrayy/pcg-platformer/blob/master/game/window.py): `game/window.py`
- [Player controls](https://github.com/rahulrayy/pcg-platformer/blob/master/game/player.py): `game/player.py`
- [Physics engine](https://github.com/rahulrayy/pcg-platformer/blob/master/game/physics.py): `game/physics.py`
- [Camera](https://github.com/rahulrayy/pcg-platformer/blob/master/game/camera.py): `game/camera.py`
- [Chunk manager](https://github.com/rahulrayy/pcg-platformer/blob/master/game/chunk_manager.py): `game/chunk_manager.py`
- [Distance score](https://github.com/rahulrayy/pcg-platformer/blob/master/game/score.py): `game/score.py`

### Level generation

- [Opening segment](https://github.com/rahulrayy/pcg-platformer/blob/master/level/opening_segment.py): `level/opening_segment.py`
- [Chunk generator](https://github.com/rahulrayy/pcg-platformer/blob/master/level/generator.py): `level/generator.py`
- [Cellular automata](https://github.com/rahulrayy/pcg-platformer/blob/master/level/cellular_automata.py): `level/cellular_automata.py`
- [Chunk model](https://github.com/rahulrayy/pcg-platformer/blob/master/level/chunk.py): `level/chunk.py`
- [Tile sprite conversion](https://github.com/rahulrayy/pcg-platformer/blob/master/level/tilemap.py): `level/tilemap.py`

### Reachability validation

- [BFS reachability](https://github.com/rahulrayy/pcg-platformer/blob/master/validation/bfs_reachability.py): `validation/bfs_reachability.py`

### Shared configuration

- [Game configuration](https://github.com/rahulrayy/pcg-platformer/blob/master/config.py): `config.py`

### Other components

- **Player**

## Connections

- Player → Launch entry: starts game (evidence: `README.md`)
- Launch entry → Game window: creates window (evidence: `main.py`)
- Game window → Opening segment: creates opening (evidence: `game/window.py`)
- Game window → Tile sprite conversion: converts opening (evidence: `game/window.py`)
- Game window → Chunk manager: manages chunks (evidence: `game/window.py`)
- Game window → Player controls: creates player (evidence: `game/window.py`)
- Game window → Physics engine: updates physics (evidence: `game/window.py`)
- Game window → Camera: updates camera (evidence: `game/window.py`)
- Game window → Distance score: updates score (evidence: `game/window.py`)
- Chunk manager → Chunk generator: generates chunks (evidence: `game/chunk_manager.py`)
- Chunk manager → BFS reachability: checks reachability (evidence: `game/chunk_manager.py`)
- Chunk manager → Tile sprite conversion: converts chunks (evidence: `game/chunk_manager.py`)
- Chunk generator → Cellular automata: creates tile grid (evidence: `level/generator.py`)
- Chunk generator → Chunk model: builds chunk (evidence: `level/generator.py`)
- Opening segment → Chunk model: builds chunk (evidence: `level/opening_segment.py`)
- Tile sprite conversion → Chunk model: reads tiles (evidence: `level/tilemap.py`)
- BFS reachability → Chunk model: checks tiles (evidence: `validation/bfs_reachability.py`)
- Camera → Game configuration: reads settings (evidence: `game/camera.py`)
- Chunk manager → Game configuration: reads settings (evidence: `game/chunk_manager.py`)
- Physics engine → Game configuration: reads settings (evidence: `game/physics.py`)
- Player controls → Game configuration: reads settings (evidence: `game/player.py`)
- Distance score → Game configuration: reads settings (evidence: `game/score.py`)
- Opening segment → Game configuration: reads dimensions (evidence: `level/opening_segment.py`)
- Chunk generator → Game configuration: reads dimensions (evidence: `level/generator.py`)
- Cellular automata → Game configuration: reads dimensions (evidence: `level/cellular_automata.py`)
- Tile sprite conversion → Game configuration: reads tile size (evidence: `level/tilemap.py`)
