Friday 23 October 2020

Murder Mystery Generator

 I created a small program that generates a murder mystery. The source can be found here: https://gitlab.com/Elmosfire/murder_mystery_generator. The backstory is as follows (details can differ, it is a generator of course.)

5 people are invited to a rich's persons mansion, on a Sunday at 14:00. They all stay there in different rooms, meeting with different people, and at the end of the day, after everyone went home, the body is found. You, as an investigator, are tasked with finding out who murdered him. Your subordinates have already done the tasks like interviewing the suspects and witnesses, gathering DNA, and so on, but it is your task to interpret this information and find out who the killer is.

Mechanically it works like this: each person is located at a given place each hour. They will report each hour where they were, and which other people they saw in the same room. People might forget information, and they might lie, but they will never accidentally report false information. If people were committing a crime, they will lie about there whereabouts, otherwise they will tell the truth, as long as their memory serves them. But beware, the murder is not the only crime committed, people will often lie because they were committing unrelated crimes like:

  1. Thief: A person was alone in a room.
  2. Affair: Two people were together in a room. 
  3. Secret meeting: Three people were together in a room.
No matter the crime, these people will always lie and state they were somewhere else.

You can analyse the following information:

Witness report

A person will state for every hour in which room they were, what other people they saw there and how many people they saw, if they remember. They might lie if they were committing an aforementioned crime. The murder victim will not have a witness report, and will also never be spotted after the crime (although people might claim they spotted him).

Name of murder victim

The name of the murder victim

Dna evidence

Dna of people can be found in rooms they were in. Note absence of DNA is no proof a person was not there, but existence of DNA proofs 100% the person was there.

Inventory report

Art will be missing from rooms where a "thief" crime happens.

Smart Lights

Lights will always have been on if there was at least one person in the room, otherwise, they would be off. They are logged for every room at every time.


All clues will be delivered in both a txt human-readable format, and a computer-readable format. Usually it is solvable, but this is not guaranteed. A solving algorithm using a saving backtracked is included, but a human with pen and paper usually can solve this riddle faster than a computer can, as humans are naturally good at backtracking.