Hash Implementation

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Hash Implementation

Postby skydereign » Tue Jul 03, 2012 6:09 pm

Here is a small example of a hashed array data structure in gE. It uses linked lists for collision resolution (so there is a linked list implemented as well). I haven't fully tested it in gE, though I've been using it outside of gE. So you might find some problems. Not all of the hash functions are implemented, currently there is no hash_print, and hash_traverse doesn't work. But, it does get the general idea of a hash across.

There are some more advanced topics used in this, such as function pointers, so if anyone wants something explained just ask. I'll update this as I get more time. But for now, all the game logic does is allow you to add to and search the array. The actor with the text word to add is the text input actor. When you press enter it will try to add the name to the array. Pressing control-s will search the array for the text, and display a found message if it was found. In future I'll come up with a more interesting example.
Attachments
hash_example.zip
(92.5 KiB) Downloaded 177 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Hash Implementation

Postby AliceXIII » Thu Jul 05, 2012 8:40 pm

hmm.. i understand what your getting at it's interesting if you don't mind i might use it in my template engine? ;)

im thinking i could add it into my map editor that would allow you to create the lists for npcs, and other assorted things while in the map editor well it's not necessarily just a map editor as you can pinpoint npcs and enemies positions on the map. but anyways then possibly use it to be able to search through the array to pick specific npcs or enemies to make it easier to use the editor :D
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score

Re: Hash Implementation

Postby skydereign » Fri Jul 06, 2012 7:41 am

Go ahead. I posted this as an example and template for anyone who might need it. Hashing can be quite convenient. I haven't written a function to read and write it out though, which would be pretty handy. But, as I'm finishing up a general case serializing function, that isn't currently very high on my todo list.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Hash Implementation

Postby AliceXIII » Fri Jul 06, 2012 12:44 pm

well i've been messing around with reading and writing array maps so i could when i get the time after my visit to the SSA office
which will take awhile look into patching it up..

my editor and gameplay template could use something like this definetly i just never thought about implementing one myself i've read all about stuff like this though in my book(i found these 2 nifty books for 1$ each at my local goodwill a year ago 1's a very good primer to understanding C and the other is all about simple to advanced data structures in C++ which most of it is more advanced structures which is nice for me) so i understand a little of whats going on as i haven't read through all your code just kinda skimmed real fast :p

but for now i have a busy day ahead of myself at the SSA well unless i mail my form into them lol
"Taking a breath of fresh air."
User avatar
AliceXIII
 
Posts: 325
Joined: Fri Sep 17, 2010 2:36 am
Location: victoria, texas
Score: 37 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest