# Games

2 of the bundled models. The numbers are from a run made when this page was generated: see [how](index.md#how-the-numbers-are-made).

## Emergency department: staffing game

A staffing game built on ed_patient_agents: patients run the same Stable -> Deteriorating -> Critical statechart through triage and a Doctor queue ranked by entity.agent.acuity. Two controls let a player staff Doctor (1-4) and Nurse (1-3) up or down mid-run; every 8 hours a Policy-mode DECIDE ('divert') asks whether to divert ambulances, which turns away 60% of new arrivals until reviewed again. In the results, read the doctor queue, doctor utilisation, waiting against critical patients, the acuity mix and the diverted count.

```console
naga run ed_game
```

```mermaid
flowchart LR
    b0["arrivals (CREATE)"]
    b1["divert_check (DECIDE)"]
    b2["diversion_chance (DECIDE)"]
    b3["assign_diverted (ASSIGN)"]
    b4["leave_diverted (DISPOSE)"]
    b5["triage (PROCESS)"]
    b6["seize_doctor (SEIZE)"]
    b7["treatment (DELAY)"]
    b8["release_doctor (RELEASE)"]
    b9["notify_treated (SEND)"]
    b10["time_in_system (RECORD)"]
    b11["leave (DISPOSE)"]
    b12["review_clock (CREATE)"]
    b13["divert_decision (DECIDE)"]
    b14["assign_stay_open (ASSIGN)"]
    b15["assign_divert (ASSIGN)"]
    b16["leave_review (DISPOSE)"]
    b0 --> b1
    b1 --> b2
    b1 --> b5
    b2 --> b3
    b2 --> b5
    b3 --> b4
    b5 --> b6
    b6 --> b7
    b7 --> b8
    b8 --> b9
    b9 --> b10
    b10 --> b11
    b12 --> b13
    b13 --> b14
    b13 --> b15
    b14 --> b16
    b15 --> b16
```

3 replications, seed 0:

| KPI | Mean | 95% half-width |
|---|---|---|
| `system/Total Entities Completed` | 325 | 37 |
| `system/Avg Throughput Time` | 0.632 | 0.059 |
| `system/Avg Queue Length` | 0.0564 | 0.045 |
| `system/Avg Resource Usage %` | 31.3 | 5.6 |
| `user/time_in_system` | 0.656 | 0.059 |
| `agent/Patients/Stable/Avg Count` | 1.29 | 0.33 |
| `agent/Patients/Deteriorating/Avg Count` | 0.592 | 0.11 |
| `agent/Patients/Critical/Avg Count` | 0.427 | 0.091 |
| `agent/Patients/Discharged/Avg Count` | 0 | 0 |

## Supply line: order-rate management game

A one-echelon, beer-game-style supply line: Inventory is replenished from a Supply Line pipeline through a 3rd-order shipping delay (DELAY3); customer demand steps up in week 5. A negative Inventory level IS the backlog, so one stock covers both. Every week a Policy-mode DECIDE ('order') asks the player to set the order rate low/medium/high, with a finer control beside it; Total Cost accumulates holding and backorder cost. In the results, read on-hand inventory against backlog, total cost and the service level.

```console
naga run sd_supply_game
```

```mermaid
flowchart LR
    b0["weekly_review (CREATE)"]
    b1["order_decision (DECIDE)"]
    b2["assign_low (ASSIGN)"]
    b3["assign_medium (ASSIGN)"]
    b4["assign_high (ASSIGN)"]
    b5["leave_review (DISPOSE)"]
    b0 --> b1
    b1 --> b2
    b1 --> b3
    b1 --> b4
    b2 --> b5
    b3 --> b5
    b4 --> b5
```

1 replication, seed 0:

| KPI | Mean | 95% half-width |
|---|---|---|
| `system/Total Entities Completed` | 41 |  |
| `system/Avg Throughput Time` | 0 |  |
| `level/Inventory/Average` | -54.7 |  |
| `level/Supply Line/Average` | 52.8 |  |
| `level/Total Cost/Average` | 1,260 |  |
