# andrew-hsu-6/coms4444-playpen-group-2 architecture

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

- Interactive diagram: https://gitdiagram.com/andrew-hsu-6/coms4444-playpen-group-2
- Repository: https://github.com/andrew-hsu-6/coms4444-playpen-group-2

## Overview

Playpen is a Python simulator for constructing and evaluating baby enclosures from a room polygon, piece inventory, and scoring weights. A user selects a player and scenario (or requests generation); the game gives the player its inputs, runs its construction, validates and scores the result, then reports it headlessly or in the GUI. The graph includes scenario generation, player selection, validation/scoring, and the documented GUI and run logging. Some links rely on README documentation or the SOURCE INDEX because the relevant source excerpts are partial.

Main entry points: [`src/game.py`](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/game.py) (Game orchestration), [`src/scenario.py`](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/scenario.py) (Scenario loading and generation), [`players/example_player.py`](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/example_player.py) (Player strategies), [`src/enclosure.py`](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py) (Rule validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Run entry"]
  node_cli["CLI arguments<br/>[args.py]"]
  node_launcher["Run launcher<br/>[main.py]"]
  node_runlogs["Run logs<br/>[runlog.py]"]
end

subgraph group_inputs["Scenario inputs"]
  node_scenarios["Scenario files"]
  node_scenario_io["Scenario loading and generation<br/>[scenario.py]"]
  node_room["Room geometry<br/>[room.py]"]
  node_inventory["Piece inventory<br/>[inventory.py]"]
  node_piece_model["Pieces and connectors<br/>[pieces.py]"]
  node_score_weights["Scoring weights<br/>[weights.py]"]
end

subgraph group_strategy["Player strategies"]
  node_player_registry["Player registry<br/>[registry.py]"]
  node_player_api["Player interface<br/>[player0.py]"]
  node_player_impl["Player strategies<br/>[example_player.py]"]
end

subgraph group_engine["Game engine"]
  node_game["Game orchestration<br/>[game.py]"]
  node_construction["Enclosure construction<br/>[enclosure.py]"]
  node_validation["Rule validation<br/>[enclosure.py]"]
  node_scoring["Score calculation<br/>[enclosure.py]"]
  node_cpu_limit["CPU time limit<br/>[limits.py]"]
  node_gui["Interactive GUI<br/>[game.py]"]
end

node_user(("Simulator user"))

node_user -->|"sets options"| node_cli
node_launcher -->|"parses options"| node_cli
node_launcher -->|"starts game"| node_game
node_launcher -->|"captures output"| node_runlogs
node_user -.->|"provides scenario"| node_scenarios
node_game -->|"loads or generates"| node_scenario_io
node_scenario_io -->|"reads and writes"| node_scenarios
node_scenario_io -->|"builds room"| node_room
node_scenario_io -->|"builds inventory"| node_inventory
node_scenario_io -->|"builds weights"| node_score_weights
node_inventory -->|"uses piece types"| node_piece_model
node_game -->|"selects player"| node_player_registry
node_player_registry -->|"loads strategy"| node_player_impl
node_player_impl -->|"implements"| node_player_api
node_game -->|"provides inputs"| node_player_api
node_player_api -->|"returns proposal"| node_construction
node_player_impl -->|"checks placement"| node_room
node_player_impl -->|"tests candidates"| node_validation
node_construction -->|"uses components"| node_piece_model
node_game -->|"validates proposal"| node_validation
node_validation -->|"checks containment"| node_room
node_validation -->|"checks availability"| node_inventory
node_game -->|"scores result"| node_scoring
node_scoring -->|"applies weights"| node_score_weights
node_game -->|"limits player run"| node_cpu_limit
node_game -->|"renders results"| node_gui

click node_cli "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/args.py"
click node_launcher "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/main.py"
click node_runlogs "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/runlog.py"
click node_scenarios "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/tree/main/scenarios"
click node_scenario_io "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/scenario.py"
click node_room "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/room.py"
click node_inventory "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/inventory.py"
click node_piece_model "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/pieces.py"
click node_score_weights "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/weights.py"
click node_game "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/game.py"
click node_player_registry "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/registry.py"
click node_player_api "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/player0.py"
click node_player_impl "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/example_player.py"
click node_construction "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py"
click node_validation "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py"
click node_scoring "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py"
click node_cpu_limit "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/limits.py"
click node_gui "https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/game.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_cli,node_launcher,node_runlogs,node_user toneBlue
class node_scenarios,node_scenario_io,node_room,node_inventory,node_piece_model,node_score_weights toneAmber
class node_player_registry,node_player_api,node_player_impl toneMint
class node_game,node_construction,node_validation,node_scoring,node_cpu_limit,node_gui toneRose
```

## Components

### Run entry

- [CLI arguments](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/args.py): `src/args.py`
- [Run launcher](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/main.py): `main.py`
- [Run logs](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/runlog.py): `src/runlog.py`

### Scenario inputs

- [Scenario files](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/tree/main/scenarios): `scenarios`
- [Scenario loading and generation](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/scenario.py): `src/scenario.py`
- [Room geometry](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/room.py): `src/room.py`
- [Piece inventory](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/inventory.py): `src/inventory.py`
- [Pieces and connectors](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/pieces.py): `src/pieces.py`
- [Scoring weights](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/weights.py): `src/weights.py`

### Player strategies

- [Player registry](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/registry.py): `players/registry.py`
- [Player interface](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/player0.py): `players/player0.py`
- [Player strategies](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/players/example_player.py): `players/example_player.py`

### Game engine

- [Game orchestration](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/game.py): `src/game.py`
- [Enclosure construction](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py): `src/enclosure.py`
- [Rule validation](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py): `src/enclosure.py`
- [Score calculation](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/enclosure.py): `src/enclosure.py`
- [CPU time limit](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/limits.py): `src/limits.py`
- [Interactive GUI](https://github.com/andrew-hsu-6/coms4444-playpen-group-2/blob/main/src/game.py): `src/game.py`

### Other components

- **Simulator user**

## Connections

- Simulator user → CLI arguments: sets options (evidence: `README.md`)
- Run launcher → CLI arguments: parses options (evidence: `main.py`)
- Run launcher → Game orchestration: starts game (evidence: `main.py`)
- Run launcher → Run logs: captures output (evidence: `main.py`)
- Simulator user → Scenario files: provides scenario (evidence: `README.md`)
- Game orchestration → Scenario loading and generation: loads or generates (evidence: `src/game.py`)
- Scenario loading and generation → Scenario files: reads and writes (evidence: `README.md`)
- Scenario loading and generation → Room geometry: builds room (evidence: `src/scenario.py`)
- Scenario loading and generation → Piece inventory: builds inventory (evidence: `src/scenario.py`)
- Scenario loading and generation → Scoring weights: builds weights (evidence: `src/scenario.py`)
- Piece inventory → Pieces and connectors: uses piece types (evidence: `src/inventory.py`)
- Game orchestration → Player registry: selects player (evidence: `src/game.py`)
- Player registry → Player strategies: loads strategy (evidence: `players/registry.py`)
- Player strategies → Player interface: implements (evidence: `players/example_player.py`)
- Game orchestration → Player interface: provides inputs (evidence: `README.md`)
- Player interface → Enclosure construction: returns proposal (evidence: `players/player0.py`)
- Player strategies → Room geometry: checks placement (evidence: `players/example_player.py`)
- Player strategies → Rule validation: tests candidates (evidence: `players/example_player.py`)
- Enclosure construction → Pieces and connectors: uses components (evidence: `src/enclosure.py`)
- Game orchestration → Rule validation: validates proposal (evidence: `src/game.py`)
- Rule validation → Room geometry: checks containment (evidence: `src/enclosure.py`)
- Rule validation → Piece inventory: checks availability (evidence: `src/enclosure.py`)
- Game orchestration → Score calculation: scores result (evidence: `README.md`)
- Score calculation → Scoring weights: applies weights (evidence: `src/enclosure.py`)
- Game orchestration → CPU time limit: limits player run (evidence: `src/game.py`)
- Game orchestration → Interactive GUI: renders results (evidence: `README.md`)
