Introduction
Whodunnit is an investigative game that places the player in the role of a detective tasked with solving automatically generated mystery cases. The objective is to identify the culprit of a crime by analyzing clues, interrogations, documents, and relationships among the characters involved in the case.
Game Concept
Each Whodunnit game presents a unique investigative case, dynamically generated by an artificial intelligence-based system. The case includes a narrative plot, a set of characters with different roles (suspects, victims, witnesses), a series of investigative documents (emails, messages, interviews, diaries), and a hidden solution that the player must discover.
The gameplay revolves around the progressive construction of a knowledge graph, a visual representation of the relationships among case elements. The player explores available documents and, based on the collected information, builds connections between characters, events, and evidence. Each connection added to the graph represents an investigative hypothesis formulated by the player during the investigation.
Game Mechanics
The game is based on three fundamental pillars:
Clue exploration: the player has access to a series of investigative documents that provide information about the case. These documents include correspondence between characters, interview transcripts, personal diaries, and other materials containing clues more or less relevant to solving the mystery.
Knowledge graph construction: as the player analyzes the documents, they can build a directed graph representing the relationships among case elements. Graph nodes can be characters or documents, while edges represent semantic connections between them (e.g., "met with", "is enemy of", "mentions"). The ability to visualize and manipulate these relationships allows the player to identify patterns and formulate investigative hypotheses.
Dynamic hint system: during the investigation, the player receives hints generated by a rule-based system that analyzes investigative behavior. These hints can be helpful, directing the player toward promising directions, or misleading, simulating false leads typical of real investigations. The system evaluates metrics such as graph coverage relative to the solution and connection density, adapting hints to the player's progress.
Game Flow
A typical game session unfolds according to the following phases:
Case generation: at the start of a new game, the system automatically generates a complete investigative case, including plot, characters, documents, and solution. Generation occurs through a language model that respects constraints of narrative coherence and playability.
Plot presentation: the player receives a narrative description of the mystery to solve, introducing the main characters and outlining the investigative situation.
Investigative phase: the player explores available documents and builds the knowledge graph, formulating hypotheses about the relationships among case elements. During this phase, the system provides hints based on the analysis of investigative behavior.
Resolution: when the player believes they have gathered sufficient evidence, they can make an accusation by identifying the culprit. The system validates the solution by comparing the constructed graph with the prerequisites defined in the correct solution.
Feedback: at the end of the game, the player receives feedback indicating whether the proposed solution is correct and what the actual solution to the case was.
Distinctive Features
The system implements advanced features that enrich the gaming experience:
Time-travel and versioning: the player can navigate through the history of changes made to the knowledge graph, returning to previous investigation states. This feature allows exploring alternative hypotheses without losing completed work, simulating the iterative process of a real investigation.
Undo/redo operations: every graph modification can be undone or restored, offering the player freedom of experimentation without permanent consequences (with an action window limited to 5 moves).
Automatic generation with constraints: the case generation system can operate with thematic constraints (e.g., historical setting, narrative genre) to create different experiences in each game, maintaining coherence and playability.
Investigative behavior analysis: the system monitors player actions and graph metrics over time, using this information to generate contextual hints that guide or challenge the player.
Technologies and Architecture
Whodunnit is implemented in Scala 3, leveraging functional programming paradigms and a modular architecture based on the Model-View-Controller (MVC) pattern. The graphical interface is built with ScalaFX.
Automatic case generation utilizes Large Language Models (LLMs) through external APIs, while game logic is based on immutable data structures that facilitate the implementation of features such as versioning and time-travel. The hint system uses an internal Domain-Specific Language (DSL) to define rules for analyzing investigative trends in a declarative and expressive manner.