Sponsored By

Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

Procedural generation and emergent narrative #3 : Murder we wrote!

Wouldn't it be awesome to have a detective game with endless murders to solve? Though it seems quite unreasonable in terms of production. Could we create a quest generator for it? Let's discuss it!

Luis Diaz, Blogger

July 22, 2015

9 Min Read

Hey!

This is the third part on a series of articles about emergent narrative and procedural generation (fancy tittle, right? :P)

You might want to read the introduction and the second article before starting this one. You might also find this post-mortem of mine helpful, who knows?

I'm still kind of a newbie when it comes to writing these kind of articles, so leave me a comment telling me what you liked or disliked about the text. Some parts of the article are a bit vague, and that's intentional (as explained below)

3.0 Disclaimer

- I'm not defending emergent narrative(and procedural generated) against tradtional narrative, it's just easier to make a huge amount of the first. Most games benefict from having a strong plot, but I believe some cool projects require quantity over quality, just like Minecraft wouldn't be the same with just a single map (even if it was awesome).

- This is not a design document. I'm just saying out loud some ideas and issues found along the way. Filling the gaps can be done in many different ways, so most times I just ramble about some solutions that came to my mind. The point of this article is to give you another gamedev tool which might turn out to be useful.

- The tech and code that I'm describing is no thing of the future. Check out Ultima Ratio Regum if you'd like to see something really impressive made using procedural generation.

3.1 Introduction

Last time we talked about a game featuring evolving squirrels, which isn't very exciting narrative-wise, but it was necessary to introduce procedural generation without involving map-creation.

Today we're going to discuss a more interesting concept. Have you played one of those detective games and ended up longing for more cases to solve? I think this genre could benefit A LOT from having a "quest" generator. But making something like that won't be easy, as I wrote on a previous article, the hard part is to come up with the logic rules that sustain our system. In this case we would need a set of logic rules to model human behaviour, getting a realistic system seems like an impossible task, so we're aiming for something more limited. I've prototyped something very basic, but we're going to start over in here.

Just a quick reminder before beginning! This was written to serve as an inspiration so you use similar systems in your own projects, this is not a design document for a real project.

3.2 Explaining the idea

So let's try to get everyone on the same page(though it's really hard to explain a game idea just with words). Imagine a 2D top-down game where you can move around a city, enter every house and speak with people. In fact, let's try to imagine something which looks like Hotline Miami, where you can go around a whole city and talk to people instead of killing everyone.

To have a working prototype we'd need:

a) A city to explore (which won't be covered on this article since it's not one or our goals. You can design it manually or generate it using procedurally).

b) A set of characters of characters.

c) A murder/case to solve

let's just move on to the next point...

3.3 Creating a set of characters!

I have explored two different methods that seem to work. One is extremely cool but also harder to implement, the other is still decent but way easier to make.

I like to call the cool one the "Adam and Eve" method, cause I use a pair of "characters" and iterate 'til I have a whole community. The simple one doesn't have a tittle and remains nameless, we skip the whole descendants thing, create a bunch of random families and set up artificial relationships between them.

QUICK NOTE! Creating relationships or links between those characters is as important as the rest. Have you seen a cool detective movie or book where the villain was some random guy who didn't know the victim? Me neither! Figuring out the links and putting the pieces together is part of the fun, so we gotta make sure we have them in our game.

Before getting to generation we need to set up what parameters define our characters. It might be something based on RPG systems (strength, speed, faith, etc), something liked the sims (introvert/extrovert, intelligence, etc) or something completelly new, be creative and think out of the box!

These are the ones I've chosen for the sake of our example:

[ name , surname , gender , age , job , family status , personality ]

This is what I meant when I said we need to establish limits, those 7 parameters couldn't really describe a person, but for the sake of production we need to choose just a few ones that can be informative enough.

We also need an array of relationships for each character, this will serve us to collect all the basic links between our characters. And don't forget about setting all the possible values for each parameter(remember to limit those). For example, we might use this for the relationships array:

[ unknown, acquaintance , friend , relative , close friends, lover ] or translate those into a metric system if that sounds easier ---> { 0=unknown, 1= acquaintance, ... , 5=lover}

3.3.a The "Adam and Eve" method

Let's start with our initial couple, we just need to set their parameter as we want (though they must have different gender for obvious reasons). If you've read the previous articles you know we need to write down the rules for the main loop which is going to create all the content.

For this example my iteration unit will be "generations", so we'll just jump from one generation to the next. Sure, you can use "years" as a unity, though that will make everything more complex. Boundaries man!

MAIN LOOP:

(1) Pick a subject

(2) Decide wether if it's going to have descendants of this iteration or not (what's the chance of him/her having a son?)

(3) Pair with a random subject of the opposite gender

(4) Decide the amount of descendants

(5) Set a value for each parameter of each descendant

(6) Go back to one 'til we're done with the whole population

END OF THE LOOP

Each step of the loop would require a further examination if this was to be a real project. For example... how would we decide the value of each parameter of a given descendant? how would parents influence "personality" or "job"(or any parameter that you've chosen) ? That's remain for the designer to choose.

The greatest thing about this method is that we end up with a whole set of links between the members of the population, and those are a bit less artificial than what we could get by using the other method.

3.3.b The nameless method

I wouldn't say this second method uses procedural generation as there's no iteration of data involved. Instead we just create a few families with random values and establish relationships between them. Once again, the hard part is to come up with a logic system which models something as complex as human emotions and relations, but we're not lookin for something realistic, just something we can use in a game.

3.4 Creating a crime!

Once we have a town to explore and filled with characters who know each other it's time to make somebody kill one of his neighbours(as cruel as that may sound). For this part it'd be nice to consult a book about criminology or some expert on the matter. Once again, and for the sake of this article, let's pretend I know about stuff, let's say that there are three main reasons to murder, money, pasion/love and having some kind of mental issue.

We pick one random subject who kills another random subject(with whom he/she has some kind of relationship). Once that's done we have the first part of our game ready, there's a case to solve and it makes some sense, but there's something big missing, the gameplay part, how does the player find the killer?

NOTE: How to pick victim and killer is one of those gaps waiting to be filled.

3.5 Solving the crime!

In most mystery games players usually find objects with clues or spend their time talking to other characters in order to advance in the plot. But there's always a catch in these situations, is there anyway we can write down logic rules to model this? Is there a pattern in all these stories that we can use? I believe there is, just like "Joseph Campbell's Monomyth".

When I'm generating maps which need a starting point and a goal (ex: Spelunky) I usually draw a line between those two areas and then make it wider adding more tiles(or noise); it's like writing the perfect solution to a puzzle and then adding "noise" in order to make it look it like something more open. That might be one of the possible solutions for this game/concept. We choose the starting point(the victim) and we generate some noise around the killer, maybe people close to them who saw something or knows something that might help unraveling the mystery.

Maybe we could have a game where you talk to other characters to narrow the list of suspects and then run DNA tests on objects from the crime scene to find out who did it. There's a last gap for you to fill.

Making decent dialogues in a random generated world is something complex that we could discuss for ages, but it's not the point of this text. It might be a nice topic for a new article.

3.6 Closing thoughts

I hope you gained some interesting insights from reading all of this rambling. I might keep up with this series of articles or switch to a different topic. I'm not sure how helpful is discussing my mental process and discoveries about these weird ideas, let me know on the comments. Just don't forget about theses systems, they might lead you to some cool projects in the future.

Follow me on twitter for more nonsense rambling and gamedev.- @Ludipe

Read more about:

Featured Blogs

About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like