We're on Discord! Please join our server now if you don't want to miss anything! (More info) | Join the UCC4 contest! (More info)

* WalrusIRC (More rooms available on our Discord server)

Author Topic: Project LotG  (Read 709 times)

0 Members and 1 Guest are viewing this topic.

Offline Woodrow

  • New User
  • Join Date: Jan 2018
  • Location: Miami, Florida
  • Posts: 15
  • Post Rating Ratio: +0/-0
  • Jack of all trades, master of, like, two.
    • @@TheTreeOfComedy
    • eyeoftheaxolotl.tumblr.com
  • Gender: Female
Project LotG
« 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.


  • Calculators owned: TI-83+
  • Consoles, mobile devices and vintage computers owned: TI-83+, iPhone, Nintendo Switch, iPad, Kindle
.emaG ehT esol won lliw uoy ,siht gnidaer rof tnemhsinup sA

Offline Jean-Baptiste Boric

  • Full User
  • Join Date: Jan 2016
  • Location:
  • Posts: 36
  • Post Rating Ratio: +2/-0
Re: Project LotG
« Reply #1 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 (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.

Offline Juju

  • aka Yuki Kagayaki aka J̵̭͕͇ù̞̭̝̯̦j̴̭̙̗͖͡ù͏͓̲̕
  • CodeWalrus Staff
  • Super User
  • Server Maintenance
  • Moderator
  • Forum Maintenance
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Inside a walrus
  • Posts: 3287
  • Post Rating Ratio: +39/-2
  • Couch potato
    • jul.savard
    • juju2143
    • @juju2143
    • juju2143
    • @julosoft
    • juju-kun
    • /u/juju2143
    • juju2143
    • @juju2143
    • Juju's shed
  • Gender: Female
  • WalriiPoints: 99999
Re: Project LotG
« Reply #2 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.
  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
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

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games