hashtable limits?

W!†A_cRaft

Ultra Cool Member
Reaction score
28
Okay since im making sort of a weird map i will try to clue you guys in on what I need:

a unit to unit relation that stores certain data:

unit 1 towards unit 2 has data value of lets say 10
unit 1 towards unit 3 has data value of lets say 15
unit 2 towards unit 3 has data value of lets say 30
unit 3 towards unit 2 has data value of lets say 105
unit 3 towards unit 1 has data value of lets say 5

if you get the point, i need to make relations between units in my map and store data to it. I think the hashtable would be a rather easy way to do it.

PROBLEM:
I don't know if a hashtable can handle it, or if it would make the game laggy. Due to enormus number of relations that are kept as data stored in the hashtable itself it might cause lag, or possible even clogging the table? It would be better if i could dispose of the data when the unit decays away, since i would no longer need it.... But I cant do that with hashtables.

What are the limits with tables? Is there a way to dispose of the data that i no longer need inside the table?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
A single hashtable can store unlimited amounts of data as far as i know. however, you are limited to 256 hashtables a map. (thats not such a bad limitation because seriously, no one will ever need this many)

depending on what kind of data you want to store and how many units are involved it might become laggy. this is because of all the ram taken to save the values.

if you are going to store big amounts of data like unitgroups and such for hundreds of units it can really become laggy the way memory leaks would do. however, saving a couple of hundred numbers within 0 - 255 wouldnt really make much of a difference for todays computers.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
Well im counting like this:

i will have like 200ish units in a map, so the total relations would go as high as oblivion...

just take a pattern of 5 units:
unit 1 relates to units 2,3,4,5
unit 2 relates to units 1,3,4,5
unit 3 relates to units 1,2,4,5
unit 4 relates to units 1,2,3,5
unit 5 relates to units 1,2,3,4

that makes a total of 4 + 4 + 4 + 4 + 4 relations = 20 relations for 5 units. using the same principal, 200 units would in return have: 39800 relations

39800 relations x Number of Data Stored (which should be at least like 5-10) would make an average of:

278600 Hashtable entries in total I think this is a little too much don't you? It would be really epic if I could clear the data once I do not need it anymore thus freeing up space for other data, specially since there will never be a need to keep more then 20 units stored at same time.


EDIT: Also is there really any benefit in spreading the data over multiple hash tables, or can i just keep using 1?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>It would be really epic if I could clear the data once I do not need it anymore thus freeing up space for other data, specially since there will never be a need to keep more then 20 units stored at same time.

Use Clear Parent Hashtable + Clear Child Hashtable?

>the limit is 123 not? Oo
nope it's 256

Off-topic: wasn't the limit of gamecache also 256?
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
123 doesnt make any sense. 128 would be more fitting as a power of 2.
the indexnumber of hashtables can varry from 0 - 255, thats exactly 1 byte. this limitation is used to save memory. if you could create more then 256 hashtables they would need doubled ram to store their corresponding ID.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top