August 19, 2019, 02:15:01 am

News:

Juju thinks he's so clever by putting funny stuff here



Alternatively, join us on Discord.

Project LotG

Started by Woodrow, January 21, 2019, 04:53:45 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Woodrow

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.
.emaG ehT esol won lliw uoy ,siht gnidaer rof tnemhsinup sA

Jean-Baptiste Boric

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 (https://github.com/NetBSD/src/tree/trunk/games/battlestar), though code quality has come a long way since the early 80s. I'd also recommend studying adventure (https://github.com/NetBSD/src/blob/trunk/games/adventure) as an example on how NOT to write an adventure game.

Juju

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.
Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

Powered by EzPortal