And the big project has started![]()
We have to created a sort of inventory system for an RPG, honestly, it sounds more fun than it is....
Okay: my current big problem : I have to store items in a backpack, it has to be possible to retrieve both the heaviest and lightest item in O(1) (so independent of the amount of items), adding and removing has to happen in at least O(log(n)) (typically a binary search is used to achieve this). The problem: in order to get the heaviest and lightest item in constant time I need to sort the items by weight, but weight isn't a unique number, I need a unique number to sort the items in an ordered way. I was thinking of using a number that is a combination of the weight (as a whole number ) and the HashCode(as the decimals), but not even the HashCode is unique![]()
Then there are some demands about memory management, I have no idea how to this. The game has Dukats as a currency, they're actual objects. The amount of memory needed to handle Dukats in every game has to be the same.
I was thinking of just remembering the amount of dukats stored, with references to the static variables in Dukats (they have a constant weight and value), but interpreting the assignment it seems like they want links to the actual objects (the dukats). Any ideas ?
Similarly, Dukats can be stored in a Purse, the amount of memory needed for storing the Dukats has to be constant for every Purse. Any ideas ?
There still some details about heroes and monsters and potions that haven't been revealed yet, so these probably aren't my last questions. For what is supposedly a 30hour project it's friggin' huge though !![]()
Bookmarks