One probability engine. Three interfaces. A stubbornly counter-intuitive result.
Monty Hall Lab demonstrates why switching doors wins roughly twice as often as staying. The shared TypeScript simulation engine powers a deliberately terminal-like Vue interface, a documented Hono API, and a local Node.js CLI.
The browser runs the engine locally—no request or cold start is needed for the interactive simulation. The API and CLI also accept optional seeds when a run needs to be reproducible.
Assume the host always opens a goat door, always offers the switch, and chooses randomly when either goat door can be opened.
Your first choice has only a one-in-three chance of being right:
The other two doors jointly carry the remaining two-thirds probability. Monty’s informed reveal removes a goat, not probability, so that full chance lands on the only unopened alternative:
Equivalently, after choosing door 1 and seeing Monty open door 3:
The simulation does not create the result; it makes the convergence toward
┌─ Vue workbench (runs locally in the browser)
packages/simulation ──┼─ Hono API (Cloudflare Worker)
└─ Node CLI (terminal / scripts)
packages/simulation Framework-independent seeded simulation engine
apps/web Vue 3 + Vite interface and convergence chart
apps/api Hono API, OpenAPI contract, and Swagger UI
apps/cli Node.js command-line interface
Open the live simulator, choose a sample size, and run the experiment. Dark and light themes are available from the title bar.
Explore requests interactively in the public API docs, or use curl:
curl -X POST https://monty-hall-lab.monty-hall-api.workers.dev/api/simulate \
-H 'Content-Type: application/json' \
-d '{"trials":10000,"strategy":"both","seed":42}'strategy accepts stay, switch, or both. Requests are capped at 1,000,000 trials. The raw contract is available at /api/openapi.json.
pnpm simulate --trials 10000 --strategy both --seed portfolio
pnpm simulate --trials 100 --jsonRequires Node.js 22+ and pnpm.
pnpm install
pnpm devThe Vue app runs at http://localhost:5173. Run the Worker separately for the API and docs:
pnpm dev:apiThe API is at http://localhost:8787/api; Swagger UI is at http://localhost:8787/docs.
pnpm test
pnpm typecheck
pnpm buildThe Worker configuration serves the built Vue app as static assets and routes /api/* and /docs through Hono. After authenticating Wrangler with a Cloudflare account:
pnpm run deployThat produces one free-tier-friendly Cloudflare deployment for the app, API, and documentation.