Added option to use 4GB to skip hash searches#3
Added option to use 4GB to skip hash searches#3klutt wants to merge 2 commits intofogleman:masterfrom
Conversation
|
This doesn't work. 4 billion entries are required in the complete table: 256_256_256*256=4.294.967.296 With 4 bytes per entry that table uses 16GB. Use For a data structure that is both compact and fast, have a look at a map that uses a trie instead of hashtable for its keys. |
|
You are completely right. Thank you. Maybe I'll change that tomorrow. Some memory could be saved however. I see three ways of doing this. Firstly, the four tiles in the middle will not be used. This could bring it Secondly, two robots can never use the same tile. This brings us down to Thirdly, and here I'm not 100% sure but almost, the positions 0x00010203, Of course this will require some function to translate the position, but On Mon, Sep 2, 2013 at 9:22 PM, Michael Henke notifications@github.comwrote:
|
|
While the first two of your ideas to reduce memory are known and can be used as-is, the third idea is good too, but you can't swap the positions of all 4 robots, only those of the 3 non-active robots. This is already implemented in function Btw. Michael Fogleman published a presentation about the algorithm used in his program: https://speakerdeck.com/fogleman/ricochet-robots-solver-algorithms My program uses nearly the same algorithm - it's the fastest and least memory-consuming that I currently know. However, I don't like the hashtable so I implemented the map using a trie (TieMapByte.java here: https://github.com/smack42/DriftingDroids) Have fun! |
A friend of mine told me that this were the proper way to do this.