Hashing Project - MMORPG
Launched November 2023
Purpose:To practice and demonstrate proficiency in creating, manipulating and utilizing hash tables and concepts around hashing using Java programming
Knowledge Goals: Hash Tables, Hashing, Collision Resolution (Linear Probing, Double Hashing, Separate Chaining)
Summary
The purpose of this project was to create a data storage model for a massive multiplayer online roleplaying game (MMORPG), a game where players sign on and play with other players around the world in a virtual setting. We wanted to emulate the records of this MMORPG. Each record contains data about a player. So whenever someone joins the game, an account is created and assigned a unique record number. This number is used to locate a Character record.
We indexed Character objects using a hash function, handling collisions and searching using separate chaining, although we also considered quadratic probing and double hashing.
Because the game is so popular, this MMORPG rarely gets a request to delete an account. In this scenario, the number of Characters increased to the thousands and the developers realized they could not keep the entire database in memory so they chose to use an indexing scheme. In this scheme, the Character's name and record number would be stored in memory, but their entire record would only be loaded if they were logged into the game.
We implemented this database system using a list and a Hashed Dictionary. The list stored each player as an instance of the Character class. Each time a new player account is created, it is added to the end of the list so that its position is also its record number. If an account is deleted, its position in the list is set to null so the positions of the other entries do not change. For the dictionary, each key is a Character's name, and each value is a record number (list position) to point to the Character's details in the list. The index is hashed. We added two names that cause collision in order to demonstrate collision resolution with separate chaining. We chose to model the list using Java's ArrayList.
UML Class Diagram

Java Implementation
Interfaces
- DictionaryInterfaceInterface for the hashed dictionary
- add
- remove
- getValue
- contains
- getKeyIterator
- getValueIterator
- isEmpty
- getSize
- clear
-
CharacterDatabaseInterface
Character Database interface
- addCharacter(name, height, weight, moralAlign)
- removeCharacter
- getCharacter
- getHashTable
- printList
Classes
-
Character
Character class that represents a player
- Getter and setter methods for name, height, and weight
- Moral alignment and health have a getter but not a setter as that is done through the methods below
- heal
- injure
- change
- toString
-
HashDictionary
Hashed Dictionary implementation using separate chaining for collisions
- displayHashTable
- getHashIndex
- getSecondHashIndex (only for DoubleHashing)
- probe
- locate
- enlargeHashTable
- isHashTableTooFull
- getNextPrime
- isPrime
- checkIntegrity
- checkCapacity
- checkSize
- KeyIterator class
- ValueIterator class
- TableEntry class
- CharacterDatabase Contains the List and HashedDictionary, implements the interface
- Main Runs the program
Output
We tested our MMORPG by doing the following:
- Created a new CharacterDatabase instance using its interface.
- Added a character with the name "FB" (and other attributes)
- Added a character with the name "Ea"
- Added a character with the name "Daegon"
- Added a character with the name "Gandalf" and moral alignment of 1.0
- Cleanly and clearly printed the Hash Table to verify characters were put in. Verified that the hash indices of FB and Ea were the same (collision!) and verified it was handled correctly.
- Removed the character Daegon.
- Printed the Hash Table to verify Daegon was removed.
- Printed the list and verified Daegon's place was replaced with null.
- Retrieved the character Gandalf and printed his character sheet (toString)
- Shifted Gandalf's alignment
- Used the injure method on Gandalf
- Used the heal method on Gandalf
- Printed Gandalf's Character Sheet again (toString) and verify everything changed.
Documentation
Used javadoc comments on functions to explain what they do. Where there is an interface, used @inheritDoc.
Thanks for checking out my project!
Thank you!
Thanks for checking out my work! If you've got a project or job you think suits me, contact me here, by email, or on LinkedIn.
Contact Me
Thanks for dropping by!
Back to top