AGS Awards nominations close at 13:59 GMT on Saturday 10 February 2018. You haven't yet nominated, so you've got 18 days and 6 hours left to play the games and decide which to nominate!

Author Topic: Procedural detective game  (Read 556 times)

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Procedural detective game
« on: 02 Jan 2018, 20:42 »
Hello.

I would like to tell about one idea that interests me. I had it for quite a long time in a form of random thoughts, but recently decided to go and try implementing this even if in a limited form, for starters.

This idea is of procedurically generated detective adventure game.

There was a pretty good number of procedural games in the past, so I guess everyone can imagine what is it in general. I've also seen procedural detective games before. Although I must admit that haven't played much of them, so cannot know many details, but the ones I've seen were mainly based on randomization of predefined roles and scenarios. While that may work perfectly for the game, my intention was to go further (or deeper), and instead of randomly granting every character a role (killer, victim, thief, witness, etc), grant them conflicting personalities and ambitions, that may randomly result in committing a crime under "fortunate" circumstances.

As such this is not only a game project, but also a research project about building a character AI. Or maybe even "story AI".

If you think above is a bit vague, let me give an example.

Imagine there is a mansion full of party guests. Each guest has particular personality traits and wishes assigned at the game's generation. Guests are wandering around the house, following certain rules (like avoiding restricted areas).
Consider one of the guests have a "cleptomaniac" personality, or maybe there is "financial problems" issue troubling them. This character enters a room with some "expensive item" on the showcase. A combination of character's traits and aims gives them a motive to steal the item. They wait for the right moment and do that. This is how the crime takes place.

The peculiarity of this approach that intrigues me much - is that since there are no predefined roles, not only player does not know who the criminal is, but even the game does not "know" that, until crime happened. In fact, there is always a theoretical possibility that more than one crime may take place (with different motives and participants), and maybe even sequences of events following first crime help another one to occur.

As with any AI, it is a matter to programmatically depict decision making. This game would require explaining such things through the code, as the concept of crime itself, clues, motives, ambitions and aims, personality traits and conflicts, and on advanced level - planning a strategy through assuming sequential events, manipulating other people, and so forth.


Obviously such approach also makes it harder to create a flawless scenario, but the challenge is perhaps the interesting part here.
The final goal of this potential project is to create AI that would be flexible and smart enough to generate an interesting game.
« Last Edit: 02 Jan 2018, 20:49 by Crimson Wizard »

Re: Procedural detective game
« Reply #1 on: 02 Jan 2018, 23:46 »
In the party example you have a place (rooms, gardens,...), agents (the persons), properties of the agents (in this you probably have to define some relations between agents to generate motives), a crime (the easier would be murder, and then try to come up with other crimes). This kind of simulation model you proposed looks to be somewhat Agent Based Model, so that's why I refered to agents there. Make something simple first (here is an example of simple thing using agents, The Incredible Car Salesman , HTML5 made in Construct).

The game elements are not really clear yet though - would this happen before in black screen, and through clues and talking to people you would see flashbacks from what happened? If you are going for Agents, remember you will have to make some modifications to ensure: (1) a crime does happen, (2) this crime is solvable. On the game elements part, I am throwing some references below for stuff I remembered by reading the party description and could be useful. Also a crazy idea here would be to inverse the play in the system: You must commit a murder and then watch the detective agent solve it or not.


One of Us - PC Jam Game

Is a game where you walk in a village where someone is the wolf, who kills, every end of a day, after getting clues, you choose someone you believe to be the wolf, to be hanged. If the right person is chosen, the game ends, if not, the wolf kills someone, and you can again explore the village.


221 B Street - Board Game

This game is known as Scotland Yard here in South America, (the European Scotland Yard here is Interpol). You walk on the board going to different places collecting clues, clues are predefined from a book of a lot of cases, every play is a different case. With clues you can put together stuff like murder weapon, the name of the person who committed the crime, and other things. The game has interesting elements idea on how to gammify a case solving - like how you must race against other player to the Scotland Yard once you know the answers.

I really like board games for inspiration because they are usually game systems in the simplest form you can just look and experiment. If there is any local bar with boardgames, go there.


And Then There Were None - Book

This book has a cool story and is written by Agatha Christie. Her other books, featuring the detective Hercule Poirot have a nice catch: once Hercule states he knows who did it, you can stop reading, analyse the clues you have been giving and try to process then in your head. You can then proceed reading and see if you got things right. I like the setting of those books and the era they take place provide lots of Public Domain assets to stea... use.

Danvzare

  • The Man with No Name
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Procedural detective game
« Reply #2 on: 03 Jan 2018, 12:08 »
You know, I've had a similar idea for quite a while. But I've never tried making it because I know it would be too much work for me.

You may not know this, but there already kind of is a procedural detective game. It's a dos game called Sleuth. Coincidentally there's also a browser based game called Sleuth that's also a procedural detective game. Both of them are pretty decent as well.

Darth Mandarb

  • Evil Sith Lord
  • Mittens Vassal
  • AGS Baker
    • Lifetime Achievement Award Winner
    •  
    • Darth Mandarb worked on a game that was nominated for an AGS Award!
Re: Procedural detective game
« Reply #3 on: 03 Jan 2018, 13:08 »
I love the idea!

A few years back (like 10) I started working on a game based on the board game (in to some extent the 1985 movie) Clue that I was intending to make procedural (sort of).

The game-play was going to be centered around the murder of Mr. Body and you could pick any of the characters to play (Ms. Scarlet, Mr. Green, Mrs. Peacock, Col. Mustard, Mrs. White or Prof. Plum). The only thing you would know for sure was that the character you picked wasn't the murderer. You would then play to track down the actual murderer. I had plans to make each character have 10 different reasons for killing Mr. Body (10 different back-stories). So each time you played the game you'd have a random weapon that would be picked, a random room where the murder took place, and a random character (not your own) that commits the murder and a random (1 in 10) motive for the murder. So really it would be unlikely you'd ever play the same game twice given all the variability.

I even toyed w/ the possibility that the player could be the murderer and then the game-play would center around trying to not get caught while simultaneously trying to frame somebody else for the murder but the mechanic (the how to program it to make it work) seemed too far beyond me.

In the end (despite creating all the character art and several backgrounds) the project was too much to tackle at the time and it joined the 10,000 others on the "dead projects" pile.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Procedural detective game
« Reply #4 on: 03 Jan 2018, 16:44 »
You may not know this, but there already kind of is a procedural detective game. It's a dos game called Sleuth. Coincidentally there's also a browser based game called Sleuth that's also a procedural detective game. Both of them are pretty decent as well.

Yes, as I said I've seen some of the procedural detective games before. Probably not many, so that would be a good idea to check out the ones mentioned here at some point for inspiration.


But I have a little concern that an important point may be missed here. The concept I am trying to work out is not of a randomly predefined storyline, but of a dynamically evolving storyline, the story that creates itself as the time goes on, using characters AI.

It came to me yesterday that in foundation this is practically a concept of a strategy game, with adventure elements only added on top. Take some grand strategy game out there, where lots of countries rival each other trying to dominate over the world. There is no predefined scenario, not even randomized. In fact, the starting position may be always the same (historical setting). But then the players (computer and human ones) make decisions, random events occur, and the outcome may be very varied(1, 2).

So, what I'd like to do is a strategy game where players are people having certain personalities and ambitions, and they are in some limited enviroment (town, mansion) participating in a "game". Goals of that game are not strict, each participant chooses one for themselves. Achieving some of these goals may require committing a crime...

The game elements are not really clear yet though - would this happen before in black screen, and through clues and talking to people you would see flashbacks from what happened?

These are the kind of things that may be decided at later stages, they may even be optional.
I see this project as multilayered. The first layer is the strategy game of AI and human players, which creates a story. The second layer is a crime-solving adventure game, which may have its own features.

Also a crazy idea here would be to inverse the play in the system: You must commit a murder and then watch the detective agent solve it or not.

This is indeed a wonderful idea, and very well fitting in this concept. I believe, AI and humans should be equal here, from the game rules' perspective. Of course making AI detective may be more complicated than the criminal one.
« Last Edit: 03 Jan 2018, 16:51 by Crimson Wizard »

Re: Procedural detective game
« Reply #5 on: 03 Jan 2018, 21:23 »
About Agent Based Modeling, there is a project some people are experimenting with in the company I work, called JaCaMo, the website has a nice short description of the concepts that may or may not be useful.

Snarky

  • Global Moderator
  • Mittens Earl
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: Procedural detective game
« Reply #6 on: 03 Jan 2018, 21:46 »
More than a strategy game, it seems to me that what you're first and foremost talking about here is a simulation.

How familiar are you with programming intelligent agents? It's been fifteen years since I studied it, but I remember goal-based planning as being the most difficult thing to implement well. Unless you're an absolute AI genius, the NPCs are going to be pretty dumb; it will be a challenge to design around that, either by imposing constraints that make it easier for them, or by tricking players into thinking that they are smarter than they really are, for example by hardcoding certain complex behaviors. (Most likely you'll have to do both.)

There's an idea which I might have had from reading about Fa├žade, which is to introduce an invisible "authorial agent" (or dungeon master, if you like) into the simulation in addition to the characters. The role of this agent is to try to make sure that interesting and appropriate things happen in the plot, and that there's a good storytelling rhythm. (For example, the authorial agent might ensure that a key witness is killed just as he's about to reveal his information by encouraging one of the characters to do it.)

There are other ways to do this as well, for example by allowing/forcing the different characters to take on particular archetypal roles that then influences the patterns of their actions, such as love interest, comic relief, Watson, femme fatale, snitch, obstructive authority figure, etc. (Combining multiple roles into certain characters in different ways, and with different relationships between them, creates a vast space of possibilities.) Something like an improv performance, RPG or party game where everyone's collaborating, playing different roles in order to create as fun an experience as possible. What I'm trying to get across is that even building it as a simulation, it doesn't have to be a "realistic" simulation of people just walking around a house and maybe committing crimes.

I guess overall I think the risk is that the simulation becomes horrendously complex without really creating particularly compelling stories or mysteries (because that's a pretty difficult thing even for clever writers). So if you want something that is actually fun to play, I would advise you to not leave the "game" bit for last in the design, but to think carefully about what the experience is supposed to be like for players and what is meant to be enjoyable for them. That in turn will guide what the elements of the simulation need to be.

Danvzare

  • The Man with No Name
    • I can help with AGS tutoring
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Procedural detective game
« Reply #7 on: 04 Jan 2018, 12:50 »
This sounds like a great idea, although potentially a really difficult one as well.
Something that this idea reminds me of, is a dissertation from 1977 called Tale-Spin. (It's completely unrelated to the 90s cartoon.)
I highly recommend giving it a read, since it's about procedurally generated stories through complex AI, and is quite relevant to this conversation.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Procedural detective game
« Reply #8 on: 04 Jan 2018, 14:20 »
Something that this idea reminds me of, is a dissertation from 1977 called Tale-Spin. (It's completely unrelated to the 90s cartoon.)
I highly recommend giving it a read, since it's about procedurally generated stories through complex AI, and is quite relevant to this conversation.

Hey, this was a great fun reading this; if you know a bit about programming you can even imagine the program algorithms and bugs in them as you read those successful and failed stories :).

PS. I am actually glad I started this thread, I've noted number of things said above as something to consider.

I have not studied "intelligent agents" theory, my experience with AI is purely practical.
* AI for monsters and "bots" in 1st person shooter (pathfinding, situational decisions and goals in team modes).
* AI for volleyball players in 3D sports game (performing throw combinations and attacks).
* AI for a racing game I did recently (frankly, the most dumb of all).
Aside from A* algorithm and finite state machine, I had to invent everything myself...
« Last Edit: 04 Jan 2018, 14:34 by Crimson Wizard »

Re: Procedural detective game
« Reply #9 on: 06 Jan 2018, 15:38 »
I signed up just to reply to this topic. A procedural sleuth/mystery game is something I have thought about too at some point. The world deserves such a game which hopefully would have infinite replay value.

Before starting to program there needs to be a design phase of course. Learn about existing detective games, what they do and how they work. Adopt their ideas. Come up with your own, better ideas.

Here are some inspirational games to draw ideas and gameplay mechanics from:

Jack The Ripper gameplay (PC Game, 1995)


Murder!


Could a game mechanic be introduced that works by a process of elimination? A kind of Sherlockian deduction where whatever remains, however improbable, must be the truth. See the below game to see where I'm getting at.

PC-Sherlock: a Game of Logic & Deduction gameplay (PC Game, 1991)


What would the game setting be? Personally I find Victorian London a pretty fascinating place. A time before advanced forensics where you couldn't solve crimes by just doing lab tests.

Re: Procedural detective game
« Reply #10 on: 06 Jan 2018, 21:39 »
What Makes a Good Detective Game? | Game Maker's Toolkit


Mandle

  • NO PIXEL LEFT BEHIND!!!
    • Mandle worked on a game that was nominated for an AGS Award!
Re: Procedural detective game
« Reply #11 on: 08 Jan 2018, 02:32 »
Wow, CW, what you describe is exactly the kind of game I've been dreaming of making for some time now.

My vision is of a small town, also procedurally generated, maybe tile-based, where the citizens all have personality traits, goals, morals, and responsibilities which cause them to interact with each other in realistic ways.

The game would randomly assign these traits to the citizens and then run through a hidden 10 years or so (or more) of interactions where the townsfolk lived their lives, met each other, fell in love, got married, had children, maybe murdered someone or commited other crimes or insults against each other, developed friendships, built houses/businesses etc. This builds the relationships between people, families, and groups. I got this idea partially from "Dwarf Fortress" which builds a history of the world you are about to play in during the world creation phase and the player can select how many years of history to create. Longer periods like 1000's of years can take hours for the computer to work through though, but result in a richer and more detailed world to play in.

So, yeah, the game basically just plays itself for a pre-determined period without the player character present.

The player is a new citizen of the town and can do basically whatever they want to: They can try to solve a crime (if one occurs) if they want to, or commit crimes, or just go to work every day like a regular Joe, or run for Mayor, or commit suicide, or try to have an affair with someone, etc. etc.

I would also want certain "themed" plot devices to potentially happen at random, mostly inspired by books and movies:

* A vampire moves into the town with the desire to turn it into their new nest of the undead (Salem's Lot/30 Days Of Night)
* A zombie virus starts to spread within the town (Planet Terror/Dawn Of The Dead)
* Alien invaders start taking over the citizens (Body Snatchers/The Thing)
* A demonic figure arrives in town looking for fun and destruction (Witches Of Eastwick/Needful Things)
* A family with a history corrupted by dark forces is preparing a ritual to summon a monstrosity from beyond the veil of our reality (H.P.Lovecraft)
* An enemy nation's army invades the town (Red Dawn)
* An almost unkillable slasher stalks the community as revenge for some past harm against them/their family (Halloween/Elm Street)
* A natural disaster hits the town (Flood/Twister/Dante's Peak/Volcano)
* A giant monster/monsters attack the town (Them/Godzilla/Night Of The Lepus)
* Someone in town is a werewolf (American Werewolf In London/Silver Bullet)
* A house falls under a supernatural curse (Poltergeist/Amityville Horror)
* The town has a dark history it wants to conceal (Twin Peaks/Shadow Over Innsmouth)
* Etc.

The player would have options at the start of the game to allow any possible plot device, or ban/only include supernatural ones, or ban/only include non-realistic ones, or pick and choose possibles freely, or choose only one, or ban all, etc.

So every time you played the game you have no idea what is going to happen, or if something might happen that you will be unaware of, or if nothing much is going to happen, or if your best friend is a werewolf, or if you just spend the game working at a gas stand until you get so bored you go on a mass shooting, or...

The game could turn into a horror movie, or an action movie, or a monster movie, a detective story, or it could just be a soap opera about the lives of the people in the town.

Up until this point the game sounds relatively easy to code but that's where I run into a HUGE problem:

It's easy enough to give NPCs traits like Morals, Jealosy, Kindness, Anger, Sanity, etc. and have them interact with each other but how to give them actual memories of what has happened to them which is vital for their motivations when interacting with others?

I've played games where the NPCs have a hate/like meter towards each other based on what the other NPC did to/for them but they don't "remember" why they have that bias, thus there is no way to ask them the reasons why they feel the way they do.

And it gets more complicated: I would want them to be able to tell each other what they had done/had done to them/witnessed happen/etc. and then they would have to remember all that too!

Plus all these memories would have to be instantly accessable in some way and the game would have to understand what memories were related to what actions the NPCs take or what feelings they have.

Plus they would need some sense of what information they were willing to share and with who. They would have to understand that they can trust their mother with a crime confession (maybe) but not to blurt it out to a stranger, or rat out a friend to the cops, or not want to tell their friend about her husband's affair to protect her feelings, etc.

Even something as seemingly mundane as having the NPCs remember where they work and having them understand that they have to be at their job by a certain time and shouldn't leave until a certain time gets complex as they should also have an understanding of when an appropriate circumstance occurs that should make them break these rules, like their workplace catches fire, or they hear a loved one has been in an accident, or they feel sick, or they need to sneak away to hide some evidence against them etc. etc.

The characters in Dwarf Fortress can speel off a HUGE list of everything they did or what happened to them but they can't answer a specific question like "Why do you hate John?" or "What did you see that night?"

Having a seperate array of memories for every NPC that connect in a kind of web like memories in our own brains where each is linked in some way to others to lesser or greater degrees seems the way to go but the actual design of this mechanic is something that I would probably need months or years to perfect.

Another option is for the game to remember every single global turn as a kind of "save game" frozen state that it could then check to see if that NPC was present to witness something so they could reply to a question about it, but this seems like a dead-end route as that's not how memory works and also would be impossible to scan to find NPCs motivations and reasons for doing/feeling as mentioned above. And just imagine what a memory/resource hog this would be.

Like I said, this is a kind of "dream" or "Holy Grail" idea I have for the ultimate game I would love to make. It's probably an unrealistic goal but it has spawned a few lesser and more approachable ideas in my mind for games:

The first is a kind of dumbed-down version of the concept where the player plays as a bartender and can talk to/listen to the customers that come and go. Some will be regulars and will build up relationships with other regulars good or bad. Then they will leave and go out into the abstract "outside" world where they may also have interactions with each other. So, for example, one of them might suspect another of having an affair with his wife. You, as bartender, might know this not to be true and talk him out of it, or you could tell him the truth that the other guy had admitted to it, or you could even lie about it either way. Then maybe you read in the newspaper that the one guy went and killed the other, or that the suspected guy was murdered but the police have no suspects and now you have to wonder if the angry guy did it. So, yeah, as bartender you listen to the customers' tales and maybe you're a nice guy and try to help them out or an evil SOB and manipulate them against each other for your own entertainment, or a bit of both. It's up to the player. Maybe, if you're a baddie, one of them figures it out though and shows up just before closing time with a shotgun... Or maybe even one night that last customer turns out to be a vampire...

The other idea, which I'm actively working on with one of our own talented artists in the AGS community, is a physical boardgame based on life in a small town when suddenly The Devil shows up to cause mayhem and the players must figure out which of them is The Devil and how to stop them before they achieve their goal(s). The name of the game is "The Devil Made Me Do It". This cuts through all the problems with AI because it's human player vs human player but there may be a few NPCs that display semi-intelligent behavior if I can get a streamlined game mechanic working to do so.
 
So, yeah, I've just written a book in this post. Feel free to read it! :-D
« Last Edit: 08 Jan 2018, 03:34 by Mandle »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Re: Procedural detective game
« Reply #12 on: 15 Jan 2018, 18:25 »
I wanted to start prototyping something (something simple, for now, as suggested), and considering what framework/engine to use. First I thought about Unity, but that may be an overkill.
Javascript may be a good choice since it does not require much to install (browser). Does anyone know a good Javascript framework that can just display 2D art on screen, maybe with simple GUI support? I am familiar only Babylon.JS, but it is a 3D engine, which may be too much.

Re: Procedural detective game
« Reply #13 on: 15 Jan 2018, 18:54 »
Does anyone know a good Javascript framework that can just display 2D art on screen, maybe with simple GUI support?
You could try phaserjs or craftyjs, the gui could even be plain html on top of the canvas, or not.

- Alan