mystery-o-matic is a Python program used to produce the content of mystery-o-matic.com. It produces a random murder mystery to solve using fuzzing testing. Once a mystery is generated, it produces a static html file that contains all the clues (and the solution to verify it).
mystery-o-matic supports the following languages:
or visit mystery-o-matic.com for a live version.
Make sure all the requirements are met. If you are using Ubuntu:
sudo apt-get install libsecp256k1-0Solidity 0.8.x is needed, so we can install solc-select for that:
pip install solc-select
solc-select install 0.8.17
solc-select use 0.8.17Finally, install the tool from this repository:
pip install .mystery-o-matic requires the usage of echidna for obtaining a random mystery prompt and its solution but uses a specific PR that has not been merged yet. For convenience, there is a precompiled binary provided in the bin folder. Otherwise, it can be compiled from source code using stack or nix.
mystery-o-matic will always generate a fresh mystery to solve, but depending on the output mode (--mode) will produce different results:
html: generates a local copy of mystery-o-matic.com which contains the description of the case, some clues and the solution.text: starts an interactive version of a murder mystery to solve by specific commands. It can also start a Telegram bot if an API key is provided.latex: generates an includable book case with clues, worksheets and an inline TikZ map.
By default, it will use the html output to generate a new mystery in the default scenario:
mystery-o-matic scenarios/simple.template.sol static outThe tool will produce a static index.html file stored in the out directory.
For a fixed cast, use --characters Eddie Frida Alice Carol. Names are
case-insensitive and remain in the supplied model-slot order; the character count
is inferred unless --nchars is also supplied, in which case it must agree.
Combine this with --location castle to fix the setting. Omitting --characters
keeps random cast selection.
LaTeX output disables appearance-based clues because the book has no character
profiles. Use --no-appearance-clues to disable those clues in other output modes
as well; anonymous sightings still work. Newly saved states retain the cast,
initial clock time and room layout, and loading a state infers its cast size.
When developing or testing the website you can avoid the slow fuzzing step by saving a generated scenario to a JSON file and reloading it later:
- Save the current generated state:
mystery-o-matic scenarios/simple.template.sol static out --save-state test_state.json- Reload a previously saved state (skips the echidna solving step and regenerates the site quickly):
mystery-o-matic scenarios/simple.template.sol static out --load-state test_state.jsonThis is useful to iterate quickly on templates and output generation without waiting for the solver.
The normal CLI writes a complete case TeX file directly from a saved case:
mystery-o-matic scenarios/simple.template.sol static case-output \
--mode latex --load-state case-state.jsonThe exporter owns the shared page layout in mystery_o_matic/output/latex/book.py.
It generates room positions and corridors from the simulation graph using the
same layout engine as the website maps, and embeds the map directly as TikZ.
No per-case template, map image, coordinate editing or post-processing is needed.
The tutorial maps use the same renderer as generated mysteries. Recreate every English, Spanish, and Russian tutorial SVG with:
python3 scripts/render_tutorial_maps.pyClue text is generated through language renderers in mystery_o_matic/lang/. Each language has its own module implementing the LanguageRenderer interface.
To add a new language (e.g. Portuguese pt):
- Create
mystery_o_matic/lang/pt.pywith a class that extendsLanguageRendererand implements all its abstract methods (seelang/en.pyas a reference). Callregister_renderer(PortugueseRenderer())at the bottom of the file. - Import the new module in
mystery_o_matic/mystery.py:import mystery_o_matic.lang.pt # noqa: F401
- Add the language code to the languages list in
__main__.py(e.g.["en", "es", "ru", "pt"]). - Create the HTML template at
static/pt/index.template.html(copy an existing one and translate the UI). - Add the new package to
setup.pyin thepackageslist.
While the code is open-source, I'm aware of the difficulties of using or integrating other people's code. If you don't know or don't want to run this code directly, but you are still interested in using the output of this tool in your work of fiction (e.g. novel, game, film), please feel free to contact me so I can do that for you. The generated mystery will look like this:
Characters:
* CHAR1 is bob
* CHAR2 is carol
* CHAR3 is eddie
Final Locations:
* ROOM3 is kitchen
* ROOM2 is dining room
* ROOM0 is bedroom
* ROOM1 is bathroom
Solution:
Initial Locations:
* CHAR1 was in the ROOM1
* CHAR2 was in the ROOM2
* CHAR3 was in the ROOM3
Actions:
1. takesWeapon($CHAR3)
2. move($CHAR3, $ROOM0)
3. move($CHAR2, $ROOM1)
4. move($CHAR1, $ROOM0)
5. kills($CHAR3, $CHAR1)
6. move($CHAR3, $ROOM1)
The mystery generation involves using a Solidity smart contract. This was used because of the nature of blockchain transactions as operations, but everything is simulated so no cryptocurrency is involved. Instead, every transaction represents a possible state change in the murder mystery (e.g. Alice walks from the kitchen to the bathroom). If the state change breaks any rule (e.g. no more than two characters can be in the same room), then the transaction reverts and the fuzzing tool keeps exploring.
The tool provides a single scenario for creating a random murder mystery, where the rules are encoded in the scenarios/simple.template.sol file, but others could be added. To add a new scenario:
- Create a Solidity smart contract called
StoryModel - Encode the rules to advance every step of the story. Clues are generated using events such as
SawWhenLeavingandSawWhenArrivingbut others can be added as well. - Add an Echidna boolean property should be added
mystery_not_solved(which returns false when all the steps to complete a mystery are done)
If you want to support the development, you can donate using crypto to 0xd0FD96CD73762Fd081cf2269D79F359e4314629b (ETH, BSC, etc)
