Making Decisions In Text Adventures!

Started by
21 comments, last by JustHusk 5 years, 10 months ago

Hi there,

So i'm an inexperienced student learning games dev at college and im studying c#, in my spare time im trying to work on a text adventure game with a narrative. My issue is that i dont know how to make the decisions, well not simply anyhow.

I could write out 50 variables for each decision to read from the player but that would become very tedious and too messy to even comprehend when im adding content. I was thinking of adding functions to hold each decision or area but im at a lack of knowledge on how to jump to a function or if it's even a good solution. I know i could use an array and each decision be a number but that just doesn't seem like a good solution to me either.

Any advice would be appreciated and this whole topic might sound dumb to a professional so be understanding please haha.

Thanks,

Luke

New Programmer & College Student

JustHusk

Advertisement

I think what you are looking for are called Decision Trees.

Here's a link to some info that looked promising at first glance, in c#:

https://stackoverflow.com/questions/3889301/how-to-implement-decision-tree-with-c-sharp-visual-studio-2008-help

You could also use something like a State Machine to do these kinds of things...

https://sachabarbs.wordpress.com/2013/05/16/simple-but-nice-state-machine/

5 minutes ago, Septopus said:

You could also use something like a State Machine to do these kinds of things...

https://sachabarbs.wordpress.com/2013/05/16/simple-but-nice-state-machine/

Thank you for the suggestions!

As i'm still quite inexperienced it's hard to wrap my head around some of the concepts so it'll take some time to tell what'll work for me but both seem like great solutions.

I'll update this after some messing about, thanks again!

New Programmer & College Student

JustHusk

There may even be a simpler method out there, that I'm overlooking, but hopefully those search terms will get you closer to your goal.  There are also some game engines out there specifically for building your own text adventure game, I think some are open source.  Have a peek under the hood of one. ;) 

Have a google at "c# text adventure engine" .. at least 2 or 3 there at the top.  Dissection is the best way to learn sometimes. :D

Just don't always assume the code you are taking apart was put together well.

 

44 minutes ago, Septopus said:

There may even be a simpler method out there, that I'm overlooking, but hopefully those search terms will get you closer to your goal.  There are also some game engines out there specifically for building your own text adventure game, I think some are open source.  Have a peek under the hood of one. ;) 

Have a google at "c# text adventure engine" .. at least 2 or 3 there at the top.  Dissection is the best way to learn sometimes. :D

Just don't always assume the code you are taking apart was put together well.

 

Yeah don't think i want to use an engine, even by itself i'm struggling with the links you sent me.

I have no reference to understand it,

public bool Result { get; set; }

the parameters of the line above i'm not familiar with and i'm pretty sure that's the simplest thing on the page, anything you could recommend for beginners?

New Programmer & College Student

JustHusk

Then I would say start with some introductory tutorials on c# & c# Object Oriented Programming.  You need some exposure to some of the fundamental basics, and well I'm not the guy for that.  Lol.  Start with YouTube if you prefer visual learning.  Wish I had a list of good ones,but it's been a while since I checked any out. You could probably get some better suggestions for tutorials in the Beginners forum though.  Good luck with your project! :D

Here is an old 3DBuzz text adventure game in C#. It later uses XNA but this first section is only C#. I watched a couple years ago and it seemed to be interesting so I pass it on. The later parts are not free but this first part is many hours long and is complete.

Keep in mind that it is old and you may have to do some workarounds. I have always found that a learning experience in itself. Also some best practices may have evolved since this course was made.

RIP to Jason Busby

Here is the 3rd part for your consideration. The first 2 are very basic intro and install.

 

Playlist is

https://www.youtube.com/watch?v=OOiSIajp4gw&list=PL74F05D68F408B2DD&index=1

 

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

There are professional tools out to maintain those decision trees and export into any format you need to work with your game.

The simplest solution as already mentioned is the decision tree, a structure that is a collection of connected logic nodes that each may also have child nodes attached to. When verifyng your tree you'll start with a reference to the root node and test it's children. You then take a reference to the children whitch first returned true on validation as your next root node and repeat until you reach the end of the tree and so the end of your game. Meanwhile there could also be action nodes between so run those node's functions to interact with your game

7 minutes ago, Shaarigan said:

There are professional tools out to maintain those decision trees and export into any format you need to work with your game.

The simplest solution as already mentioned is the decision tree, a structure that is a collection of connected logic nodes that each may also have child nodes attached to. When verifyng your tree you'll start with a reference to the root node and test it's children. You then take a reference to the children whitch first returned true on validation as your next root node and repeat until you reach the end of the tree and so the end of your game. Meanwhile there could also be action nodes between so run those node's functions to interact with your game

Thanks for the suggestions, again i am just learning at college level and although i'm doing this project because im ahead of my class and need something harder i dont really have a grasp on a lot of the keywords etc. I feel like it must be bad practice but would it be okay to just call methods depending on the players decisions?

New Programmer & College Student

JustHusk

This topic is closed to new replies.

Advertisement