Jump to content


Photo

Lite Data Structures


  • Please log in to reply
5 replies to this topic

#1 Experimenator

Experimenator

    Java Developer

  • GMC Member
  • 356 posts
  • Version:GM8

Posted 28 June 2012 - 09:27 PM

Lite Data Structures

v1.0


Download: http://www.2shared.c...Structures.html


I made a complete copy (+more) of GameMaker's Data Structures.
I spent some 6 days making this and more than 2 hours writing this topic,
so I will suppose I did a good job
I'll go explaining through FAQ:

What is this?

As you know, Data Structures are only for Pro version of game maker.
This will help you to use data structures even without Pro edition!
This way you can manage the memory much easily!

How to use it?

It's simple to install.
Just create a new object called DSL_MEM and put this code in it's :GM123: create event:
dsl_make_memory();


Or you can do this:
Create a new object with any name (ex. obj_memory) and, as above, and put this code in it's :GM123: create event:
dsl_make_memory();
but then before anything you do with other functions, do:
dsl_set_memory(obj_memory);
That's all.

Now just use data structures as you will do in pro edition, just add that 'l' at the end of each function beginning.

Why are you using instances instead of arrays?

Arrays:
  • Cannot be deleted after once declared
  • Cannot switch to global-local-var
  • Can only go up to 32000 elements
Instances can do all that, thus I chose them to be the memory.
Arrays are just tooo static to be used alone in such dynamic allocation
Also, I'm pretty sure GM too internally uses similar system to deal with this (aka classes and objects)

But wouldn't that make the game slow?

Not at all. These memory objects do not have any Loop events (like :GM126: :GM131: ) therefor they wont get executed, and thus they wont slow the game down. They are just static object used only to store elements, not for executing commands.

Do these data structures also have the limit of 32000?

No.
You see, If you fill the whole 1D array with 32000 real values, you'll end up with very small, pathetic 250KB of memory. This needs to be extended somehow.
Thus, I made a longer version of data structures. They can make an array in size of more than a billion elements, and go up to 8GB of memory! :D
You're not limited in size at all now!

Though, this comes with a cost. A little one. All Long data structures are 25% slower than the original, Short DSs.

All these Long Data Structures have the 'l' character at the end of the DS's name.
For example:
dsl_stackl_create();
dsl_listl_create();
...

Are these data structures fast?

Yes. Very.
All data structures have specially been improvised to work as fast as possible.
But even though, all (Short) data structures are 3 times slower than original, GM's data structures.
But you should not to be concerned. That is still very fast actually.

Which is the fastest and which is the slowest data structure?

Stacks should be the fastest since they have almost no loop functions (except copy, read and write)
But Lists, (and surprisingly) Queues are almost just as fast.
Grids are fast, but still slower than Stacks,Queues and Lists.

Priority and Maps are very very slow. It's not because my scripts are slow, its because they're naturally slow as they have to search the whole array to find the match. Even internal GM's map and priority are slow.

But not to worry as there is a rescue data structures I made! They're called Fast Priorities and Maps.
Unfortunately, Fast Priorities aren't working, but anyway... At least Fast Maps are working... Barely...
Basically, I created these to improved the speed of these 2 data structures.
While GM's Maps will break down making 30000 elements, Fast Maps will make the same amount in about 1000ms (1 second) which means that Fast Maps are even faster than GM! :)

The FastDS's system is very complex and hard to make and that's why

What are these "Cubes" and "Space-Times"?

Those are 3D and 4D data structures! :D
These may not only be useful to lite users, but also to Pro users!

The cubes are pretty much the same as grids, only that they have 3 dimensions.
Disks become Spheres and Grids become Blocks.

Unfortunately I didn't make much of 4D because I didn't have much time, only some basic functions.

Be careful when using these two because they are extremely memory consuming and with that, time too.
For example, imagine a cube 10x10x10. Seems small but that's actually 1000 cells and 8KB of memory.
32x32x32 box already passes the limit 32000 therefor the 3D cubes had to be extended so you can declare a box as large as 1000x1000x1000. But I doubt that you will ever make it create a cube that large.

And if 3D is that memory consuming, imagine how 4D will be.
So be careful.

When will the next update come and what will it contain?

I don't know yet when, but if I find time I'll update
I will fix all the bugs and glitches, but as well fix and improve all the functions in all data structures.
Not to mention making new useful functions

How can I support?

You can add me in credits of your game.
But if you really don't want to, at least +1 me

And since this is only version 1.0, it's probably full of bugs and glitches
so please HELP ME FIND ALL THE GLITCHES IN THIS LIBRARY!

Where can I download?

2shared: http://www.2shared.c...Structures.html
Sorry, I have no better file host site :/
(If link is broken, please inform me!)




That's about it. if you have any questions or suggestions, feel free to post.

Edited by Experimenator, 28 June 2012 - 09:39 PM.

  • 0

#2 famous

famous

    GMC Member

  • GMC Member
  • 169 posts
  • Version:Unknown

Posted 28 June 2012 - 09:38 PM

Using Arrays is much more efficient than Objects! A blank Object has a big Structure and reserves much memory and also will be processed. (not slowing down suchlike using Events)

I hope ive misread this. Also YYG will surely not accept this by giving Lite Users basic Features of PRO. Posted Image
  • 0

#3 Experimenator

Experimenator

    Java Developer

  • GMC Member
  • 356 posts
  • Version:GM8

Posted 28 June 2012 - 09:52 PM

They allowed http://gmc.yoyogames...howtopic=488270 so I'm 100% sure they will allow this too :)

And as I said, Objects are just much more better to use to control memory than simple variables.
That's easy to see when simple languages with no Classes like C die,
and Object-Orientated languages like C++ C# Java succeed.
I just didn't know where to find classes rather than in objects and instances.

And for arrays

  • Cannot be deleted after once declared
  • Cannot switch to global-local-var
  • Can only go up to 32000 elements

Even doe arrays are indeed faster (and C is faster than C++),
they're hard to control.


Also, I tried creating 10000 instances and FPS is constantly 30
Only at 30000 FPS starts to wobble.
But I don't think anyone will ever need that much Data Structures created in 1 moment.

Edited by Experimenator, 28 June 2012 - 09:54 PM.

  • 0

#4 famous

famous

    GMC Member

  • GMC Member
  • 169 posts
  • Version:Unknown

Posted 28 June 2012 - 10:05 PM

YYG is terrifying noneserious.

Sure, Arrays can't be freed(next absurd missing feature) but you could re-use them. Im not sure, but Game Maker supports multi-demsional Arrays? ^^ 2 as far i know.. hope.. that's sadlyPosted Image. But why you wrote this althought theres another solution doin this?
  • 0

#5 Experimenator

Experimenator

    Java Developer

  • GMC Member
  • 356 posts
  • Version:GM8

Posted 28 June 2012 - 10:14 PM

I kinda don't understand some parts.

YYG is terrifying noneserious.

What?

Sure, Arrays can't be freed(next absurd missing feature) but you could re-use them.

Since GM doesn't support multidimensional arrays, it will be hard to store all that in only 1 (or several) variables.
I could try to make a prototype but I'm not sure because the system will have to be more complex and therefor slower.
That's something like "Fast Maps" of above does....

but Game Maker supports multi-demsional Arrays? ^^ 2 as far i know.. hope.. that's sadl

Yes but you can simulate multidimensional arrays with 1D array. That's exactly what I did for 3D and 4D structures.

But why you wrote this althought theres another solution doin this?

What do you mean? What other solution?
  • 0

#6 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2057 posts
  • Version:Mac

Posted 28 June 2012 - 11:13 PM

This looks awesome. I have no use for it but I'll have to keep it in mind. I never would've thought to use instances.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users