Posted by jgiors on 2006-05-24
In the games industry, it is common practice to use hashes of strings as identifiers for objects. String hash identifiers are a useful compromise between the differences in human and computer "comprehension" — humans understand and remember string identifiers better than arbitrary numeric quantities, while computers operate most effectively with numbers.
CRC is one of the most common hashes, but there are other options, such as FNV. I prefer FNV because it is even simpler than CRC and doesn't require a lookup table as the typical CRC implementation does.
The advantages of using hashes are:
- Hash values are always the same data size no matter how long a string is.
- A primitive data type (typically a 32-bit unsigned int) can hold the hash.
- Equality/inequality comparison is fast.
- Less memory space is required than for strings.
- They make good indices into hash tables.
Like all techniques, string hash identifiers have disadvantages. Because a hash is just an arbitrary number with no intrinsic meaning, the only way to find the string a hash originated from is to look it up in a hash-to-string table. And that means you have to create a hash-to-string table if you want "reversibility". If the string was hashed without storing it in a lookup table, it may not be possible to determine the original string (though putting a conditional breakpoint in the code often works).
It is also necessary to be on the lookout for hash collisions (two different strings which hash to the same value). They are reasonably rare, but the data sets of many games are getting large enough that a few collisions will occur during the course of a project. Collisions can lead to obscure bugs which are hard to track down. Often, this can be caught in debug builds by checking for duplicate strings when inserting hashes into lookup tables. When a problematic collision is found, it can be fixed by renaming one of the items.
Even so, the advantages of string hash identifiers typically outweigh the disadvantages. I have worked on several projects that use this technique, and the consensus is that it has been worthwhile.
I'll be writing more on this topic soon…
Posted in Game programming, Programming | 1 Comment »
Posted by jgiors on 2006-05-22
I know…over a week after E3 ends is a little late to be writing about it…
The exciting part
Mercenaries 2 was being shown to the press at our Pandemic (and Bioware) booth. I'm always excited when the project I'm working on is at the show. It's nice to meet people who are interested in what you're doing, especially after you've put in so much effort getting your game ready for the show.
Impression
My impression (which is shared by many attendees I spoke with) is that there wasn't anything that "blew me away". Sure, there were some especially nice looking games/trailers (e.g., Crysis, MGS4, Assassin's Creed) and some innovations (like the Wii controller), but there wasn't anything that seemed stand-out amazing.
My theory is that games have matured to the point where everyone is pretty much state of the art. So, most products have great graphics, fluid gameplay, outstanding SFX, etc. The people that are ahead of everyone else aren't that far ahead any more–there just isn't enough headroom left to make a giant leap.
Celebrity sighting
My celebrity sighting of the show…
I was standing near a kiosk when I notice security guards scurrying about. Then, I see some guy walking and a herd of people following him. I think to myself "He looks familiar…but who is he? Warren Spector? Why would so many people be tailing Warren?"
Then he walks by, just a few feet from me. I spot his nametag:
Steven Spielberg.
So, that explained the crowd (and the security). A pretty cool celebrity sighting in my book. Yeah, he was probably there to promote a game, but it was neat to spot him on the show floor.
Posted in Uncategorized | Leave a Comment »
Posted by jgiors on 2006-05-05
I've finally decided to make the Mozilla Firefox switch, leaving Internet Explorer in the dust.
Don't always trust your first impression
I had heard about Mozilla Firefox some time ago, but I didn't really take it too seriously. After all, IE was pre-installed and worked well enough…Switching to Netscape Navigator seemed more trouble than it was worth. And, Firefox is just a spin-off of Navigator, right? How much different could it really be?
Read the rest of this entry »
Posted in Applications, Open Source | Leave a Comment »