Development => PC, Mac & Vintage Computers => Topic started by: Woodrow on January 21, 2019, 04:53:45 pm

Title: Project LotG
Post by: Woodrow on January 21, 2019, 04:53:45 pm
So, I'm making a text adventure game for a competition. i want the game (which you just lost) to
- take player choices as input and store them
- depending on player choices, move throughout the story
- have unique responses to certain inputs for comic effect, including a catch-all for unrecognized inputs ("what does [input] even mean?")

heres a basic example using my (incomplete)!game path so far. (etc means thats the farthest ive programmed in that path)

start > look > look > look > death for annoying the narrator
start > look > look > west > death for annoying the narrator
start > east > death by boredom
start > west > pet the goat > etc
start > west > attack the goat > death by goat attack
start > west > feed the goat > death by goat bite

basically, there is only one correct path through the game. all other paths inevitably lead to death and end the program.

my question is, how can i do this without drowning in if/else if/else/while loops? is there a library that could make my life easier? im using c++, but i can switch to java if that means more efficiency.

i have about a month for the competition.
Title: Re: Project LotG
Post by: Jean-Baptiste Boric on January 22, 2019, 06:47:27 pm
You can model your game as a (set of) finite state machine(s), where each state (vertex) has a number of valid transitions (directed graph) to progress the story depending on both the game's state and the player's input. Most adventure games have at least one FSM modelling the current player's location, but you can have more than one to handle things like puzzles, timers, NPCs and so on, depending on how complex your game will be.

Understanding the player's input is historically one of the hardest things to get right. There's no miracle solution, but generally you'll have to identify at least the verb (= action) and optionally one or more objects to act on. Tokenize the input and try to make sense of it. I recommend handling a fair amount of synonyms too, unless you want to frustrate users.

You can study some classic adventure games like battlestar (, though code quality has come a long way since the early 80s. I'd also recommend studying adventure ( as an example on how NOT to write an adventure game.
Title: Re: Project LotG
Post by: Juju on January 25, 2019, 01:54:53 am
I'd suggest a language made for IF and text adventures like Inform 7 ( I think it's going to be the best. Nice learning curve, easy to do whatever needed in a standard IF game and it mostly looks like English.