Inspiration
Detective fiction has always been about reading people — watching for hesitation, catching contradictions, and trusting your instincts. But in traditional mystery games, every suspect says the same thing every time. The dialogue is scripted, the lies are fixed, and once you know the answer, the illusion breaks completely.
We wanted to ask a different question: what if the suspects actually thought for themselves?
The inspiration for VERDICT came from combining two ideas — the tension of a classic noir interrogation scene, and the recent accessibility of local AI models through Ollama. If each suspect could be driven by a language model with a carefully designed personality and a secret to protect, the interrogation would feel genuinely unpredictable. The player would have to actually listen, not just click through dialogue trees.
We also wanted to build something that ran entirely locally — no API costs, no data leaving the machine, no internet dependency during a live demo. That constraint shaped the entire project.
What it does
VERDICT: The AI Detective is a browser-based murder mystery game where every suspect is powered by a local AI.
Victor Ashford, a wealthy businessman, has been found dead. Four suspects are in custody: his personal butler Thomas Chen, his wife Lady Eleanor Ashford, his business partner Dr. Raymond Mercer, and his niece Sophie Hartley. Each one had motive, access, and something to hide.
The player takes on the role of detective and must:
- Enter each suspect's interrogation room and question them freely using natural language
- Collect key statements to an evidence board
- Use a contradiction analysis tool to surface inconsistencies across suspect testimonies
- Issue a single final verdict — one accusation, no second chances
Each suspect is driven by a distinct system prompt that defines their personality, speech style, hidden alibi, and the specific lie they will defend under pressure. The AI maintains character across the full conversation, remembers what was said earlier in the session, and subtly shifts its story when directly challenged.
How we built it
The entire game runs as a single HTML file with embedded CSS and JavaScript — no frameworks, no build tools, no backend.
AI Layer Each suspect is powered by Ollama running llama3.1:8b locally. Every API call goes to localhost:11434 using the standard Ollama chat completion endpoint. Each suspect maintains an isolated conversation history array, so the AI remembers earlier exchanges within the same interrogation session.
Prompt Engineering The core design challenge was making four characters feel genuinely different using only system prompts. Each prompt defines personality traits, speech patterns, a secret, and a lie. The contradiction analysis feature uses a separate system prompt that is explicitly forbidden from naming a guilty party — it can only surface inconsistencies and leave the conclusion to the player.
Game State All state is managed through a single global gameState object. Suspect interview status, suspicious flags, per-suspect timer values, and the evidence array all live here. This prevents state loss when navigating between the suspects board and individual interrogation rooms.
UI and Design The visual design follows a noir aesthetic — deep charcoal backgrounds, warm gold typography, serif display fonts, and subtle CSS animations. The entire interface was built with vanilla CSS including the evidence board, status badges, timer display, and verdict room.
Challenges we ran into
Gemini API rate limits We initially built the game using the Gemini API but hit rate limit walls almost immediately during testing. With 15 requests per minute on the free tier and multiple suspects to test, the quota exhausted within minutes. We eventually switched to Ollama for fully local inference, which solved the problem entirely and removed the dependency on external services.
Keeping suspects in character Early versions of the AI would break character when players asked direct questions like "are you the killer?" or "just tell me the truth." We solved this through more aggressive system prompt constraints, explicit behavioural rules, and fallback instructions for when the model was uncertain how to respond while staying in character.
Game state persistence Navigating between views caused JavaScript variables to reinitialise, resetting suspect statuses and wiping the evidence counter. We refactored all mutable state into a single persistent gameState object that is only written to, never re-declared.
Markdown rendering AI responses came back with raw markdown syntax — asterisks and hashes displayed as literal characters. We wrote a lightweight markdown-to-HTML converter function and applied it to all AI output containers before DOM insertion.
Timer design Starting the timer on room entry penalised players who needed time to read previous conversation history before asking a new question. We changed the timer to activate only on the first submitted question, which made the pacing feel significantly fairer.
Accomplishments that we're proud of
- Four AI characters that feel genuinely distinct in personality and speech style, achieved entirely through prompt engineering with no fine-tuning
- A fully local implementation with zero external API dependencies during gameplay — the game runs completely offline after the model is downloaded
- A contradiction analysis system that assists the player without spoiling the answer — the AI is explicitly constrained to surface inconsistencies rather than render a verdict
- A complete game loop from intro page through interrogation, evidence collection, contradiction analysis, and final verdict — all within a single HTML file
- Noir visual design built entirely in vanilla CSS that holds up across the full game
What we learned
Prompt engineering is game design. Writing a system prompt for a fictional character is surprisingly close to writing a character bible for an actor. The more specific the constraints — speech patterns, emotional triggers, what the character will never say — the more consistent and believable the performance.
Local AI changes what is possible at a hackathon. Running llama3.1:8b locally through Ollama meant we never had to worry about API costs, rate limits, or connectivity during the demo. For a hackathon context, that reliability is worth more than the marginal quality difference between local and cloud models.
State management matters even in vanilla JS. The decision to centralise all game state into a single object early on saved significant debugging time later. Scattered variables across functions created subtle bugs that were hard to trace — the refactor to a single source of truth resolved most of them in one pass.
Error handling is part of the user experience. Generic fallback messages like "the suspect refuses to answer" told the player nothing useful. Replacing them with specific, contextual error states — including actual API error details during development — made debugging faster and the game feel more polished.
What's next for VERDICT: The AI Detective
Randomised case generation Currently the killer is always Dr. Mercer. The next version would use AI to generate a fresh case on each playthrough — different victim, different suspects, different killer — so the game has genuine replayability.
Cross-examination system Allow the player to bring a specific piece of evidence from one suspect's testimony into another suspect's room and directly confront them with it. This would make the contradiction-finding mechanic more interactive and satisfying.
Suspect memory across sessions Right now conversation history is session-only. A persistent memory layer would allow suspects to reference things said in earlier visits, creating a more dynamic and consequential interrogation experience.
Voice synthesis Adding text-to-speech with distinct voice profiles for each suspect would significantly improve immersion, especially during a live demo.
Mobile support The current layout is desktop-first. A responsive redesign would make the game accessible on phones and tablets without requiring a keyboard.
Multiple difficulty levels On harder difficulties, suspects would be more evasive, give shorter answers, and require more targeted questioning to crack. On easier difficulties, suspects might slip up more obviously and leave clearer trails.
Built With
- ai
- html
- ollama