# alanmet/zork architecture

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

- Interactive diagram: https://gitdiagram.com/alanmet/zork
- Repository: https://github.com/alanmet/zork

## Overview

Zrok is a console text-adventure engine. The principal workflow is console input through the game loop and command parser, which dispatches actions to the player and world; the loop then describes the current room. The runtime also supports serialized save/load, restart, and scripted command input. The graph retains the documented vocabulary, inventory, item, and room capabilities. Some room interactions and the trophy-case implementation were not excerpted, so uncertain links are omitted; save/load behavior is visible in the game loop source.

Main entry points: [`zrok/zrok/Player.cs`](https://github.com/alanmet/zork/blob/main/zrok/zrok/Player.cs) (Player Actions), [`zrok/zrok/GameRunner.cs`](https://github.com/alanmet/zork/blob/main/zrok/zrok/GameRunner.cs) (Game Loop), [`zrok/zrok/Adventure Parser.cs`](https://github.com/alanmet/zork/blob/main/zrok/zrok/Adventure%20Parser.cs) (Command Parser), [`zrok/zrok/Room.cs`](https://github.com/alanmet/zork/blob/main/zrok/zrok/Room.cs) (Rooms and Exits)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_runner["Game Loop<br/>[GameRunner.cs]"]
  node_adventure["Adventure State<br/>[Adventure.cs]"]
end

subgraph group_commands["Command Parsing"]
  node_parser["Command Parser"]
  node_vocabulary["Word Types<br/>[WordAndType.cs]"]
end

subgraph group_world["World and Player"]
  node_player["Player Actions<br/>[Player.cs]"]
  node_room["Rooms and Exits<br/>[Room.cs]"]
  node_trapdoor["Trap Door Room<br/>[TrapDoorRoom.cs]"]
  node_window["Window Room<br/>[WindowRoom.cs]"]
end

subgraph group_objects["Items and Inventory"]
  node_inventory["Inventory<br/>[Inventory.cs]"]
  node_item["Items<br/>[Item.cs]"]
  node_container["Containers<br/>[Container.cs]"]
  node_lamp["Lamp<br/>[Lamp.cs]"]
  node_trophy["Trophy Case<br/>[Trophy case.cs]"]
end

node_user(("Player"))
node_console["Console"]
node_savefile["Save File"]

node_user -->|"enters commands"| node_console
node_runner -->|"reads and prints"| node_console
node_runner -->|"creates and updates"| node_adventure
node_runner -->|"forwards commands"| node_parser
node_runner -->|"serializes state"| node_savefile
node_savefile -->|"restores state"| node_runner
node_adventure -->|"creates and describes"| node_player
node_parser -->|"classifies words"| node_vocabulary
node_parser -->|"dispatches actions"| node_player
node_parser -->|"checks room type"| node_trapdoor
node_player -->|"moves through"| node_room
node_player -->|"updates inventory"| node_inventory
node_player -->|"opens and transfers"| node_container
node_player -->|"lights and unlights"| node_lamp
node_player -->|"handles window room"| node_window
node_room -->|"holds items"| node_item
node_container -->|"holds items"| node_item
node_inventory -->|"stores items"| node_item
node_lamp -->|"extends item"| node_item
node_trapdoor -->|"extends room"| node_room
node_window -->|"extends room"| node_room

click node_runner "https://github.com/alanmet/zork/blob/main/zrok/zrok/GameRunner.cs"
click node_adventure "https://github.com/alanmet/zork/blob/main/zrok/zrok/Adventure.cs"
click node_parser "https://github.com/alanmet/zork/blob/main/zrok/zrok/Adventure%20Parser.cs"
click node_vocabulary "https://github.com/alanmet/zork/blob/main/zrok/zrok/WordAndType.cs"
click node_player "https://github.com/alanmet/zork/blob/main/zrok/zrok/Player.cs"
click node_room "https://github.com/alanmet/zork/blob/main/zrok/zrok/Room.cs"
click node_trapdoor "https://github.com/alanmet/zork/blob/main/zrok/zrok/TrapDoorRoom.cs"
click node_window "https://github.com/alanmet/zork/blob/main/zrok/zrok/WindowRoom.cs"
click node_inventory "https://github.com/alanmet/zork/blob/main/zrok/zrok/Inventory.cs"
click node_item "https://github.com/alanmet/zork/blob/main/zrok/zrok/Item.cs"
click node_container "https://github.com/alanmet/zork/blob/main/zrok/zrok/Container.cs"
click node_lamp "https://github.com/alanmet/zork/blob/main/zrok/zrok/Lamp.cs"
click node_trophy "https://github.com/alanmet/zork/blob/main/zrok/zrok/Trophy%20case.cs"

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_runner,node_adventure toneBlue
class node_parser,node_vocabulary toneAmber
class node_player,node_room,node_trapdoor,node_window toneMint
class node_inventory,node_item,node_container,node_lamp,node_trophy toneRose
class node_user,node_console,node_savefile toneIndigo
```

## Components

### Game Runtime

- [Game Loop](https://github.com/alanmet/zork/blob/main/zrok/zrok/GameRunner.cs): `zrok/zrok/GameRunner.cs`
- [Adventure State](https://github.com/alanmet/zork/blob/main/zrok/zrok/Adventure.cs): `zrok/zrok/Adventure.cs`

### Command Parsing

- [Command Parser](https://github.com/alanmet/zork/blob/main/zrok/zrok/Adventure%20Parser.cs): `zrok/zrok/Adventure Parser.cs`
- [Word Types](https://github.com/alanmet/zork/blob/main/zrok/zrok/WordAndType.cs): `zrok/zrok/WordAndType.cs`

### World and Player

- [Player Actions](https://github.com/alanmet/zork/blob/main/zrok/zrok/Player.cs): `zrok/zrok/Player.cs`
- [Rooms and Exits](https://github.com/alanmet/zork/blob/main/zrok/zrok/Room.cs): `zrok/zrok/Room.cs`
- [Trap Door Room](https://github.com/alanmet/zork/blob/main/zrok/zrok/TrapDoorRoom.cs): `zrok/zrok/TrapDoorRoom.cs`
- [Window Room](https://github.com/alanmet/zork/blob/main/zrok/zrok/WindowRoom.cs): `zrok/zrok/WindowRoom.cs`

### Items and Inventory

- [Inventory](https://github.com/alanmet/zork/blob/main/zrok/zrok/Inventory.cs): `zrok/zrok/Inventory.cs`
- [Items](https://github.com/alanmet/zork/blob/main/zrok/zrok/Item.cs): `zrok/zrok/Item.cs`
- [Containers](https://github.com/alanmet/zork/blob/main/zrok/zrok/Container.cs): `zrok/zrok/Container.cs`
- [Lamp](https://github.com/alanmet/zork/blob/main/zrok/zrok/Lamp.cs): `zrok/zrok/Lamp.cs`
- [Trophy Case](https://github.com/alanmet/zork/blob/main/zrok/zrok/Trophy%20case.cs): `zrok/zrok/Trophy case.cs`

### Other components

- **Player**
- **Console**
- **Save File**

## Connections

- Player → Console: enters commands
- Game Loop → Console: reads and prints (evidence: `zrok/zrok/GameRunner.cs`)
- Game Loop → Adventure State: creates and updates (evidence: `zrok/zrok/GameRunner.cs`)
- Game Loop → Command Parser: forwards commands (evidence: `zrok/zrok/GameRunner.cs`)
- Game Loop → Save File: serializes state (evidence: `zrok/zrok/GameRunner.cs`)
- Save File → Game Loop: restores state (evidence: `zrok/zrok/GameRunner.cs`)
- Adventure State → Player Actions: creates and describes (evidence: `zrok/zrok/Adventure.cs`)
- Command Parser → Word Types: classifies words (evidence: `zrok/zrok/Adventure Parser.cs`)
- Command Parser → Player Actions: dispatches actions (evidence: `zrok/zrok/Adventure Parser.cs`)
- Command Parser → Trap Door Room: checks room type (evidence: `zrok/zrok/Adventure Parser.cs`)
- Player Actions → Rooms and Exits: moves through (evidence: `zrok/zrok/Player.cs`)
- Player Actions → Inventory: updates inventory (evidence: `zrok/zrok/Player.cs`)
- Player Actions → Containers: opens and transfers (evidence: `zrok/zrok/Player.cs`)
- Player Actions → Lamp: lights and unlights (evidence: `zrok/zrok/Player.cs`)
- Player Actions → Window Room: handles window room (evidence: `zrok/zrok/Player.cs`)
- Rooms and Exits → Items: holds items (evidence: `zrok/zrok/Room.cs`)
- Containers → Items: holds items (evidence: `zrok/zrok/Container.cs`)
- Inventory → Items: stores items (evidence: `zrok/zrok/Inventory.cs`)
- Lamp → Items: extends item (evidence: `zrok/zrok/Lamp.cs`)
- Trap Door Room → Rooms and Exits: extends room (evidence: `zrok/zrok/TrapDoorRoom.cs`)
- Window Room → Rooms and Exits: extends room (evidence: `zrok/zrok/WindowRoom.cs`)
