linked list-tilemap

Previous topic - Next topic

Corax

The problem with a tilemap consisting of multiple layers is the large amount of unused memory. For example, if you have a DIM like this: TileMap[1000][1000][10] and only a few indexes use 10 tiles, the waste of memory isn?t acceptable.

I thought about tilemaps that function like linked lists. Is this possible with GLB ?
If yes, can someone post an example ?

9940

hint: with REDIM you can resize an array and free the space is unused

Corax

One index could have 10 tiles, the other but 1.

Corax

Is this ?sparse matrix?possible on GLB ?

Corax

Could you explain the concept of ?sparse matrix? and post a GLB example ?
(I read the wiki-article about it, but didn?t understand it)

Kitty Hello

use a TYPE with an array, that has a dynamic size. Then make an array from that TYPE.
No big deal.

Moru

There is a short text about it in the documentation, search on Types. I haven't tried it though since I never felt the need for it.

Nobiag

I hope thats right:

Code (glbasic) Select
TYPE tmaptiles
tiles[]
ENDTYPE
GLOBAL tilemap[] AS tmaptiles

DIM tilemap[100][100]

DIM tilemap[0][0].tiles[10]
DIM tilemap[1][0].tiles[2]
...

Corax


Hemlos

#9
Quote from: Corax on 2009-Jul-01
The problem with a tilemap consisting of multiple layers is the large amount of unused memory. For example, if you have a DIM like this: TileMap[1000][1000][10] and only a few indexes use 10 tiles, the waste of memory isn?t acceptable.

I thought about tilemaps that function like linked lists. Is this possible with GLB ?
If yes, can someone post an example ?

Its not a waste of memory, it is a waste of FPS to loop through those dimensions...just dont loop through everything...just what you need.

I am using that method, to map out particle special effects, in (25*1)dimensions and (11*2)dimensions...and growing...with more options available, and yet, still low resources required.

Im, working on, and almost done with a particle engine.
And it runs fast on everyones computer!

If you can live without Dimensional arrays, TYPEs are right up your alley.

BTW, a 3 dimensioinal array will definetely cause CPU lag.
And is probably too large to mess with strings containing data groups, or long sets of data type numbers bundled into each xyz position in a 3d array. Thats going to also make it harder to program.
Too hard to play with the data are regroup it for more useful optimizations:

Use 3 separate 1* dimensions x[] y[] z[], this is because each dimension vertice contains individual values.
BounceSizeX[] BounceSizeY[] will be easier to read and understand, and manipulate, without the need to rummage through an entire 3d array.

This is exactly what a TYPE does if im not mistaking, it groups arrays and variables throughout a program.

The advantage to a DIM is auto-quick-dirty-byref resource....if it is single dimensional.


Bing ChatGpt is pretty smart :O