Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to approach object management (unique ID's, tracking, searching, manipulating)

Author
Message
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 18th Sep 2010 00:21 Edited at: 18th Sep 2010 00:24
Apologies for such a lengthy post. I wanted to be sure it was understood what I was asking. If a MOD feels there is a better section for this to be in ( Game Design Theory? Programming Talk?) please do move it there. Thank you.

Hi guys,

this question relates to my Text RPG I am slowly but surely working on. (I've got most of my scrolling text box implemented as well as a user input routine that echos key hits and appears to be non-blocking like I need, so..making progress!)


I'm trying to do some planning ahead and decide how I want to approach object management for things like holding the actual room data, then calling that data as the player navigates through the virtual game world, as well as trying to come up with an inventory system as well, since from my point of view the two are somewhat related and will use the same basic principles when it comes to implementing those systems.

I of course do plan on using UDT's to make some basic structures and other object definitions, but as far as storing those individual objects and recalling that data when necessary I'm not sure what the best approach would be.

For example, for my actual game map I thinking of the time honored tradition of using arrays.. It will probably be either a 2D (x,y) or 3D (x,y,z (z axis for up/down above/below ground movement). However I am concerned with easing the developmental process as far as building rooms (and objects as well) giving them individual unique ID's and how to reference them by those ID's (more so for objects than the rooms) if/when I need to..

For rooms in particular I've got to have a way to link them.. Well this particular room has 3 exits, and those 3 exits lead to Rooms A, B, and C.

I could just reference by array index, but that would create complications I am hoping to avoid, because even though I am going to create maps of all the areas I am building, I'm worried about how I would need to keep track of them when building individual rooms, and making sure I link them appropriate.

Even a 1D array would work for that purpose, but it would be very quirky and unordered of course and I'd need to know every single rooms exact position in the array when assigning valid exit addresses, etc.. A 2D array is much more organized and would be presentative of any 2D map I draw out on paper but then I also have to worry about loading that data into those arrays in a quick and efficient manner, (I am NOT hard coding anything as I want to try and come up with a re-usable engine of sorts..)

Obviously if room A is 0,0 and linked to Room B at 0,1 but maybe the next time the data is loaded they are all in different positions? etc... It would create a problem.

Even if that situation is unlikely... I am much more interested in devising a Unique ID system, where every room has a unique ID, every item has a unique ID, every monster/NPC/anything else has a unique ID, etc..

I have no idea how to write a system that can assign those ID's (or let me assign them) randomly, and keep track of them internally, as well as lookup and interact with a particular ID based on user-input on the fly..


For example.. When I was working in Python with SQLite my Room mapping system was (probably) pretty primitive and based on some manual labor to keep things straight. I had a 2D grid, based on Letter / Number coordinates, as well as a general area prefix.

A B C D E F G
1
2
3
4
5

basically like that.. so the town center on such a map might be located at 1xD3 (Area 1, x (spacer), Column D, Row 3) and I basically assigned my valid room exit variables for each room as I was building them, referencing the map. When the player moved, the game would perform an SQL lookup for the grid coordinate (stored as a column value in each row, along with other column values for Town, Street, Room Description, etc) and the room data for that grid coordinate would be pulled up, assigned to the current room class (an array object of sorts :CurRoom.Title, .Name, .Description, etc). The "valid" exit values from the SQL data would be parsed through and valid exits printed as well, etc.

And that's how I did movement.. However this time I want to load the game map into memory and leave it there since its probably better to do so, and I can manage other things on the same map as well.


So let's say I had a 4x4 2D array
0 1 2 3
0
1
2
3

(I think that's right?)

let's say I filled it complete with rooms, and one of the variable fields was a unique ID field.

Instead of searching/pointing to (0,1) or (2,3) etc.. How would I iterate through that array (fastly) and search for the unique ID?

Is that even efficient? I have heard of using Linked Lists and Binary Trees, etc.. But what I have read on the forums, I do not completely "grasp" at this time.

I think it would be best if anyone could explain Arrays, vs Linked Lists, vs Binary Trees using simple code examples - related to what I would like to do.. (so making a 2D game map and how to reference and manipulate the data by unique ID)

I also mentioned an inventory system.. I am very confused on the best way to do this.. whether it is managing monsters, or items, or anything in particular..

Let's say there is a table in a pawn shop, and it has Two items on it I am interested in. They are both unique items with their own unique ID - BUT they are the same object as far as the game world is concerned.. A simple healing potion. It has the exact same description, same weight, same everything, but just like in real life they are both unique individual objects..

It will be challenging enough getting my parser (when the time comes) to distinguish wish one the player is referring to (i.e get first potion, or get second potion, attack third Orc, etc)

But I have NO IDEA how to keep track of "clone" unique items, by using their unique ID only!


If anyone can take the time to write out a good explanation, and some easy to follow example code on how I could implement this kind of functionality - or at least post a really good link that a beginner could grasp, I would be really grateful.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 18th Sep 2010 01:06
Hi Neco,

I'm pretty sure everyone would agree on my part that linked lists and binary trees do not suit DarkBasic Professional. For these two you need pointers, and DBP isn't really made for handling those (at least I've never got them to work like I wanted to without too much code).

Quote: "How would I iterate through that array (fastly) and search for the unique ID?"


I believe you're searching for searching algorithms. However, this topic is pretty big, and I will leave that for when you would decide to dive into this direction.

TBH, I don't quite understand why you would want to separate two potions that have exactly the same effect as far as the game world is concerned. It would have absolutely no difference to the outside, and a huge difference on the inside (in terms of complexity).
Just a few idea's of how I would build a world that has enough adaptability to be implemented in a parser:
- A room can be stored by a memblock, they are variable in size, can be loaded from a file, and can be referenced by an ID to link rooms.
- You can link rooms using an array that holds the portals to other rooms (like portal 2 leads to the room of memblock 6).
- Try to group types of objects into arrays, like items in a single list and have their own ID which defines their characteristics.
..Try to be creative.

I could be off, I could be on... I'm just saying what's on my mind right now and I'm not even sure if I hit a sweet spot here.

Cheers!
Sven B

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 18th Sep 2010 03:08 Edited at: 18th Sep 2010 03:19
As for why two separate potions.

Well, I am thinking of it like this..

I may not want some items to be stackable(i.e player has 2 potions, so its one potion "item" with a Qty of 2 or 5 or however many they have.. etc), or even then I may just want them to be individual objects for whatever reason.. Also if I use one reference for any one particular item, how does the game tell the difference between an item in the persons inventory, and an item sitting on a table in a shop, or held in a mobs inventory? This is what I mean by unique items, with unique ID's (just like each player in a game would be delt with uniquely, because two or more people are playing and have different things happening, two items are two "real" objects in my game world).


As far as memblocks.. I had never considered it, and I have never used a memblock before.. However if you or someone else in the know has time to come back and write an example of the system you are describing, I would surely be interested in seeing how it works.

If anyone wants to give thoughts on pointers and linked lists/B-trees that would still be nice as well.. I have seen examples of people doing it and I thought one of the add-ons for DBPro (Styx?) that I have was supposed to make using pointers possible/pretty easy and whatnot.

On Searching Algorithms, yes I suppose I may want something like that.. I will search around on the forums tomorrow (heading to bed) after work, but if anyone knows any good threads, feel free to post them.

Thanks.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 18th Sep 2010 17:34
Quote: "Also if I use one reference for any one particular item, how does the game tell the difference between an item in the persons inventory, and an item sitting on a table in a shop, or held in a mobs inventory?"


Well, you only need to know which object to reference when the difference matters. For instance, if there are two identical potions on a table, it hardly matters which one is "taken", so when your code loops through the list of potions that are on the table, it stops at the first one it finds, and that is the one that is taken.

But, if you are in a room, and you have a potion, and there is one on the table, and there is one on the floor, then you have to distinguish. So, you can't "take" the potion you already have, and you can't "drink" the potion you don't have. Your loop can count how many objects meet the criteria for the input. This is where your player would have to input

TAKE THE POTION FROM THE FLOOR

or

TAKE THE POTION FROM THE TABLE

but not just

TAKE THE POTION

because the game would reply

WHICH POTION DO YOU MEAN?

This should be familiar from other text adventures.

As far as rooms and objects, I would personally use UDT arrays for everything. They are easy to save and load when you have IanM's matrix utilities.

So, a UDT for rooms might be like this:



So, if room(1).exitNE is equal to zero, you can't travel that direction. If it is equal to 15, then moving to the north east takes you to room 15. And perhaps if it is equal to -15, travel in that direction is restricted unless you have a key. Or if (assuming you have less than 1000 rooms) it is equal to 1015 then you must throw a switch somewhere before movement to the north east from room 1 is possible. And so on, and so on.

In a system like that you would want to first design a "room construction" program that eases the process of assigning all these numbers to directions. I've played around with this kind of a construction program, and I'd be willing to collaborate with you on coding one that suits your needs.

And good luck with your game, I love a good text adventure!

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 18th Sep 2010 18:13
Hmmm.. I guess I am just not getting the whole point you guys are trying to make in reference to unique items. Not that I'm trying to be difficult.. I guess I just can't visualize it any other way..

As far as the "take from floor vs table" idea expressed - that to me looks more like a parsing issue I need to deal with first and foremost..

So lets assume I've delt with it for a moment. My game can recognize the tokens needed to understand what the player wants to take, and where they want to take it from.. Or even can fall back on a default of searching the room for the first object found..

But lets say we have this situation.

Quote: "
[Some Town, A Pawn Shop]
The smell of old mildew permeates the area as you step inside the door to the shop, you can tell it is a very old building and is not cleaned very often. Bits of paint are peeling off a wall to your right, and the windows contain a milky fog of built of dust and grime.
You also see: Along wooden display table

>Look table
>It's an old table made of sturdy oak, what else do you expect?
(oops)
>Look on table
On the table you see a green healing potion, a blue healing potion, a blue healing potion, a rusty old broadsword and a picture of your mother naked..(just kidding)
"


Now let's assume a couple more things...We'll assume the default action to "get potion / take potion from table" and commands like that, IS indeed to just grab the first potion, because no adjective was specified.

Let's also assume that my inventory system, as far as the game logic is concerned, is very simple. The game does NOT see object names or descriptions. As far as the game is concerned, the game only EVER sees pure Object IDs.

So if I have my pawnshop table (quick and dirty pseudo-code, I haven't time to think out proper structure)



I guess my first question is.. IS that even possible to do in DB in an easy manner? And secondly, how I would go about building/managing a system like that.

So, do people understand what I mean by the GAME logic being able to differentiate unique individual items?

Two potions on the table. Both blue, both do the exact same thing.

But when the parser decides (ok the player wants the SECOND blue potion on the table) it goes for the ID listed for the SECOND blue potion on the table and NOT the first, in any circumstance. I also want to reuse this logic in other areas of the game, such as combat with multiple mobs, etc..


Please, nevermind WHY I want to do it this way - this is the way I visualize things and makes the most sense to me.. I would rather try this and fail, then begrudingly go down another path I have less incentive to understand and learn from.

I grew up playing MUDS that used systems like or very similar to these concepts - so that is where I feel most at home.. Part of the goal is to make the single player experience as interactive as the atypical MUD might be, with all the little facets and features, such as distinguishing object placement position, individual and stackable items, etc.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 18th Sep 2010 18:20
Oh, I forgot to address the second part of your post.

Yes I do plan to have some kind of World Builder Application(s) so that I can build my rooms, mobs, and all the objects I want to start things off with.

I don't know if I'll need help with that portion of things, but if I do I will be sure to ask you..

As for how I'm gonna store particular data on disk. I purchased Dark Data quite some time ago, with the intention of using that. But I also am not averse to using INI, XML, or other formats for certain things where it might make more sense.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 18th Sep 2010 21:53
Well, I don't care WHY you want to do it the way you want to do it, I'm just throwing out suggestions. Use 'em or don't. Up to you.

As far as tables, or other containers, you might consider them to be objects like everything else. So, if *everything* is an object, they still might have different attributes. Like, an "objectType" attribute. An object might be a container, able to have other objects *in* it. It might also be a surface, able to have other objects *on* it. A list of objects that are *inside* another object could be stored as an array inside the UDT.

Or, you could go at it from the other direction. Each objects location could be stored on the object, and *not* as part of the objects container. Then you could loop through all objects to see if they are at a particular location. That might take more time, though, if you had a large number of objects.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 18th Sep 2010 22:53 Edited at: 18th Sep 2010 22:55
Yes, I was thinking of doing the usual Object is a treasure box, which belongs to the box type, which belongs to the containers, type, etc..

I appreciate all the input I've been given so far though, as while I may not decide to go with a particular way of doing things. It gives me pause to consider it and even other ideas I had not originally had. (storing room data in a memblock is still an interesting idea)

Regardless of how I go about it though, I am still trying to figure out the most basic way to only reference objects by ID, whatever object they may be..

I thought of using a "set" of Arrays for instance, but I'm not sure if that is either efficient, or very fast when dealing with a large, and potentially expandable game inventory (I eventually want to create unique items on the fly as special loot for instance).

Going back to the pawnshop table..

The "Table" object is an array, and it has its inventory in it..

There is also another array which mirrors the layout of the table, except it contains ID's only and is never shown to the player in any way. I suppose its sort of like a primitive Hash system (In Ruby for instance (and I think Python, I can't remember), a Hash is a key/value array).

So the player says "Get me that SECOND blue potion!"
And the game says "Ok.. search this array for the SECOND occurence of "a blue potion" and get back to me with that items Array Address - OK it's in spot Table(3)! So get me the value at the FOURTH position in the Table_ID's Array!

I can't remember whether or not DBPro has any kind of Key/Value mechanism for storage, so I'll have to go look that up and see.

I imagine this would ultimately be a cumbersome system though, and will probably lead back to the suggestion I try to lookup "searching algorithms" that was made in the original reply.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 19th Sep 2010 03:34 Edited at: 19th Sep 2010 03:43
Hrmm.. Just as an afterthought I looked into LUA.

Unity is pretty cheap ($20) and I could replace DBPros arrays with LUAs, which I think may make it easier to do what I am thinking of.

Plus you can use strings as index keys, instead of just numbers, so that might help me in some way also..

I was thinking if I were able to Type a LUA array (either via DBpro or an Internal LUA custom type declaration) and set it up to use strings as keys, those strings could be the Unique object ID's like I want.

So I could literally make a dynamic list/array/whatever with typed keys

Array(ObjectID1.name, .description, .effect, etc)
Array(ObjectID2)
Array(ObjectID3)

versus

Array(0).name, etc
Array(1)
Array(2)

etc..


Then like mentioned before, just use a (surely implemented or easily done from scratch?) LUA search function to search through the array, and verify its the object I want with its string based ID instead of having to deal with only Integers for the Array indexes..

Anyone experienced with LUA think that sounds feasible?
It's not my beloved Python, but I have been interested in using a scripting language with DBpro.. especially if there is a way to setup my program to parse external script files and use them to modify the game (be it changing out a modular system like combat rules, or adding new player commands, scripting entire story lines and game events, etc).

Maybe something like traditional game engines use to let you custom mod them to create new gameplay scenarios, or a new game altogether.

I know this is a bit of a tangent, but I've been going back and forth between purchasing Unity for a while, and I think the array features, and potential integrated scripting, are legitimate motivations for me to purchase it if they can be done.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Sep 2010 07:13 Edited at: 19th Sep 2010 07:23
Neco, your making it way more complicated that it needs to be. With text adventure games all you need to track is room numbers and item numbers. I personally don't like to use UDTs for text adventure games because it's a lot easier to use a FOR/NEXT loop to check each direction rather than the long way with UDTs. It's best not to use a 2D grid for rooms because you don't want a bunch of wasted space. Plus you may want to be able to move a player from one side of the map to another by simply walking a direction. This method gives you greater control of where each room appears to be to the user and you can change the exits at will... you can't do that with a 2D grid of rooms.

Each room can be in a regular multi-dimensional array to store the exits for each room and another array for the room name and the description. The array simply stores each exit to another room number that references itself in the same array. If you're in room number 1 and room number 17 is to the east and you go there the program then looks at the same array for room number 17 when you want to go another direction. If the room number for a particular exit is negative it's a blocked direction linked to a description in code. The room descriptions using the same room numbers are in a string array are shown as needed. The first element in the array being the room name and the rest the description.

Dimensionalizing the room arrays:


The description of the room data:


A small example of the room data:


The items are done in a similar method. Each item has an item location number. If it's a positive number it's a room number, if it's a negative number it's inside another item referenced to the item number list, and if it's in the players inventory it's zero or any number that won't be an actual room like 10000. If you do use zero for inventory and have a room number zero or you'll see everything in your inventory appear to also exist on the floor of room zero and in the players inventory at the same time. When the player goes to the room for the first time or types LOOK after it types the description it searches the first piece of item data to see which items are in the room and prints the floor text. If you pick it up it changes the room number to zero (or whatever) and if that item is placed into another item it's turned into a negative number for the item number it's placed into. Like room numbers item number zero should not be used.

Dimensionalizing the item arrays:


The description of the item data:


A small example of the item data:


In the above snip the backpack and hardhat are in the players inventory at the start, the sack is in room number 1, the torch is in room number 3, and the paper is inside item number 3 which is the sack.

I got my last name "Grueslayer" from Zork... trust me it works.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 19th Sep 2010 17:58
I'd like to second Grog's explanation of the room data. For example, with a 2D grid everything becomes grid-like and predictable, and you can't have short-cuts to distant rooms (for example teleports or long windy tunnels).

The item data is where I would use a UDT, but pretty much mirror the structure that Grog has used anyway (UDT is more readable in code).

Finally, I'd put everything in spreadsheets, saving them out to CSV when I make changes, and having a separate program convert that to a condensed format that would be loadable by your adventure program (with my plug-ins that conversion program would load the data into arrays with definitions that match your adventure game program, then SAVE ARRAY TO DATAFILE directly into a file, the game would load using LOAD ARRAY FROM DATAFILE).

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 19th Sep 2010 19:54 Edited at: 19th Sep 2010 19:56
Thanks for the continued feedback.

I don't want to sound combative, but I don't "see" the restrictiveness of a 2D array, in relation to short-cuts. Although I do acknowledge the "predictable" nature of a grid system, and that I actually had not considered implementing those types of things (although to me writing an internal command that simply modified the players coordinates and prints the new room they are in, seems pretty straightforward)

I do find a lot of merit in the suggestions, but I also must admit - that code reads like gibberish to me, but to be fair you probably did it quickly and I'm sure this method could fill a small tutorial as far as teaching someone the basics.

For me I guess the way I approach designing these things is, finding a tradeoff between something I can physically model and mentally follow, and making something that plays well and is resource efficient.

I guess what I end up with, is something that seems clear and makes sense to me, but others see as overly complicated. I think I also trip myself up to a degree because I lose interest in something if it is not challenging (as opposed to outright boring or not making sense from the start, leaving me no incentive) so I can understand what people mean when they say I make things harder than they have to be... I guess I just like/need them to be that way?

Wasted space in arrays is a very fair point, I could see quite a fair bit of wasted space where I choose to run a street diagonal, etc. Which is also why I had considered doing it in a one dimensional array as well, or (as mentioned earlier) a linked list or something similar, and then building the World Crafting application to handle and keep track of that.

You guys are giving me lots to think about though and I appreciate your suggestions (and patience)

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Sep 2010 01:37
Quote: "I do find a lot of merit in the suggestions, but I also must admit - that code reads like gibberish to me, but to be fair you probably did it quickly and I'm sure this method could fill a small tutorial as far as teaching someone the basics."


Actually the only code was the DIM statements... the other snips were copies of the text file I made to explain the data structure of all my files and the actual data from the room and item files. All of it is from a text adventure I made myself but never finished. There actually is a tutorial on making a text adventure game by Pluto. He made it back when I wasn't posting for a bit otherwise I would of added my 2 cents.

http://forum.thegamecreators.com/?m=forum_view&b=7&t=129931&p=0


@ IanM:

Thanks for seconding my explanation of room data.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 20th Sep 2010 02:54 Edited at: 20th Sep 2010 02:56
Ok, that tutorial link definitely helped explain the concept better, although I've only skimmed it (heading to bed soon).

Although I will definitely read the whole thing tomorrow at some point, I am still strongly in favor of a grid system. I guess I won't know for sure until I finally decide, but I spent the day thinking of how I might do a grid system, with emphasis on no wasted space in the array... So these are some ideas I had in that regard.

Given that I use Visio 2010 to create maps for my areas before I even start to write them (so I know where I want everything to be, what it looks like as a physical model, etc). I figured it was easy enough to just drop array element numbers on them, for their reserved space in the game map array.

The first method is ultra sparse and uses every last bit of space. It would be nothing but a 1 dimensional array, and I would assign element numbers in order, starting with 0 on the very first map I draw and continuing to increment the numbers in logical order across different maps. Assignment would go Left to Right, from the Top down.

The second method is to create a 1D array for each separate "Area block" of the game. 1 area might encompass a very large city, or an area might encompass a relatively small town as well as the wilderness that borders its outskirts, or the wildnerss in some areas might have their own array.

The third method is to create a 2D array and use it in Row/Column configuration, like an SQL database might look like.

0 1 2 3 4 5 6 7 8 9
1 1 2 3 4 5 6 7 8 9
2 1 2 3 4 5 6 7 8 9
3 1 2 3 4 5 6 7 8 9
4 1 2 3 4 5 6 7 8 9
5 1 2 3 4 5 6 7 8 9

(I don't know if that's the correct representation for a 2D matrix or which digit would come first, for some reason I'm drawing a blank)

So each verticle "row" in the array will contain the data for one specific area of the game, across all its columns. I'm sure everyone gets what I am saying.

I'm pretty sure "linking" areas would also be a trivial issue, and in some cases the World Builder could dynamically resize the array if I wanted to change the total number of elements or reduce them, etc. The third example would have wasted space, unless I had areas overlapping to/from other rows to use all free space

Certainly not pretty.. but a much more efficient usage than my original starting idea. Of course I will still look into the DATA statements thing, but if I decide to stick with the grid system - please don't scream, k?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Sep 2010 04:29
I want to again discourage you from using a 2D grid. Even if you manage to use all the space you ultimately will make it harder to find the data you need. With a 2D grid you'd have to assign room numbers and the links to each other room number... simple enough but what happens when you're in a room and you want to switch rooms. You would have to create code to search the 2D grid for the right room number.

It's a lot easier to use an array like I showed because to switch room numbers you simply make the variable you use for the players current room number equal to the number in the exit they desire to go to.

The DIM statement again with rem statements:


Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 20th Sep 2010 17:42 Edited at: 20th Sep 2010 17:46
I do understand what you're saying. And I haven't decided yet (I just got home so will read the tutorial in full very soon).

But I would like to point out one thing, also. If I use even a 2D grid (I'm leaning towards 1D) during the design phase when I do my initial area maps, their array positions would be assigned, and a number placed in that rooms square, on my map. (basic square map linked with lines). Then when it comes down to putting the info into my world app, I already know where to tell it the room belongs, instead of letting it figure it out.

Technically I would not need to assign a room number, because the array position becomes this number by default (its unique and there is only ever 1 room at that address)

Yes I will assign direction linkages, however part of my general room printing routine will also be to print out a line with the obvious exits (hidden paths, etc will not be shown).

So using a Room Type that contains an "Exit list" type, only valid exits to other linked rooms get printed as an exit, and if the user were to try to go North when there is no North exit, for example, the parser would take care of that by recognizing a directional movement command, and then checking to see if the North property is null or not. Null data (or whatever value I want to indicate "no")? Can't go that way.

Let's say West is valid.. If you wanted to go West instead, the parser would check the West property from the exits list, and pull the array index, then pass it along to where it needs to go (update player position, call room printing routine, etc).

I used the same system in my Python prototype and it worked very well. The only difference back then is I didn't have a map in my Python version, I simply linked by ID's, then queried an embeded SQLite database for the proper room, and dumped everything into a "Current Room" variable.


Anyhow, I'm off to read that tutorial now.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Sep 2010 18:11 Edited at: 20th Sep 2010 18:15
Quote: "Technically I would not need to assign a room number, because the array position becomes this number by default (its unique and there is only ever 1 room at that address)

Yes I will assign direction linkages, however part of my general room printing routine will also be to print out a line with the obvious exits (hidden paths, etc will not be shown).
"


Ah. Because you said you would use every possible space in the 2D grid and have the ability to move the player to any room with exit locations assigned I assumed that you wouldn't use the 2D grids natural proximity to each grid space for movement. So if you use the natural exits with a few blocked areas you'd basically have a text maze. A maze or two in a text adventure is ok but not the entire map. I encourage you to keep leaning towards 1D.

Ultimately it's up to you but no matter what you decide I'm glad your making a text adventure and hope you post the .exe so I can play.

Also I know you want to use Visio 2010 to create the map but have you tried programs that were specifically designed to make text adventure maps? They may be easier to use.

16 different mappers:
http://www.ifarchive.org/indexes/if-archiveXmapping-tools.html

The newest mapper:
http://trizbort.genstein.net/

tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 20th Sep 2010 20:04
When I hear about people bumping into limitations of DBPro data structures, I start to think of DarkData. I think IanM's suggestion of a CSV for content creation then a loader program to populate data is key. Make it a DarkData type database structure and then to top it off you can write a game engine to access and react to what is in the database.


A 3D marble platformer using Newton physics.
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 20th Sep 2010 20:40
I do intend to use DarkData - that's what I purchased it for... Since I can't use SQLite *cry*

However I would have assumed trudging down the road of pulling everything from the DB as needed (low memory usage for sure) would get me a lot of no-no's as that is a LOT of HDD access for a text game of all things.

I have no idea what the final memory footprint will be, but if its looking like its gonna get huge, then I might implement some savings in that way.

Grog, on the subject of 1D.. Do you think its better to have one huge array, or split it into smaller area based arrays and then hand off to the next array when you pass a boundry room, etc.. ?


As far as Visio, this is purely for planning and later recollection purposes. I prefer Visio because its simple to use and I can make my own shapes to represent any map objects I want.

I don't think the tool to make the maps is as important as just having some maps to go by

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Sep 2010 22:29
Quote: "Grog, on the subject of 1D.. Do you think its better to have one huge array, or split it into smaller area based arrays and then hand off to the next array when you pass a boundry room, etc.. ?"


You're right about not wanting to access the HD over and over again just for text... nobody would like that. I would keep all map data one array and just keep it all in memory (loaded at the beginning of the program). Even the huge text adventure games don't have more than 150 rooms.

I've never used DarkData but IanMs Matrix 1 Utilities Plugin has some really nice database commands to make working with files a whole lot easier. He also makes a better SAVE ARRAY command called SAVE ARRAY TO DATAFILE which saves UDTs too and the opposite LOAD ARRAY FROM DATAFILE. Use those two commands and you've already created your games save/load routine.

Best of all IanM still allows us to have Matrix 1 Utilities Plugin for free. If you don't have it yet click the link below to add more greatness to Darkbasic Pro (there are a lot more useful commands of course). I'm starting to sound like I'm obsessed with IanMs Plugin but being a little crazy is worth it.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18

Quote: "I don't think the tool to make the maps is as important as just having some maps to go by"


Yeah your right. Actually with all this text adventure talk I'm tempted to make a new one myself.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 20th Sep 2010 23:04 Edited at: 20th Sep 2010 23:11
I do have the Matrix Utilities. I was also considering his Save/Load commands, but I also paid money for DarkData so I may as well use it. It looks like a very solid product and has a nice feature or two as well.

Although, hoping these aren't famous last words, but my game may possibly be well over 150 rooms. It may come close to 1,000 in the end. I've attached a rough draft map of one of the towns that will be in the game, and its already 25 rooms. It also features the array indexing numbers for the order in which the town would be "built" in to the array

It all depends on several factors though, the least of which is me not getting burned out creatively. I'm hoping this is the first big project I can really finish, as I've struggled with learning to program since I first picked up a book at 15 (not a cheap endeavor for my parents either).

Once I get some basics working, so that you can walk around in some rooms, and flesh out the GUI some more, I will post a (hopefully) working Demo for people to play with



Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 21st Sep 2010 01:42 Edited at: 21st Sep 2010 01:57
Quote: "Yeah your right. Actually with all this text adventure talk I'm tempted to make a new one myself. "


Yeah, me too. The last time I wrote one was using ADRIFT, which I found to be really easy to use.

ADRIFT

and here's the game. Small, but I had fun writing it.

Where Is Richard?

And here's a screenshot...



Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Sep 2010 11:12
@ Neco:

It's good that you already have IanMs Plugin since his string commands will be vital for quick text parsing. If you have any problems with any part or get burned out post a message and we will all try to help you though it. We all hope you finish this text adventure.

@ Rich Dersheimer:

Cool! I downloaded your game but I'm stuck. I got everything in the closets and got into the attic but other than that I have no clue what to do.

I'm definitely going to make a new text adventure (from scratch) but I'll do it in Darkbasic Pro.

Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 21st Sep 2010 14:32
Grog - examine the computer screen, it will show you several messages as you progress.

Good job getting up into the attic! Have you visited the basement as well?

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 21st Sep 2010 17:40 Edited at: 21st Sep 2010 17:44
Actually, I nixed the string commands DLL last night, because I was sick of the compiler warning (naming conflict with Styx) and I'm using Styx text commands at the moment for some things.

I would assume Styx commands are also faster than DB's standard stuff or I could be wrong, but I can't really tell at the moment since I'm not putting a lot of text on the screen at this stage.

I actually started to come up with with a nice basic line-wrap function, now I just have to write the part that scrolls the appropriate amount of lines for the wrapped text. Most methods I've seen read one character at a time, but mine doesn't need to do that.

TDK's scrolling text box with commented code was a huge help to me in figuring out how I wanted to design my own. If you're reading this, TDK, I appreciate all the comments you added for me

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Sep 2010 00:16
Quote: "I would assume Styx commands are also faster than DB's standard stuff"

And you'd be wrong.

There's no direct equivalence between them, but you'll find that the DBPro and Matrix1 string commands together provide everything that Styx does, and they do it faster too.

Styx, being written in a .NET language, needs to convert strings to and from DBPro string format for all of the string commands, and that's overhead that there's no way to get rid of.

Having said all that, you are writing a text adventure, so speed probably isn't really something you need to worry about.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 22nd Sep 2010 00:23
That's interesting information, thanks.

Is there any way I can run a test to compare the speed differences? No real particular reason other than "cause I want to"...

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Sep 2010 07:25 Edited at: 23rd Sep 2010 08:15
Quote: "Grog - examine the computer screen, it will show you several messages as you progress.

Good job getting up into the attic! Have you visited the basement as well?"


Thanks I completely forgot about the computer screen. Now I've got the booth ready for dimensional travel (and 300 points) but I can't start it. I'll keep trying till you reply with another hint.

Edit: I just go it going. Apparently there was a timer on pressing the button in the booth 'cause it didn't work right away. So I'm off to a new area and don't need any hints right now.

Edit Again: I finished it with 900 points (see attached image). It's a great adventure and you should make more for sure. What threw me off at the end was the comment "It's too heavy." when I tried to pick up the pick and then later the beacon at the end. I assumed the pick was just that "too heavy" but when I saw the beacon was "too heavy" I knew it meant I was carrying too much. Thanks for letting me play it Rich.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Sep 2010 15:47
Quote: "Is there any way I can run a test to compare the speed differences?"

Sure. Some commands are fairly similar - simply repeat the same complete operation a few hundred thousand times or more while timing it.

* By 'complete operation' I mean that in some cases you need to run several commands together. For example my SPLIT STRING and related commands - you'll get no useful information by simply running a single command in this set. Get all of the words extracted.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 23rd Sep 2010 15:50
Grog - grats! I've started on the sequel, hopefully it will be a bit longer.

Neco - sorry about hijacking the thread a bit. I'll be watching here to see your progress. Your examples of gameplay show a clever wit and writing style. Can't wait to see the game!

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 23rd Sep 2010 16:37
I don't think you hijacked it... too much.

I can definitely write - when I feel like writing :p trying to force it just comes out all wrong.

Also I wanted to clear up one thing for everyone. A little pet peeve of mine.

It's not a Text 'Adventure' !!!

I'm making a Text RPG

Thank you..

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Sep 2010 18:57
@ Rich:

Cool! I can't wait to play the sequel.

@ Neco:

I was thinking about that for mine too. But mine is going to be a sci-fi text adventure like Planetfall with RPG elements like Beyond Zork but with a look similar to Zork Zero.

http://en.wikipedia.org/wiki/Planetfall

http://en.wikipedia.org/wiki/Beyond_Zork



Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 23rd Sep 2010 19:37
Quote: "Also I wanted to clear up one thing for everyone. A little pet peeve of mine.

It's not a Text 'Adventure' !!!

I'm making a Text RPG
"


Even better!

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 23rd Sep 2010 19:55 Edited at: 23rd Sep 2010 19:59
I still haven't decided how much of an RPG it's gonna really "be" but I am hoping in the end.. It reads like a mix between an interactive book (plot on rails) and a free roaming game where you have quite a bit of freedom.

(Divine Divinity is a good example of this.. It has a plot, but TONS of quests and you can go anywhere you want in any sequence, as long as your can physically survive the trip.. great game, way better than Diablo 1/2)

I'm still on the fence about free roaming mobs or placed + random encounters.. As well as group based combat and the whole party system (kind of hard to do a party in text without being overly verbose).

But as far as the world setting, its strickly sword and board fantasy, with a bit of magic.. The typical formula to say the least. But it's going to be based in a world I actually started creating for an unfinished book I started when I was 18.. (really wish I had finished it, I'd probably be rich or something).

All in all, very Tolkien inspired. But I've been writing since the 8th grade as well. Have about 10+ years of free-form chat room RP experience (typed on the fly, no official combat rules/systems) and a good 10 years playing GemStone IV (was III when I signed up).

So hopefully that will give me enough foresight to make a really neat game..

I don't see the GUI being very graphics laden at all.. Most all of the interaction is going to be done through text commands, and possibly some macro'd keys.. I am going to experiment with making a basic graphic that takes up the whole screen and has stuff carved out for the text box, and other status displays I may want to include. Or I may have to go old school and make a purely text driven UI.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 3rd Oct 2010 00:25 Edited at: 3rd Oct 2010 00:45
Well, I haven't really made much progress at this point mostly because I have been doing a little free form experimentation with ideas as they come to me, and things of that nature.

I did take some time and start working on a World Editor application, a very simple one but effective for my immediate needs.. I focused on putting how I want to build my rooms and save that data into practice.

I rather painlessly wrote some code to use Matrix1 Utilities' Array Saving and Loading functions, as I don't have the time or desire to play around with Dark Data right now. It was very painless to save an array out (haven't tried loading back yet...baby steps) and I think I may use this to some degree.

Currently I've started writing my room printing function, which will include the steps of finding the room data and printing it to the screen, also ditching the FOR/NEXT loop for scrolling my Screen_Buffer array in favor of trying to implement the Rotation idea suggested earlier. Also going to work on some primitive coloring of text..

Right now I'm sitting on a compromise solution that will not require me to code tags of any kind into the actual room data, as I build each room.. Instead, since my display routine prints line by line, I am simply going to color certain lines, or parts of a line, as they are printed. Which will suffice for now.


I kind of hit a fork in the road with regards to how I want to handle my special room exits.. Things like Doors, hidden paths that need to be uncovered with a skill check, and stuff like that.. I will probably redo them using a "portal" UDT archetype, and make child types from that for specific objects.. and then place them in the room that way.. So that way I could easily have two doors if I wanted and stuff like that..

Not quite sure how I want to handle room objects, and making sure they are displayed in the correct room, can't be referenced when they shouldn't be, etc.. I was thinking of just keeping a separate array for that, but not sure that is worth the headache. At the same time, if I just kept a global array of objects with a Type Field that held their room address - that is equally CPU intensive as I would have to sequentially iterate every object in the game in that array, to see if it had to be displayed or not.. However I'm not really focused on addressing this problem at the moment - more so thinking a lot about what I'll mention next..

I still like the idea of using a 1 Dimensional array, however I have some things to consider.. Using the simple system of assigning each room a place in the array at build time works well at first.. However I did not take into consideration a couple things

Interiors of Buildings, potentially multi-level buildings, as well as below-ground levels (caverns and tunnels or whatnot). It might be well handled if you build them all in the first time, but thats a pain to add in later, IMHO. You would end up with a fragmented mix of data all over the array.

So I am again thinking of splitting the areas of the game into multiple arrays, based on sections, as well as using a room ID field, instead of relying on the array index.

The main problem with searching through an array for a matching ID field is processing time, but I think this will be negated by sectioning out the game areas into multiple arrays.. The call for a room will also include its Array Name by default, so passing into new areas makes array switching pretty much seamless.

This is pretty much what I've decided to do. Perhaps against some better judgement, but this way I can build any room I want, in any order I want, add on to an area later, and so on and so forth.

Realistically, searching for an ID in a For/Next loop in an array of 20 to 50 rooms, I don't think is going to be a huge burden on any computer, especially versus the alternative of searching through one massive array for something that might be at the very end, or using a very rigid and strict Array index assignment strategy that makes it no fun for me to personally work with.

Once again, I thank everyone for their input, as it has been really helpful. We may not all agree on the best way to do something, but that's just how it goes..

I hope to put up a WIP build soon enough, that will let you walk around through a decent sized area, have colorized text, and maybe the beginnings of the GUI I plan to use (nothing fancy, just a single image with pre-made areas for text to be displayed).

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 3rd Oct 2010 00:46 Edited at: 3rd Oct 2010 00:47
Forgot to add this bit.. might as well separate it in a new post though, as I'd really like an answer and don't want anyone who might know to miss it in the sea of text above..

Is it possible to make a "Hash Map/Table/whatever" in DB relatively easily? Or is there another similar method DB programmers use.

If I simply made a map of the array with Key/Value pairs, I assume the cost in memory would be worth the gain in performance from not having to sequentially search through anything?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Oct 2010 08:32 Edited at: 3rd Oct 2010 09:13
Quote: "Is it possible to make a "Hash Map/Table/whatever" in DB relatively easily? Or is there another similar method DB programmers use."


Are you wanting to create a reference to the item list within the room data? If so it is possible but it would be just as quick to use a FOR/NEXT loop to search the item list to see which items are in the current room. The user wouldn't know the speed difference.

Added later after some thought about your message:
Quote: "I kind of hit a fork in the road with regards to how I want to handle my special room exits.. Things like Doors, hidden paths that need to be uncovered with a skill check, and stuff like that.. I will probably redo them using a "portal" UDT archetype, and make child types from that for specific objects.. and then place them in the room that way.. So that way I could easily have two doors if I wanted and stuff like that.."


With the method I mentioned before you could do doors and special paths easily by using negative numbers. Not just -1, -2, -3, and so on but nested within the negative number could be other numbers for data. If you say all locked doors are -10 and you want to use item number 15 to unlock the door use -10015 to add a room number that door leads to say 35 make it -10015035 for the exit. -11 could be an unlocked but still closed door -11015035 and -12 could be an unlocked and open door -12015035. Giving the user (with the reference data still in the exit data) the ability to close and relock the door any time they want. When the user goes that direction a simple check to see if it's a closed locked, closed unlocked, or an open door that automatically lets the user go to room number 35 is easy. The program would know instantly that there is a north, south, and west door... or even a room with every exit as a door with it's own key or the same key works for all doors.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Oct 2010 19:23
I saw your message in Game Theory. I had no idea you've never played the most influential game that basically started the text adventure genre.

Zork was finished in 1979 and sat on the MIT mainframe till home computers started popping up and they decided to split Zork into 3 games mainly because computers didn't have enough space to take the original huge game. Because of Zorks popularity Infocom was created to make text adventures and many high quality games were made. Thankfully the first 3 Zorks did eventually become available for free so I encourage you to download and play at least Zork 1. If you really truely want to know what a good text adventure is you have to play Zork.

http://www.infocom-if.org/downloads/downloads.html

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 3rd Oct 2010 19:54 Edited at: 3rd Oct 2010 19:59
It's true... I never played it. I had a copy of Zork at one point, but I couldn't get into it at that time. I will revisit it later perhaps.

re: The Hash question.

I suppose you could call it a reference. I think in C++ it's just called a "map" or something like that. But I'm thinking along the lines of a Dictionary of simple key:value pairs.

Not sure I would want to use it for items, but as far as the current implementation of my rooms, I wanted to map named reference to Array Indeces. Maybe I'll try the room system you want me to use in a future project, but I just don't have the free time to get the idea to sink in (I can look at it for an hour and still not "get" it.. it's a problem I've had with learning since childhood)

Using named references is simply going to be easier for me in this regard, and would let me design the maps in a grid fashion, but store them efficiently. So using my old model of addressing.



So the question was, dealing with the fact I am gonna be sticking an ID tag on each room, is it gonna matter if I have a FOR/NEXT searching an unordered array of potentially 500+ objects? Or is the Map going to be worth the cost it takes in memory for instant address resolution.

RiiDii
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 3rd Oct 2010 20:26
Here's another way to accomplish managing a text adventure and all the objects contained there-in: Using file system folders, shortcuts and text files.

Objects are simply text files with script. The script can include descriptions, flags, function calls, triggers, etc. Ian M's Matrix Utilities makes it easy to parse a function call from a script.

Containers and Locations are folders with like-named text files within the folder for description and function scripts. Include in the script file can be a flag indicating if the Folder is a location or a container.

Shortcuts would act as passages to other locations, with like-named text-script files in the containing folder describing what the passage looks like (e.g. "A dark passage to the south-east") and any function scripting.

A room might look like this:

TxtAdvGame/World/Grueville/SpookyHouse/Bedroom/
...with the following files...
Bedroom.txt
Bed(Folder - if the bed is a "container")
Bed.txt
Dresser(Folder)
Dresser/DrinkMePotion.txt
Dresser.txt
Flashlight.txt
CoinJar(Folder)
CoinJar/Quarter.txt
CoinJar/Dime.txt
CoinJar.txt
BedroomDoor(Shortcut to SpookyHouse/Hall)
BedroomDoor.txt
ClosetDoor(Shortcut to SpookyHouse/BedroomCloset)
ClosetDoor.txt
MouseHole(Shortcut to /Grueville/MouseMazeEntrance5)
MouseHole.txt

Inventory is easy-cheesy. If the player picks up the flashlight, move the flashlight.txt file to the player's inventory folder (TxtAdvGame/Player/Inventory). The same can be accomplished with containers. When moving a container folder - all the contents would go with it (for example, the player picks up the coin jar).
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 5th Oct 2010 14:41 Edited at: 5th Oct 2010 14:52
I didn't bother to read all the comments, because after the first couple of posts I got inspired to write a small example of how I would probably do the "objects"...

So here it is...



Don't now if it is of any use to you, but I had fun making it so...

- enderleit
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 5th Oct 2010 21:26
Thanks for your contribution. That was an interesting bit of code to read through, and hopefully it will give me some ideas as well.



IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Oct 2010 21:32 Edited at: 5th Oct 2010 21:34
Regarding your key:value pairs, create a UDT containing that pair, create an array based on that UDT, then populate the array. Then use the SORT ARRAY command from my plug-ins to sort on your key field. Finally, write yourself a binary search function to search that array.

Or, you could take a look at the hash table implementation I posted into the Codebase and see if you can make any sense of it.

[edit]
Or another method is to use key:value lookup tables - the values are stored as strings, so you may need to convert to/from your value type to use them if their type isn't string.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 5th Oct 2010 21:41
Thanks Ian, I will look into that... I know a Binary Search Function is probably beyond my grasp, but a Key:Value lookup table is pretty much what I was thinking of at this point.

I will also check out your hash table code.

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 5th Oct 2010 23:18
Quote: "It reads like a mix between an interactive book (plot on rails)"


You may be too young to remember, but as a kid I read some RPG type books that had questions such as "You face a fearsome dragon" and then "if you decide to fight, turn to page 20. If you decide to run, turn to page 50" etc Each choice continued the story with a different outcome. (Usually death for all except 1 choice!)
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 5th Oct 2010 23:23
We had those kind of books too, when I was a kid. I think it was something like the "Choose Your Own Adventure" line.

I got very bored with them and skipped around, and found it annoying to have to go back..lol

The first one I read was called Invasion of The Turons, or something like that... was pretty interesting sci-fi.. They banned all forms of electricity including simple batteries, because a simple flashlight beam pointed at their ship could apparently bring them down.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Oct 2010 23:27
Quote: "You may be too young to remember, but as a kid I read some RPG type books that had questions such as "You face a fearsome dragon" and then "if you decide to fight, turn to page 20. If you decide to run, turn to page 50" etc Each choice continued the story with a different outcome. (Usually death for all except 1 choice!)"


Their called Choose Your Own Adventure Books. There have been a few books like that based on Zork.



A long time ago I made a choose your own adventure book program in QuickBasic. I'm sure it'd be much cooler in Darkbasic Pro since it would be easy to add animated sprites.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 11th Oct 2010 17:27 Edited at: 11th Oct 2010 17:32
Progress: I haven't touched my engine source in quite some time, as I have been working on building my World Editor, so I can actually make rooms to display with the Engine (!).

I'm pretty close to completing the room building functions, and then all I have to do is put in the save/load routines. So I went back and revisited my main display window and how that works.

Currently it's simply a FOR/NEXT loop that spits out 20 lines from the screen buffer array, however at some point (I can't find this original post at the moment) someone suggested using the ROTATE ARRAY command from Matrix Utilities, as it essentially saves 19 extra loops from being executed.

I like the idea of the ROTATE command - but it doesn't fit with my other goal, which is to have a scrollable backbuffer, so the user can review something that happened moments before, or scroll back to see something like a clue they might have missed while trying to solve a puzzle, etc..

The problem with ROTATE, is that it actually rotates the array elements (we don't want that!) so I am wondering aloud if there is any other method that will simply SHIFT all array elements to the LEFT, but NOT stick element 0 at the end of the array?

Part of me thinks I should know better about saying this, but having a command that simply shifts all elements to the left or right, by X number of indices seems like a pretty basic utility any language should have?

In an ideal world my buffer would probably function as follows...



Short of someone slaving away to make a very fast DLL that would do this, is there anything better than using a FOR/NEXT loop to manually shift all elements of the array to the left?

The earlier point about saving cycles is really starting to resonate with me, as I begin to realize this is likely going to be a pretty CPU heavy game if I ever finish it. Hundreds if not thousands of calculations going on in real-time in the background probably... So seems stupid to waste time on rendering text like that.

Or maybe I'm just being paranoid?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 11th Oct 2010 21:48 Edited at: 11th Oct 2010 21:54
I think I mentioned it earlier in this thread about using IanMs Matrix 1 Utilities Plugins DATAFILE commands to make a buffer in a file. Wherever I mentioned it I made just that to start my new text adventure. The following is a stripped down version of what I use right now. I just cut out the text coloring, image detection, bitmap fonts, and inserting text.



What this does is it outputs every text grabbed with the GETTEXT() function to a DATAFILE. To show the buffer it reads from that same DATAFILE 30 lines of text previously saved to the file. When you use the up arrow, down arrow, page up, and/or page down keys (while allowing the user to type in text) it changes CLine (that started at 30) to a higher number to go backwards in the file or a lower number to forward in the file. Each line that's saved is 200 characters... you can increase or decrease the amount as you see fit. Just be sure that all lines in the file are the same length (delete the old buffer file) or it won't calculate where the strings start properly. And don't forget to add 2 to the calculation because strings have 2 extra characters added to them when their saved.

Using a file rather than an array gives you the ability to have an unlimited buffer with no need to worry about the amount of lines or speed since it only reads the currently viewed lines. It's mainly the DATAFILE commands that make me IanMs greatest fan.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 11th Oct 2010 23:37
I appreciate that.. But I like the idea of using an array with a set limit (perhaps lets the user change that to their preference as well) because it just seems a lot simpler to fetch that data from the "history".

A user doesn't need an entire history of their play session, I don't think.. just enough to scroll back a few minutes or something like that.

I'm not sure I'm gonna find an easy way of scrolling the currently viewable text than a FOR/NEXT loop as it is.. and all it would take to all the backbuffer functionality is to include a command to move indices forwards and backwards with the FOR/NEXT loop.

I suppose in this case I prefer simplicity over complexity. But I don't know how I'm going to get my colors implemented at this point.. (See my "Colored Text" thread) At least not the way -I- want to do it.. I can't think of a way to get individually colored words within a string, much less keeping those colors when reading it from an array..

Getting markers into a string is no problem at all, but I don't understand how all those MUD clients can do their parsing to display individually colored words within the same line, etc.. Much less within a text box that scrolls up and down, and which I would assume involves an array of some sort?

Hitting one of those discouraging roadblocks...meh

Login to post a reply

Server time is: 2026-07-23 10:35:03
Your offset time is: 2026-07-23 10:35:03