# Build a runnable simulation to learn how a technical system works

A small, commented program you can run to see a protocol or system in action, with experiments to try.

- Topic: Learning & Teaching
- Framework: Few-Shot
- Level: Standard
- Tags: Coding, Fill-in Template, Step-by-step
- Source: https://www.thinkwithprompt.com/prompts/build-a-runnable-simulation-to-learn-how-a-technical-system-works

## Prompt

```text
Build a small simulation I can run to understand how a technical system or protocol works by watching it in action.

**What I want to understand:** [e.g. "how CAN bus messages and arbitration work in a car ECU", "how TCP handshakes work", "how a thermostat PID loop works"]
**My current level:** [beginner / know the theory / work near it]
**Language:** [e.g. Python, standard library only if possible]
**Where I'll run it:** [laptop terminal, Jupyter, browser]

Requirements:
- One file I can run immediately, with any install steps listed up front.
- Model the core mechanics faithfully but simply. For a protocol, show the actual message structure (fields, IDs, checksums) and timing; for a control system, show inputs, state, and outputs.
- Print clear, step-by-step output so I can follow what happens and why (e.g. "Node B loses arbitration: its ID 0x200 has a recessive bit where 0x100 is dominant").
- Include at least one realistic failure or edge case (error frame, collision, packet loss, sensor noise) and show how the system handles it.
- Comment the code to explain concepts, not just syntax.
- Keep it under ~200 lines unless more is truly needed.

Return:
1. A plain-language explanation of the system in under 150 words.
2. The code.
3. Sample output with notes on what each part shows.
4. Three experiments I can try by changing parameters, and what I should expect to see.
5. Where the simulation simplifies reality, so I don't learn anything wrong.
```

## What to fill in

- beginner / know the theory / work near it
- e.g. Python, standard library only if possible
- laptop terminal, Jupyter, browser

Free to copy and use. From ThinkWithPrompt (https://www.thinkwithprompt.com/), a library of 2,663 curated AI prompts.
