Inspiration

Noir detective fiction has always been about atmosphere and deception — a world where everyone lies and the truth hides in the spaces between words. We wanted to build a game that felt like stepping into a 1940s interrogation room, where the AI isn't just a gimmick but the actual engine driving the mystery.

What it does

Last Witness is a browser-based noir detective game where every case is uniquely generated by AI. No two playthroughs are alike.

  • The AI creates a fresh murder case each game: victim, setting, motive, clues, and three suspects — one of whom is the killer
  • You interrogate each suspect in natural conversation. The AI plays each character with a distinct personality, alibi, and secret. The killer actively lies and deflects; innocent suspects hide their own smaller secrets
  • You pin clues to your evidence board, take notes, and when you're ready — make your accusation with written reasoning
  • The AI delivers a dramatic noir verdict, revealing the truth and judging your deduction

How we built it

Built as a single-page React application that calls the Anthropic Claude API directly. The AI does three distinct jobs:

  1. Case generation — a structured JSON prompt produces the entire mystery: victim, suspects with secrets, real clues, and red herrings
  2. Character roleplay — each suspect gets a tailored system prompt with their personality, alibi, secret, and whether they're the killer. Responses stay in period-accurate noir voice
  3. Verdict narration — a final prompt receives your accusation, reasoning, and the true answer, then generates a dramatic close to the case

Challenges

The hardest problem was keeping suspect characters consistent across multiple questions. We solved this by passing full conversation history with each API call, so each NPC remembers everything they've said and can't contradict themselves — making interrogation feel genuinely tense.

Getting the case generator to reliably output valid JSON with exactly the right structure (3 suspects, 1 killer, 2 real clues, 2 red herrings) required careful prompt engineering and error handling.

What we learned

How much prompt structure matters — the difference between a vague "generate a mystery" prompt and a precise schema-driven one is the difference between chaos and a playable game. Also that giving the AI a strong stylistic voice ("speak in 1940s noir style, maximum 3 sentences") produces dramatically better character dialogue than leaving it open-ended.

Built With

Share this project:

Updates