Skip to content

About

A daily murder mystery to solve in less than 5 minutes! (https://mystery-o-matic.com)

Topics

Resources

Stars

125 stars

Watchers

3 watching

Forks

Repository files navigation

mystery-⚙️-matic

Support mystery-o-matic.github.io on drips.network

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:

Screenshots

or visit mystery-o-matic.com for a live version.

Installation

Make sure all the requirements are met. If you are using Ubuntu:

sudo apt-get install libsecp256k1-0

Solidity 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.17

Finally, 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.

Usage

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 out

The tool will produce a static index.html file stored in the out directory.

Fast testing with precomputed state ✅

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.json

This is useful to iterate quickly on templates and output generation without waiting for the solver.

Direct book exports from saved JSON

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.json

The 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.

Regenerating tutorial maps

The tutorial maps use the same renderer as generated mysteries. Recreate every English, Spanish, and Russian tutorial SVG with:

python3 scripts/render_tutorial_maps.py

Adding a new language

Clue 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):

  1. Create mystery_o_matic/lang/pt.py with a class that extends LanguageRenderer and implements all its abstract methods (see lang/en.py as a reference). Call register_renderer(PortugueseRenderer()) at the bottom of the file.
  2. Import the new module in mystery_o_matic/mystery.py:
    import mystery_o_matic.lang.pt  # noqa: F401
  3. Add the language code to the languages list in __main__.py (e.g. ["en", "es", "ru", "pt"]).
  4. Create the HTML template at static/pt/index.template.html (copy an existing one and translate the UI).
  5. Add the new package to setup.py in the packages list.

Integrations

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)

Scenarios

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 SawWhenLeaving and SawWhenArriving but 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)

Donations

If you want to support the development, you can donate using crypto to 0xd0FD96CD73762Fd081cf2269D79F359e4314629b (ETH, BSC, etc)

About

A daily murder mystery to solve in less than 5 minutes! (https://mystery-o-matic.com)

Topics

Resources

Stars

125 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages