11 Replies - 517 Views - Last Post: 26 January 2013 - 12:07 PM Rate Topic: -----

#1 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Facets of a text based game?

Posted 25 January 2013 - 10:02 AM

I am looking to make a text based game, like a offline mud kind of thing.

Firstly, what i am not looking for; i don't need any particular code, don't need any networking help or mud libraries. What i am looking for and am having a hard time finding on google is the kinds of things that i need to work on or a round about description of how features are implemented (on 'average') regardless of language.

For example, how are 'room' usually stored or the items within in them. I was thinking maybe each room has a unique id that corresponds to a set of data about that room in a sqlite database. Then i thought why not do the same thing for items, all items being unique id's in another sqlite database and then each room just has a list of id's that correspond to the items in the room or something.

Also i am wondering what kinds of things i am not thinking of or if there is something in these games that one may think to do one particular way but would be flawed and a better way may be something i may not thing of.

So basically are there are any particular tips or pitfalls for implementing a text based game world or particular things that may need more thought before just starting to implement something that i will have to through out anyways?

I have googled around a fair bit today but most people either are happy with answers on how the networking side of these things work or they get no (meaningful) answers.

Thanks all, sorry for being a bit vague.

This post has been edited by Nekroze: 25 January 2013 - 10:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Facets of a text based game?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5476
  • View blog
  • Posts: 11,762
  • Joined: 02-June 10

Re: Facets of a text based game?

Posted 25 January 2013 - 10:34 AM

Objects. All things are objects. At least within any Object Oriented language, which would be all the common ones used today.

Objects have inheritence so a Kitchen would inherit from the more generic Room. A Sword would inherit from the more generic BladeWeapon which was inherited from the even more generic Weapon.

There is a tutorial on objects linked in my signature block.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9073
  • View blog
  • Posts: 34,115
  • Joined: 12-June 08

Re: Facets of a text based game?

Posted 25 January 2013 - 10:38 AM

*
POPULAR

Quote

like a offline mud kind of thing.

Okay so this becomes just a basic CRUD app. (Create Recal Update Delete).. a screen, some form of user input, and a database/xml/textfile to hold everything. There's no game timer or graphics so a turn is defined by when the player takes an action.


Quote

For example, how are 'room' usually stored or the items within in them. I was thinking maybe each room has a unique id that corresponds to a set of data about that room in a sqlite database.

Yes.. basic relational database techniques would be best. Have a table for 'rooms'. Each row has a unique id, flavor text, etc. Then you can have a table of 'room connections' that list a room id and a corresponding room it connects to.. this allows you to have zero to N connections per room so yeppie for flexibility.


Quote

Then i thought why not do the same thing for items, all items being unique id's in another sqlite database and then each room just has a list of id's that correspond to the items in the room or something.

Yes - continuing on the relational database theme you would then have a table called 'item'. Where each time has a unique id, name, flavor text, etc. Then have a table that connects the item id to a room id.


Quote

So basically are there are any particular tips for implementing a text based game world or particular things that may need more thought before just starting to implement something that i will have to through out anyways?

Really really try and get all the concepts down on paper first. The key to this whole.. thing.. is to have a good data structure setup. So think of all the objects in the world.. and how their data should be grouped.. and how you would define an action between an item and a character or a character and a room etc.. get that model down and you'll be set. Keep in mind OO design theory and try to keep things open and flexible enough to tack on more things later.

Oh and don't have suckie writing. Since there's no graphics bad writing kills it.
Was This Post Helpful? 5
  • +
  • -

#4 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Facets of a text based game?

Posted 25 January 2013 - 11:00 AM

Great advice so far thanks.

I am quite well versed in OOP, however I'm not sure how easy doing inheritance would be if i am storing all rooms in a sqlite db for example. Would i really need to have a kitchen type room a separate object that inherits from a generic room if the only real difference between them is the items they may contain and the text displayed for the room at various intervals, this would all be different for each instance of just the room and i don't see the value of having a separate kitchen object, if interactions between a player room just queries its exits or items within it then there is nothing more unique about a specific kitchen object. not to day i don't know how i could do that but i just don't see yet how a kitchen would need a different object interface if i may keep stretching the kitchen example.

On the point of writing, I intend on getting my partner, who is doing a major in creative writing, to help with that part of it all so hopefully it will turn out well. She has slight ocd as well so maybe that will help :bigsmile:/>.

Another thought that i am not sure if i have the right handle on is world states. For example i have implemented a system at the moment where a room can have a first visit and a return visit mention but can also have other messages that can only be displayed once if their special conditions are met. these conditions are my world states. so for instance if i start a quest and go into a room i have never been to before it will display the message that corresponds to the condition that would check with a database (i am using a hashmap/dictionary atm) if it exists or equals a certain thing. so with a message like 'there is a new presence here' may have condition 'tutorial = 1' so if you are on stage one of the tutorial mission this message is played rather then any other for that room.

How would a state system for this kind of thing usually be done. I may have states changed or added by entering rooms using items or objects and other things obviously need to detect that and play specific messages if those states exist or equal some value.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9073
  • View blog
  • Posts: 34,115
  • Joined: 12-June 08

Re: Facets of a text based game?

Posted 25 January 2013 - 11:11 AM

Quote

I am quite well versed in OOP, however I'm not sure how easy doing inheritance would be if i am storing all rooms in a sqlite db for example. Would i really need to have a kitchen type room a separate object that inherits from a generic room if the only real difference between them is the items they may contain and the text displayed for the room at various intervals,

Yeah.. no idea why you would have a 'kitchen room' different than a 'bed room'. Just have *a* 'room' type.

Quote

Another thought that i am not sure if i have the right handle on is world states. For example i have implemented a system at the moment where a room can have a first visit and a return visit mention but can also have other messages that can only be displayed once if their special conditions are met. these conditions are my world states

That seems more like a 'room state' and not a 'world state'.

I sort of assumed tracking when the player was in a room or last visited an area would be in play.

You can have a column with a 'last visited' datetime field.. update when the user enters a room.

Quote

How would a state system for this kind of thing usually be done. I may have states changed or added by entering rooms using items or objects and other things obviously need to detect that and play specific messages if those states exist or equal some value.


So then when a user enters a room collect all the information that applies and see if it triggers anything. That whole custom trigger thing is the part of planning I mentioned you need to do. It's custom.. it's unique to what ever you are cooking up.. and you need to work out a system of getting information off the players and how to translate that into what ever may receive it.
Was This Post Helpful? 2
  • +
  • -

#6 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Facets of a text based game?

Posted 25 January 2013 - 11:26 AM

View Postmodi123_1, on 25 January 2013 - 11:11 AM, said:

That seems more like a 'room state' and not a 'world state'.

I sort of assumed tracking when the player was in a room or last visited an area would be in play.


Oh yeah the first visit thing is room specific but for things like quest states i mean. So a room is defined with a bunch of conditional messages and if one of them matches that is played these conditions are global cause all rooms may need to know what they are. you enter a dungeon but all its rooms are empty but if the world state for a specific quest has been set to 1 then each room of the dungeon can, if it has one defined, check the conditional messages and play the new one for that specific state instead, now the dungeon is not empty there are creepy sounds and an odd smell in the air for example.

I also wanted to keep the states in a globally accessible database so that i don't have to keep around objects of a room that is no long in use just to remember its specific last state and i didn't particularly want to save its state to disk either. I thought doing this would mean that no matter the room all i have to do is load it from the room database and do its message check to see if any conditionals match or if it should play the first or return visit message as each rooms id code is used as a world state to show it has been visited, this way i could also have something so that each room visit the world state for that room id increases and displays a conditional that matches that room id equaling 6 so the 6th visit is special. this way all i have to do is store the simple keys and values for states in an in memory database (or dictionary as i am at the moment) rather then store entire room structures and or segmented states like that, also allows cross reference of rooms so that if i have entered room 2000 and then i enter room 3000 it says something like 'oh this looks like something that other room thing had' but wouldn't say that if you hadn't ever visited room 2000.

Is this wrong or just another way of doing it or is there some flaw there i am missing or problem i may have later. I am trying to plan specific features its just some of the broader implementation details that are still unclear to me, but thanks for sticking around to help!
Was This Post Helpful? 0
  • +
  • -

#7 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Facets of a text based game?

Posted 25 January 2013 - 12:15 PM

For my 2c on the matter I wouldn't use a database at all! There just isn't the need, a bit of overkill in my opinion. How I would approach it is with a doubly linked list, which would give you defined entry (accessing a node) and exit (leaving a node) points. Linked lists will handle a lot of the logic of where to go next as you play the game.

If you feel really adventurous you can look into binary or quad trees which borrow from the principles of a linked list, but can represent more complicated maps/structures.

Regarding the room types keep it simple. Just have an enumeration for 'cave' or 'dungeon' for instance. OOP for a text based game also seems overkill.
Was This Post Helpful? 0
  • +
  • -

#8 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Facets of a text based game?

Posted 25 January 2013 - 12:49 PM

I would like it to be a fairly complex text based game, i am using python and plan to have it work on android so i don't want to load a lot of things into memory at once which is why i want the static representation of the world on disk.

I would also like to extend it in the future to lan play for short-ish adventure worlds.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9073
  • View blog
  • Posts: 34,115
  • Joined: 12-June 08

Re: Facets of a text based game?

Posted 25 January 2013 - 12:57 PM

Quote

Oh yeah the first visit thing is room specific but for things like quest states i mean.

What is a "state"? what is a "quest"? Iron out these details and then code for it. Like I said - write all this down.. and start ordering it and making it fit into some sort of meta concept.. then you can code for that and have room to expand and change the game flavor text and items in rooms later.


Quote

So a room is defined with a bunch of conditional messages and if one of them matches that is played these conditions are global cause all rooms may need to know what they are. you enter a dungeon but all its rooms are empty but if the world state for a specific quest has been set to 1 then each room of the dungeon can, if it has one defined, check the conditional messages and play the new one for that specific state instead, now the dungeon is not empty there are creepy sounds and an odd smell in the air for example.

This is what I was talking about when I said 'keep in mind OO design theory'. You need to apply the same logic of abstracting a task (that you want to repeat) and distill what needs to go in and out. (not necessarily that you need to use inheritance and what not).

Quote

I also wanted to keep the states in a globally accessible database so that i don't have to keep around objects of a room that is no long in use just to remember its specific last state and i didn't particularly want to save its state to disk either. I thought doing this would mean that no matter the room all i have to do is load it from the room database and do its message check to see if any conditionals match or if it should play the first or return visit message as each rooms id code is used as a world state to show it has been visited, this way i could also have something so that each room visit the world state for that room id increases and displays a conditional that matches that room id equaling 6 so the 6th visit is special. this way all i have to do is store the simple keys and values for states in an in memory database (or dictionary as i am at the moment) rather then store entire room structures and or segmented states like that, also allows cross reference of rooms so that if i have entered room 2000 and then i enter room 3000 it says something like 'oh this looks like something that other room thing had' but wouldn't say that if you hadn't ever visited room 2000.

Again.. figure out how you want to the rooms to interact, what a 'state' even is, how 'states' interact, etc... and then start to distill it... right now all I see is you throwing out wild and disparate conditions. You need to start figuring out how to codify them else you'll end up with a bunch of hard coded features.


@butch - yeah that thought crossed my mind, but this guy just needs to figure out what these blanket terms mean with his concept of the game. How to break down these "conditions" into something like:

condition
---------
id
requirement
response

and linking conditions to rooms... then the player, when entering a room, just feeds current variables into the condition finder and see what happens. You know - something boiled down like a 'rule-based system'.

http://ai-depot.com/.../RuleBased.html
Was This Post Helpful? 1
  • +
  • -

#10 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Facets of a text based game?

Posted 26 January 2013 - 10:53 AM

Thanks to all, your input has been very helpful.

I think I have enough understanding now to get the rest, cheers!
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9073
  • View blog
  • Posts: 34,115
  • Joined: 12-June 08

Re: Facets of a text based game?

Posted 26 January 2013 - 11:41 AM

I better see some screen shots and a write up in the 'share your project' in a month or two!
Was This Post Helpful? 1
  • +
  • -

#12 Nekroze  Icon User is offline

  • D.I.C Head

Reputation: 14
  • View blog
  • Posts: 170
  • Joined: 08-May 11

Re: Facets of a text based game?

Posted 26 January 2013 - 12:07 PM

View Postmodi123_1, on 26 January 2013 - 11:41 AM, said:

I better see some screen shots and a write up in the 'share your project' in a month or two!


I would like to do that, i'm not sure how far away it will be however as it is a spare time kind of thing but i have... decent, hopes for it bring sooner rather then later.

I am well on my way now to having done most of the world classes i just need player and enemy interactions and then a, probably custom, way of serializing the world for easy incremental loading from an sqlite db and then a ui. The ui thing may take awhile cause i am really bad at graphics (which is why i have chosen a text based game at the moment) and i need to make 2 sets of the gui. One for desktop that will be larger and all on one window and the android one which will likely have tabs for different things, i was going to have commands be a actual series of branching buttons for example, and also have to work well on android but do both modes with as little major changing between them.

So anyways, i will en devour to do a write up even if i put out a windows only single player version at first but i would love to have it be multi-player over lan so that a few people with android devices (may be hard on anything bar a tablet) can spend an hour or 3 or whatever having a text based rpg adventure together!

EDIT: oh and my story writer is coding illiterate so i will be making an editor for it before i can produce any meaningful content and worlds to use my framework.

This post has been edited by Nekroze: 26 January 2013 - 12:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1