The Detective — A Procedural Mystery That's Provably Solvable
Crime scene, suspects, alibis, clues. The puzzle has a 4-step solvability proof and a built-in solver that re-rolls if generation produces ambiguity. Make your accusation.
What this is
A procedural murder mystery with a provably-solvable solution. The generator picks a victim, 4-5 suspects with motives + alibis, a weapon, a location, a time. Then it plants clues: EXCLUDE clues for each innocent (a signed receipt placing them somewhere else at crime time), INCRIMINATE clues that point only to the guilty (a unique trace at the scene + a maid's diary entry). Then it RUNS a built-in solve() function to verify the puzzle yields exactly the guilty suspect — re-rolling with seed+1337 if not. Investigation: 5-7 locations to explore, evidence objects to click, witnesses to interview (innocents tell truth, guilty lies). Notebook accumulates clues and suspect cards. Accuse with suspect+weapon+location triple. Game shows the deduction trail: green checks for matching clues, red X's for misses.
Why this is mind-blowing
Generating fiction is easy. Generating SOLVABLE puzzle fiction is hard. This nails it with a generate-and-verify loop in 1325 lines from one paragraph. The same approach scales to procedural Sudoku, crossword, escape room — anything that needs a unique solution.
Single-file procedural detective game. Generate a fully consistent
murder mystery: random victim, 4-5 suspects with motives + alibis,
weapon, location, timeline. Plant clues throughout an interactive
crime scene. The crime IS solvable from the evidence — exactly one
consistent solution. Player accuses; game reveals correctness.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Solvability proof in 4 steps: guilty's truth-loc = crime location, EXCLUDE clues planted for innocents, INCRIMINATE clues point only to guilty, run a built-in solve() that verifies uniqueness or re-rolls with seed+1337. The puzzle is provably consistent BEFORE play begins.
- Innocents tell truth in interviews; guilty lies. The lie is only refutable by finding the trace clue at the scene. That's the entire detective genre's deduction structure in one design rule.
- Re-rolling with seed+1337 if the solver doesn't yield exactly the guilty suspect is the simple insurance against pathological generations. Generate-and-verify beats clever generation.