Scuwr / Snitch-Visualizer

A mod to render snitches in civcraft
MIT License
5 stars 8 forks source link

Snitch Auto-update detection fails for complex snitch inventories #10

Open ProgrammerDan opened 9 years ago

ProgrammerDan commented 9 years ago

The snitch name eating bug is directly related to auto-update detection failing. It may have to do with the ordering of the vector used to store snitches, or the sort function used. I will be investigating. Seeing that a good, natural, non-overlapping compare function is in use, leveraging TreeSet could avoid the need to continually resort on new snitch add, and lead to O(ln) direct indexing of snitches. Might be simpler than the memory datastructure I was working on.

I'll notate progress here.

ProgrammerDan commented 9 years ago

Treeset won't work.

ProgrammerDan commented 9 years ago

Should expand on that last comment briefly; Treeset is great for natural ordered items (like Snitches) that extend comparable, assuming you don't need (1) direct index access and (2) don't need items in a non-linear pattern around the "found" item. Unfortunately, this problem space involves both. In some cases direct index access is desired, and in other cases "nearness" is desired.

The current function is a very clever O(ln) approach that will halt on first match, but which snitch matches is somewhat arbitrary in case of overlap. My thinking is:

(1) Autoupdate should find and update all the snitches your character is overlapping.

(2) The datastructure we use should allow for simple interaction: structure.get(x,y,z) and structure.getNear(x,y,z,range) and must be no worse than O(ln) in performance, ideally O(c) -- constant time.

So, the rub is ... I'm not aware of any structures that do this as part of the base Java libraries. I do however know how to build one, so I am -- https://github.com/ProgrammerDan/dynamic-spatial-map -- but this will take a little while, as with any new datastructures index testing is a pain. This algorithm will be constant time insertions and searches for maps like Civcraft where the bounds are known; and is O(ln) in the worst case. It achieves this via memory utilization; so large networks like MN's 10k snitches will gracefully function with this datastructure, but will require more memory than if stored in a Vector as current. I'll do testing to make sure the impact is kept constrained.

staygroovy57 commented 9 years ago

One thing I'd like to add... today I noticed that my snitches weren't displaying anymore. Not sure when it happened but the plug-in looks like it turned itself off?

I had to force a snitch update manually, then things are fine again. This is for a 31-page set of snitches.

ProgrammerDan commented 9 years ago

If you are comfortable doing so, could you send me the log file from that session? Or at the very least, the startup portion of the log? If posting it publicly doesn't thrill, upload it and send me a reddit PM. Sounds like your snitch list got trounced somehow, but I've never experienced this before so I'd love to see if any errors made it to the console. On May 27, 2015 12:54 PM, "staygroovy57" notifications@github.com wrote:

One thing I'd like to add... today I noticed that my snitches weren't displaying. I had to force a snitch update, then things are fine again. This is for a 31-page set of snitches.

— Reply to this email directly or view it on GitHub https://github.com/Scuwr/Snitch-Visualizer/issues/10#issuecomment-105992049 .

ProgrammerDan commented 9 years ago

@staygroovy57 Not sure if you saw my prior message, I'd love to diagnose the issue but can't without some kind of trace or log. Can you open a new issue describing the problem, and either PM me on reddit (/u/programmerdan55) or link to the client log of the session where you experienced the issue?