# iazzouzi/pac-man architecture

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

- Interactive diagram: https://gitdiagram.com/iazzouzi/pac-man
- Repository: https://github.com/iazzouzi/pac-man

## Overview

This is a Python/Pygame Pac-Man game. The player configures and launches a session, the engine generates successive mazes and runs movement, ghost AI, collisions, scoring, and level progression, while the GUI state machine presents play and menu screens. Results can be recorded to a local JSON high-score file and viewed later. The graph preserves the documented screen and gameplay capabilities; some relationships are based on README descriptions because their implementation excerpts were not provided.

Main entry points: [`engine.py`](https://github.com/iazzouzi/pac-man/blob/main/engine.py) (Game Engine), [`gui_src/menu_state.py`](https://github.com/iazzouzi/pac-man/blob/main/gui_src/menu_state.py) (Main Menu), [`gui.py`](https://github.com/iazzouzi/pac-man/blob/main/gui.py) (Game Controller), [`gui_src/playing_state.py`](https://github.com/iazzouzi/pac-man/blob/main/gui_src/playing_state.py) (Playing Screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_launcher["Game Launcher<br/>[pac-man.py]"]
  node_config["Config Parser<br/>[parser.py]"]
  node_settings["Game Settings<br/>[models.py]"]
end

subgraph group_gameplay["Game Runtime"]
  node_engine["Game Engine<br/>[engine.py]"]
  node_maze["Maze Builder<br/>[mazegen.py]"]
  node_entities["Game Entities<br/>[models.py]"]
  node_pathfinding["Ghost Pathfinding<br/>[algo.py]"]
end

subgraph group_interface["Game Interface"]
  node_game["Game Controller<br/>[gui.py]"]
  node_menu["Main Menu<br/>[menu_state.py]"]
  node_playing["Playing Screen<br/>[playing_state.py]"]
  node_pause["Pause Screen<br/>[pause_state.py]"]
  node_result["Result Screen<br/>[result_state.py]"]
  node_highscores["High-score Screen<br/>[highscore_state.py]"]
  node_instructions["Instructions Screen"]
  node_statebase["State Interface<br/>[game_state.py]"]
  node_background["Animated Background<br/>[background.py]"]
end

subgraph group_records["Scores"]
  node_scorefile[("High-score JSON")]
end

node_player(("Player"))
node_generator["Maze Generator Package"]

node_player -->|"starts game"| node_launcher
node_launcher -->|"loads settings"| node_config
node_config -->|"builds config"| node_settings
node_launcher -->|"starts session"| node_game
node_game -->|"runs logic"| node_engine
node_launcher -->|"creates engine"| node_engine
node_engine -->|"uses config"| node_settings
node_engine -->|"creates levels"| node_maze
node_maze -->|"wraps package"| node_generator
node_maze -->|"spawns entities"| node_entities
node_engine -->|"updates entities"| node_entities
node_engine -->|"plans ghost paths"| node_pathfinding
node_game -->|"shows state"| node_menu
node_game -->|"shows state"| node_playing
node_game -->|"switches state"| node_pause
node_game -->|"switches state"| node_result
node_game -->|"switches state"| node_highscores
node_game -->|"switches state"| node_instructions
node_menu -->|"starts play"| node_playing
node_playing -->|"pauses game"| node_pause
node_playing -->|"ends session"| node_result
node_result -->|"restarts game"| node_playing
node_menu -->|"opens scores"| node_highscores
node_menu -->|"opens instructions"| node_instructions
node_pause -->|"resumes game"| node_playing
node_pause -->|"returns to menu"| node_menu
node_result -->|"returns to menu"| node_menu
node_highscores -->|"returns to menu"| node_menu
node_instructions -->|"returns to menu"| node_menu
node_playing -->|"reads game state"| node_engine
node_menu -->|"renders"| node_background
node_highscores -->|"renders"| node_background
node_instructions -->|"renders"| node_background
node_result -->|"saves score via"| node_engine
node_engine -->|"reads and writes"| node_scorefile
node_highscores -->|"retrieves scores"| node_engine
node_menu -.->|"implements"| node_statebase
node_playing -.->|"implements"| node_statebase
node_pause -.->|"implements"| node_statebase
node_result -.->|"implements"| node_statebase
node_highscores -.->|"implements"| node_statebase
node_instructions -.->|"implements"| node_statebase

click node_launcher "https://github.com/iazzouzi/pac-man/blob/main/pac-man.py"
click node_config "https://github.com/iazzouzi/pac-man/blob/main/parser.py"
click node_settings "https://github.com/iazzouzi/pac-man/blob/main/models.py"
click node_game "https://github.com/iazzouzi/pac-man/blob/main/gui.py"
click node_menu "https://github.com/iazzouzi/pac-man/blob/main/gui_src/menu_state.py"
click node_playing "https://github.com/iazzouzi/pac-man/blob/main/gui_src/playing_state.py"
click node_pause "https://github.com/iazzouzi/pac-man/blob/main/gui_src/pause_state.py"
click node_result "https://github.com/iazzouzi/pac-man/blob/main/gui_src/result_state.py"
click node_highscores "https://github.com/iazzouzi/pac-man/blob/main/gui_src/highscore_state.py"
click node_instructions "https://github.com/iazzouzi/pac-man/blob/main/gui_src/instructions_state.py"
click node_statebase "https://github.com/iazzouzi/pac-man/blob/main/gui_src/game_state.py"
click node_background "https://github.com/iazzouzi/pac-man/blob/main/gui_src/background.py"
click node_engine "https://github.com/iazzouzi/pac-man/blob/main/engine.py"
click node_maze "https://github.com/iazzouzi/pac-man/blob/main/mazegen.py"
click node_entities "https://github.com/iazzouzi/pac-man/blob/main/models.py"
click node_pathfinding "https://github.com/iazzouzi/pac-man/blob/main/algo.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_launcher,node_config,node_settings toneBlue
class node_engine,node_maze,node_entities,node_pathfinding toneAmber
class node_game,node_menu,node_playing,node_pause,node_result,node_highscores,node_instructions,node_statebase,node_background toneMint
class node_scorefile toneRose
class node_player,node_generator toneIndigo
```

## Components

### Configuration

- [Game Launcher](https://github.com/iazzouzi/pac-man/blob/main/pac-man.py): `pac-man.py`
- [Config Parser](https://github.com/iazzouzi/pac-man/blob/main/parser.py): `parser.py`
- [Game Settings](https://github.com/iazzouzi/pac-man/blob/main/models.py): `models.py`

### Game Runtime

- [Game Engine](https://github.com/iazzouzi/pac-man/blob/main/engine.py): `engine.py`
- [Maze Builder](https://github.com/iazzouzi/pac-man/blob/main/mazegen.py): `mazegen.py`
- [Game Entities](https://github.com/iazzouzi/pac-man/blob/main/models.py): `models.py`
- [Ghost Pathfinding](https://github.com/iazzouzi/pac-man/blob/main/algo.py): `algo.py`

### Game Interface

- [Game Controller](https://github.com/iazzouzi/pac-man/blob/main/gui.py): `gui.py`
- [Main Menu](https://github.com/iazzouzi/pac-man/blob/main/gui_src/menu_state.py): `gui_src/menu_state.py`
- [Playing Screen](https://github.com/iazzouzi/pac-man/blob/main/gui_src/playing_state.py): `gui_src/playing_state.py`
- [Pause Screen](https://github.com/iazzouzi/pac-man/blob/main/gui_src/pause_state.py): `gui_src/pause_state.py`
- [Result Screen](https://github.com/iazzouzi/pac-man/blob/main/gui_src/result_state.py): `gui_src/result_state.py`
- [High-score Screen](https://github.com/iazzouzi/pac-man/blob/main/gui_src/highscore_state.py): `gui_src/highscore_state.py`
- [Instructions Screen](https://github.com/iazzouzi/pac-man/blob/main/gui_src/instructions_state.py): `gui_src/instructions_state.py`
- [State Interface](https://github.com/iazzouzi/pac-man/blob/main/gui_src/game_state.py): `gui_src/game_state.py`
- [Animated Background](https://github.com/iazzouzi/pac-man/blob/main/gui_src/background.py): `gui_src/background.py`

### Scores

- **High-score JSON**

### Other components

- **Player**
- **Maze Generator Package**

## Connections

- Player → Game Launcher: starts game (evidence: `README.md`)
- Game Launcher → Config Parser: loads settings (evidence: `README.md`)
- Config Parser → Game Settings: builds config (evidence: `parser.py`)
- Game Launcher → Game Controller: starts session (evidence: `README.md`)
- Game Controller → Game Engine: runs logic (evidence: `README.md`)
- Game Launcher → Game Engine: creates engine (evidence: `README.md`)
- Game Engine → Game Settings: uses config (evidence: `engine.py`)
- Game Engine → Maze Builder: creates levels (evidence: `engine.py`)
- Maze Builder → Maze Generator Package: wraps package (evidence: `README.md`)
- Maze Builder → Game Entities: spawns entities (evidence: `README.md`)
- Game Engine → Game Entities: updates entities (evidence: `engine.py`)
- Game Engine → Ghost Pathfinding: plans ghost paths (evidence: `engine.py`)
- Game Controller → Main Menu: shows state (evidence: `gui.py`)
- Game Controller → Playing Screen: shows state (evidence: `gui.py`)
- Game Controller → Pause Screen: switches state (evidence: `README.md`)
- Game Controller → Result Screen: switches state (evidence: `gui.py`)
- Game Controller → High-score Screen: switches state (evidence: `README.md`)
- Game Controller → Instructions Screen: switches state (evidence: `gui.py`)
- Main Menu → Playing Screen: starts play (evidence: `README.md`)
- Playing Screen → Pause Screen: pauses game (evidence: `README.md`)
- Playing Screen → Result Screen: ends session (evidence: `README.md`)
- Result Screen → Playing Screen: restarts game (evidence: `README.md`)
- Main Menu → High-score Screen: opens scores (evidence: `README.md`)
- Main Menu → Instructions Screen: opens instructions (evidence: `README.md`)
- Pause Screen → Playing Screen: resumes game (evidence: `README.md`)
- Pause Screen → Main Menu: returns to menu (evidence: `README.md`)
- Result Screen → Main Menu: returns to menu (evidence: `README.md`)
- High-score Screen → Main Menu: returns to menu (evidence: `README.md`)
- Instructions Screen → Main Menu: returns to menu (evidence: `README.md`)
- Playing Screen → Game Engine: reads game state (evidence: `gui_src/playing_state.py`)
- Main Menu → Animated Background: renders (evidence: `gui_src/menu_state.py`)
- High-score Screen → Animated Background: renders (evidence: `gui_src/highscore_state.py`)
- Instructions Screen → Animated Background: renders (evidence: `gui_src/instructions_state.py`)
- Result Screen → Game Engine: saves score via (evidence: `gui_src/result_state.py`)
- Game Engine → High-score JSON: reads and writes (evidence: `README.md`)
- High-score Screen → Game Engine: retrieves scores (evidence: `README.md`)
- Main Menu → State Interface: implements (evidence: `gui_src/menu_state.py`)
- Playing Screen → State Interface: implements (evidence: `gui_src/playing_state.py`)
- Pause Screen → State Interface: implements (evidence: `gui_src/pause_state.py`)
- Result Screen → State Interface: implements (evidence: `gui_src/result_state.py`)
- High-score Screen → State Interface: implements (evidence: `gui_src/highscore_state.py`)
- Instructions Screen → State Interface: implements (evidence: `gui_src/instructions_state.py`)
