Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've already asked this on gamedev at, but I think I'm after more of a mathematical answer than a programming one. Here is the question:

I'm looking at creating a fairly complex choose-your-own adventure style of game, but I'm looking for a technique or method to help with the game design.

It will be a multi-branching story, and at times the branches will fold back in on themselves, and your major actions will be remembered and items will be collected. For example, if the player goes to the swamp and the forest before going to the castle he has picked up a dinosaur bone, killed a unicorn and grown an extra arm. If a player gets to the castle via the caves and the crypt he has picked up a bicycle and a strange smell. Now when developing puzzles for the castle I don't want to create a situation where two impossibilities are requires, for example - an extra arm and the smell are needed to kill an ogre.

Other than documenting the events and items very very carefully is there a process, a technique I can use in a spreadsheet or a piece of software that can help me?

share|cite|improve this question

You obviously know you're writing a state engine. In this situation, I'd probably consider the castle multiple states instead of one.

That is to say, the "swamp forest castle" and the "crypt castle" are different castles. In your code, you may render them the same, but the states are distinct because they've resulted in arriving at a destination with different assets.

Another way to think of it is to say, "at the castle isn't really my state . . . at the castle with a bone and a smell are my state."

share|cite|improve this answer

If there are $n$ locations and $m$ items/qualities that one can either have or not have, there are (a priori) $n\cdot2^m$ possible states. If that total isn't too large—or even if the reachable part of it isn't—it should be possible to write a program to walk through all of the possible states.

Then you can simply see if after traversing all possible states if the node in question has been reached.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.