Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Ok, more progress.

I hard coded the mansion that the game will take place in.  basically it is just a series of connected nodes.  Right now, there are 9 rooms arranged in a square.  I also made a quick visualizer so I can see what is going on.  This is what it looks like:


The red are valid paths.  

Then I wrote a simple flood fill pathfinding algorithm.  You can supply a from and to ID for rooms and it will find the best path (best being shortest).  It currently always takes the room with the lower ID if two paths are equal, so going from 0 to 4 will always go through room 1 instead of 3 because 1 is lower than 3.  A savvy player could use this I guess.  I'll change the algorithm to take a random route if there are multiple shortest routes.

TestCase.hx:46: Shortest path from room 0 to Room 8: [0,1,2,5,8]

I also wrote a modified algorithm in case I needed a person to go through a specific room (like the murderer needs to move from their location, to the location where they stash the weapon, but they have to pass through the room with their victim).  So that is working too.

TestCase.hx:49: Path from room 0 to Room 8 going through room 4: [0,1,4,5,8]

Finally, I wrote the core to take the paths I generated and create a list of events so that the other people can tell you about them when you question them.

TestCase.hx:54: { timePeriod => 0, location => 0, lie => false, action => LEFT, person => 1 }
TestCase.hx:54: { timePeriod => 0, location => 1, lie => false, action => PASSED_THROUGH, person => 1 }
TestCase.hx:54: { timePeriod => 0, location => 4, lie => false, action => PASSED_THROUGH, person => 1 }
TestCase.hx:54: { timePeriod => 0, location => 5, lie => false, action => PASSED_THROUGH, person => 1 }
TestCase.hx:54: { timePeriod => 0, location => 8, lie => false, action => ENTERED, person => 1 }

There is a flag in there so this statement can actually be a lie.  This is a future state thing.  Right now, all the statements are true.

I also created the Constraint object that tell if an event is valid or not.  I manually created some and checked them and they are working like I expect, but they aren't plumbed into the mystery creator yet, so no examples.

How this basically is going to work is that I'll have the random people (not the murderer or the victim or the one who finds the body) just walking around.  I'll generate a random movement for them (generate the events to move person 1 from room 1 to room 5), then check those events and find out if they would violate any constraints.  If they do, throw out those events and try to generate another set.  I'll have to be careful not to get caught in any infinite loops by putting people in situations where they have no valid moves.  I don't think I will have any of those situations with how I'm currently designing the murders, but I might in the future.  That's one of the dangers of procedural generation.  

I might just make an event like "Person 3 is disappears to resolve a time paradox" in the event that a person has no legal moves, including just staying where they are and doing nothing.  Interestingly enough, if questioned about this the other people will mention it in passing like it is no big deal.