• Create Account

Auto-tile system - algorithm to auto-generate hash table

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

#1thescholar  Members

115
Like
0Likes
Like

Posted 30 October 2012 - 07:21 PM

Recently I've programmed an auto-tile system for my game engine, which use 47 possible tile combinations. The technique is to check each of the eight adjacent cells ariound the center tile which are represented as a power of two, like so:

128, 001, 002
064, 000, 004
032, 016, 008

This method work great so far for me, the autotile system is assembled with the proper edge tiles automatically in real-time.

The real issue was to write the hash table of keys and values, which was EXTREMELY time-consuming. It took me nearly 6 hours to enter the values and make sure they're exact. See my hash table below.

My question: is there a way to auto-generate the keys/values of that hash table with an algorithm so that next time I don't have to enter it manually? I feel it's very important to ask because I will probably have to do it again for something else similar.

Edited by thescholar, 30 October 2012 - 07:22 PM.

#2turch  Members

590
Like
1Likes
Like

Posted 31 October 2012 - 06:11 AM

Its kind of hard to tell what's going on without more description....

What does the hash table store? Each tile's value? If so, I can only assume the tiles are in some sort of array to begin with, so you would be able to

	 i = 0
j = 0
for each row
for each column
hash_table.Add( ((i * numCols) + j), tile_array[i][j])
j++
i++


And since your keys are 0-255 with no gaps, why do you need a hash table? A 1-d array would serve you just as well...

Edit: from reading your previous question, I take it you are trying to generate one of 47 unique ids based on a 3x3 pattern?

Edited by turch, 31 October 2012 - 07:15 AM.

#3thescholar  Members

115
Like
0Likes
Like

Posted 31 October 2012 - 02:22 PM

Yes, I would like to create an auto-tile system by filling it with patterns. for example, the larger the field gets, larger tile patterns are inserted (rather than always repeating 1x1 pattern.

So rather than using constantly 32x32 tiles for the middle part of the autotile, I would like to use other patterns like 2x2, 3x3, etc.

But I know how complex it is, so I try to ask my questions at the most basic level as possible.

And since your keys are 0-255 with no gaps, why do you need a hash table? A 1-d array would serve you just as well...

It's because the keys are the bit signature for all tile possibilities, so the same tile id can be used for many type of connections depending of the adjacent tiles around the middle tile.

Edited by thescholar, 31 October 2012 - 02:30 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.