# johnskouloudis/pacmanproject architecture

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

- Interactive diagram: https://gitdiagram.com/johnskouloudis/pacmanproject
- Repository: https://github.com/johnskouloudis/pacmanproject

## Overview

This repository is a Berkeley Pacman AI teaching project, with separate game variants and exercises in search, adversarial agents, tracking, and reinforcement learning, plus a small machine-learning package. The main gameplay workflow loads a maze, runs Pacman and ghost agents through game-state transitions, and displays the outcome. Other branches implement inference and learning workflows. Relationships below use README and SOURCE INDEX evidence; unsampled subsystems are included where documented, but their unverified connections are omitted or dashed.

Main entry points: [`Tracking/pacman.py`](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/pacman.py) (Pacman Runner), [`Tracking/inference.py`](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/inference.py) (Belief Inference), [`Reinforcement/gridworld.py`](https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/gridworld.py) (Gridworld MDP), [`Tracking/game.py`](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/game.py) (Game Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Pacman Gameplay"]
  node_maze["Maze Layout<br/>[layout.py]"]
  node_game["Game Engine<br/>[game.py]"]
  node_pacman["Pacman Runner<br/>[pacman.py]"]
  node_agents["Pacman Agents<br/>[pacmanAgents.py]"]
  node_ghosts["Ghost Agents<br/>[ghostAgents.py]"]
  node_text["Text Display<br/>[textDisplay.py]"]
  node_graphics["Graphics Display<br/>[graphicsDisplay.py]"]
end

subgraph group_search["Search Agents"]
  node_searchalg["Search Algorithms<br/>[search.py]"]
  node_searchagents["Search Agents<br/>[searchAgents.py]"]
  node_adversarial["Adversarial Agents<br/>[multiAgents.py]"]
end

subgraph group_tracking["Tracking Inference"]
  node_busters["Busters Game<br/>[busters.py]"]
  node_bustersagents["Busters Agents<br/>[bustersAgents.py]"]
  node_inference["Belief Inference<br/>[inference.py]"]
  node_bayes["Bayesian Networks<br/>[bayesNet.py]"]
  node_factors["Factor Operations"]
end

subgraph group_reinforce["Reinforcement Learning"]
  node_gridworld["Gridworld MDP<br/>[gridworld.py]"]
  node_value["Value Iteration"]
  node_qlearning["Q Learning<br/>[qlearningAgents.py]"]
  node_backend["RL Backend<br/>[backend.py]"]
end

subgraph group_ml["Machine Learning"]
  node_models["Model Definitions<br/>[models.py]"]
  node_losses["Loss Functions<br/>[losses.py]"]
  node_training["Training Loop<br/>[train.py]"]
  node_mlbackend["ML Backend<br/>[backend.py]"]
  node_gpt["GPT Model<br/>[gpt_model.py]"]
  node_chargpt["ChatGPT Interface<br/>[chargpt.py]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_pacman
node_pacman -->|"loads layout"| node_maze
node_pacman -->|"runs game"| node_game
node_pacman -->|"loads agents"| node_agents
node_pacman -->|"loads ghosts"| node_ghosts
node_pacman -->|"selects display"| node_text
node_pacman -->|"selects display"| node_graphics
node_game -->|"initializes state"| node_maze
node_searchagents -->|"uses algorithms"| node_searchalg
node_searchalg -.->|"returns action path"| node_player
node_adversarial -.->|"chooses strategy"| node_player
node_busters -->|"uses game framework"| node_game
node_bustersagents -->|"uses game state"| node_busters
node_bustersagents -->|"requests beliefs"| node_inference
node_inference -->|"uses network"| node_bayes
node_inference -->|"uses operations"| node_factors
node_factors -->|"operates on factors"| node_bayes
node_gridworld -->|"uses agent"| node_value
node_gridworld -->|"uses agent"| node_qlearning
node_backend -->|"supports exercises"| node_gridworld
node_training -->|"computes loss"| node_losses
node_mlbackend -->|"uses models"| node_models
node_mlbackend -->|"uses losses"| node_losses
node_gpt -->|"builds on"| node_models
node_chargpt -->|"delegates to"| node_gpt

click node_maze "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/layout.py"
click node_game "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/game.py"
click node_pacman "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/pacman.py"
click node_agents "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/pacmanAgents.py"
click node_ghosts "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/ghostAgents.py"
click node_text "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/textDisplay.py"
click node_graphics "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/graphicsDisplay.py"
click node_searchalg "https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/search.py"
click node_searchagents "https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/searchAgents.py"
click node_adversarial "https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/multiAgents.py"
click node_busters "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/busters.py"
click node_bustersagents "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/bustersAgents.py"
click node_inference "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/inference.py"
click node_bayes "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/bayesNet.py"
click node_factors "https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/factorOperations.py"
click node_gridworld "https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/gridworld.py"
click node_value "https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/valueIterationAgents.py"
click node_qlearning "https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/qlearningAgents.py"
click node_backend "https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/backend.py"
click node_models "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/models.py"
click node_losses "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/losses.py"
click node_training "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/train.py"
click node_mlbackend "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/backend.py"
click node_gpt "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/gpt_model.py"
click node_chargpt "https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/chargpt.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_maze,node_game,node_pacman,node_agents,node_ghosts,node_text,node_graphics toneBlue
class node_searchalg,node_searchagents,node_adversarial toneAmber
class node_busters,node_bustersagents,node_inference,node_bayes,node_factors toneMint
class node_gridworld,node_value,node_qlearning,node_backend toneRose
class node_models,node_losses,node_training,node_mlbackend,node_gpt,node_chargpt,node_player toneIndigo
```

## Components

### Pacman Gameplay

- [Maze Layout](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/layout.py): `Tracking/layout.py`
- [Game Engine](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/game.py): `Tracking/game.py`
- [Pacman Runner](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/pacman.py): `Tracking/pacman.py`
- [Pacman Agents](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/pacmanAgents.py): `Tracking/pacmanAgents.py`
- [Ghost Agents](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/ghostAgents.py): `Tracking/ghostAgents.py`
- [Text Display](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/textDisplay.py): `Tracking/textDisplay.py`
- [Graphics Display](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/graphicsDisplay.py): `Tracking/graphicsDisplay.py`

### Search Agents

- [Search Algorithms](https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/search.py): `Search and Multi-Agent/search.py`
- [Search Agents](https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/searchAgents.py): `Search and Multi-Agent/searchAgents.py`
- [Adversarial Agents](https://github.com/johnskouloudis/pacmanproject/blob/main/Search%20and%20Multi-Agent/multiAgents.py): `Search and Multi-Agent/multiAgents.py`

### Tracking Inference

- [Busters Game](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/busters.py): `Tracking/busters.py`
- [Busters Agents](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/bustersAgents.py): `Tracking/bustersAgents.py`
- [Belief Inference](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/inference.py): `Tracking/inference.py`
- [Bayesian Networks](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/bayesNet.py): `Tracking/bayesNet.py`
- [Factor Operations](https://github.com/johnskouloudis/pacmanproject/blob/main/Tracking/factorOperations.py): `Tracking/factorOperations.py`

### Reinforcement Learning

- [Gridworld MDP](https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/gridworld.py): `Reinforcement/gridworld.py`
- [Value Iteration](https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/valueIterationAgents.py): `Reinforcement/valueIterationAgents.py`
- [Q Learning](https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/qlearningAgents.py): `Reinforcement/qlearningAgents.py`
- [RL Backend](https://github.com/johnskouloudis/pacmanproject/blob/main/Reinforcement/backend.py): `Reinforcement/backend.py`

### Machine Learning

- [Model Definitions](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/models.py): `machinelearning/models.py`
- [Loss Functions](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/losses.py): `machinelearning/losses.py`
- [Training Loop](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/train.py): `machinelearning/train.py`
- [ML Backend](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/backend.py): `machinelearning/backend.py`
- [GPT Model](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/gpt_model.py): `machinelearning/gpt_model.py`
- [ChatGPT Interface](https://github.com/johnskouloudis/pacmanproject/blob/main/machinelearning/chargpt.py): `machinelearning/chargpt.py`

### Other components

- **Player**

## Connections

- Player → Pacman Runner: starts game (evidence: `README.md`)
- Pacman Runner → Maze Layout: loads layout (evidence: `Tracking/pacman.py`)
- Pacman Runner → Game Engine: runs game (evidence: `Tracking/pacman.py`)
- Pacman Runner → Pacman Agents: loads agents (evidence: `Tracking/pacman.py`)
- Pacman Runner → Ghost Agents: loads ghosts (evidence: `Tracking/pacman.py`)
- Pacman Runner → Text Display: selects display (evidence: `Tracking/pacman.py`)
- Pacman Runner → Graphics Display: selects display (evidence: `Tracking/pacman.py`)
- Game Engine → Maze Layout: initializes state (evidence: `Tracking/game.py`)
- Search Agents → Search Algorithms: uses algorithms (evidence: `Search and Multi-Agent/searchAgents.py`)
- Search Algorithms → Player: returns action path
- Adversarial Agents → Player: chooses strategy
- Busters Game → Game Engine: uses game framework (evidence: `Tracking/busters.py`)
- Busters Agents → Busters Game: uses game state (evidence: `Tracking/bustersAgents.py`)
- Busters Agents → Belief Inference: requests beliefs (evidence: `Tracking/bustersAgents.py`)
- Belief Inference → Bayesian Networks: uses network (evidence: `Tracking/inference.py`)
- Belief Inference → Factor Operations: uses operations (evidence: `Tracking/inference.py`)
- Factor Operations → Bayesian Networks: operates on factors (evidence: `Tracking/factorOperations.py`)
- Gridworld MDP → Value Iteration: uses agent (evidence: `Reinforcement/gridworld.py`)
- Gridworld MDP → Q Learning: uses agent (evidence: `Reinforcement/gridworld.py`)
- RL Backend → Gridworld MDP: supports exercises (evidence: `Reinforcement/backend.py`)
- Training Loop → Loss Functions: computes loss (evidence: `machinelearning/train.py`)
- ML Backend → Model Definitions: uses models (evidence: `machinelearning/backend.py`)
- ML Backend → Loss Functions: uses losses (evidence: `machinelearning/backend.py`)
- GPT Model → Model Definitions: builds on (evidence: `machinelearning/gpt_model.py`)
- ChatGPT Interface → GPT Model: delegates to (evidence: `machinelearning/chargpt.py`)
