java logic errors…
Thursday, July 24th, 2008Recently, I was working on a project to reproduce processing.org’s spore2 program. During the course of developing the program I kept running into a logic error which caused my simulation to work but not achieve the desired effects. The problem with tracking this down is that my program was keeping track of thousands of bits of data which made debugging almost impossible. On a large scale the program kept bottlenecking instead of creating the cool lava lamp flow of little creatures.
I eventually solved this issue by tracking just one creature and found that instead of making a downward circular path like was expected from the rules it kept always going in a downward left position. This gave me the idea that maybe just one rule was being executed. This was exactly the case as it turns out I can not compare Color objects directly in Java. Needed to use the .equals() function. Once I translated my == and != to .equals() and ! .equals() it worked prefectly.
Sometimes it seems that targeted information is much better for debugging then lots of information.