Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 1,498 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Control huge amounts of data/variables #286307
08/24/09 15:23
08/24/09 15:23
Joined: Jul 2009
Posts: 36
S
SomebodyNew Offline OP
Newbie
SomebodyNew  Offline OP
Newbie
S

Joined: Jul 2009
Posts: 36
Hello everyone, smile

I'm working on a game where I want to give the player as much room as I can to play with different equipment/abilities. In order to do so I made a huge amount of different items each with different stats and abilities.
This is comparable to some role-play-games where you have a character that can be equiped with 10 or so different item types (helmet, gloves, boots, etc...). Then there are another 10 different variations of each item type (sandals, winter-boots, diving-boots, etc). This already amounts to 10x10 = 100 different items.
Of course I want to assign the item's stats/abilities to the player. To keep things simple I wrote a script that describes each item's specifications. Every item uses a skill (say skill1 for his car, skill2 for his job, skill3 for his suit) whereas the value stored in skill1 would determine the item (1 = audi a3, 2 = audi a4, etc...). Then I would make the player check what Item is stored in skill 1, skill2, etc. These item's abilities would then be applied to the player. Thus making the player the sum of the item's abilities he's wearing. So far so good.

Recently I've experienced the problem of making all those thing way to complex to handle them the way I do at the moment (manually coding each item). Since this type of complexity is somewhat essential to the gameplay I feel I might need to move to the next lever.

Now my goal is to:
+ make all stats/variables fast and easy to change (declaring variables has helped a lot here! But they have their limits).

I thought about this for quiet some time. I think the best way to do this would be to make an excel-like-sheet (probably in the windows editor) and than list all the items/stats/abilities/whatever and it's values here. So that when you start the game it would simply read that file and assign skills/variables accordingly.
The game searches for the word „bowtie“ then reads the next 10 numbers in the same line. The first number describes the item's cost. The second the item's prestige, etc.
Of course this can also be done using a (or multiple) really huge matrix/matrizes. The manual however recommends not going overboard with the matrix size (although I do not know if that really is a problem with a 2dimensional matrix like a 50*1000).

Well, these are just some ideas I came up with. So before I jump into this I'd like to hear your opinion on it, since i'm sure this problem has not only arisen a thouasand times earlier before but also solved many many times already.

I appreciate any suggestions/input/ideas/comments. Thank you for taking the time to read all this and bother with my problems.

And of course have a good start in the new week.

Re: Control huge amounts of data/variables [Re: SomebodyNew] #286329
08/24/09 17:56
08/24/09 17:56
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Wouldn't it be much easier with structs?

You define a struct for each category of item like helmet, boot, glove and inside each one you have properties that can be changed like type, colour, price, etc. So then you are only dealing with 10 different types, but with infinite variations between them.

For more info look at structs inside the manual.

Re: Control huge amounts of data/variables [Re: SomebodyNew] #286330
08/24/09 17:58
08/24/09 17:58
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Just a quick idea:
Instead of using a text file and some text file operations you could also use a Database (MySQL). There was a MySQL plugin around. Sorry that I don't have a direct link, check out the wiki and the user contributions forum if you want to use it.

Re: Control huge amounts of data/variables [Re: Xarthor] #286334
08/24/09 19:04
08/24/09 19:04
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I think a combo of both Xarthor's idea and DJBMASTER's idea combined.

A struct is a good way to store the info you want, and search the forum
for another Database tool other than MySQL. Its a bit big for what you want.
There IS another database tool that exists as "just" a DLL for lite-c
and thats all. Cant remember where it is though....

Mind you, I single array of 50,000 elements to contain every single type of item
and every single propery of EACH ONE, doesnt really sound TOO big...
But I WOULD suggest using "malloc" to build your array out of structs.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Control huge amounts of data/variables [Re: EvilSOB] #286338
08/24/09 19:20
08/24/09 19:20
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
Sorry to inform but. there is no mysql link nothing, they are all broken.

Re: Control huge amounts of data/variables [Re: MMike] #286354
08/24/09 21:56
08/24/09 21:56
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
GSTsqlite? Got this link, when I asked for similar advices.
http://www.gstools.de

Re: Control huge amounts of data/variables [Re: Pappenheimer] #287356
08/31/09 15:31
08/31/09 15:31
Joined: Jul 2009
Posts: 36
S
SomebodyNew Offline OP
Newbie
SomebodyNew  Offline OP
Newbie
S

Joined: Jul 2009
Posts: 36
It has been quiet some time now. I just wanted to let you know that I've tried out what you suggested. Here are my results:

Arrays...
for the moment I'll go with them as they really don't affect the performance and 30.000 or so entries are manageable that way. I've tried that on pretty slow machines - it works just fine. I did not experience a decrease in the framrate.
My next variable-intensive project however will definitely not use arrays! It just creates a lot of errors when you insert the right number in the wrong place (and that will happen quiet a bit!). And looking at a huge sheet filled with numbers really doesn't help finding the error.

Textfiles...
do work too. But still, it's everything but comfortable reading a *.txt from a running game. It gets even more fun when you want to save changes made during gameplay.

Structs...
somewhat similar to the arrays. But far easier to keep an overview. Honestly... I made a lot of newbie mistakes trying to use structs. So I'll have to read/practice more with structs before I can really use them I guess.


SQL/GSTlite...
that is why it took me so long to write an answer. I was not familiar with SQL (just knew it was some kind of database). After playing around with SQL I think it is way more powerful than what is needed here.

So thanks for all your help.


By any chance... do you know how the big guys in the industry approach this problem? World of warcraft for example (or any MMORPG for that matter). A couple thousand players each with loads of customizeable stats, hundreds of skills/statistics to save. Etc...

Re: Control huge amounts of data/variables [Re: SomebodyNew] #287448
08/31/09 23:04
08/31/09 23:04
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Thanks for the update.

Arrays... grin

Textfiles...
Look into the manual for the 'file_load', 'file_save' and 'add_buffer' commands.
They will let you load the whole textfile into memory, and read/write to it as per normal,
WITHOUT actually accessing the hard-drive. Then save any changes if you WANT to.

Structs...
Keep practicing. Its worth the effort. (even though you'll NEVER actually STOP practicing).

SQL/GSTlite...
I expected it would be.... BUT see my next point.

AFAIK WOW uses a SQL look-alike if not actual Microsoft SQL-server itself.
I know that if you download one of the "private server" packages for WOW,
they have a little server app that hovers over the free "MySql" database.
You then connect to it using the standard WOW client software.
This suggests to me that Blizzard(ie WOW) have multiple dedicated SQL servers,
linked up to replicate data to each other, each with its own "WOW server app" floating on top.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1