Darwinbots Forum
Code center => Suggestions => Topic started by: Testlund on June 16, 2006, 12:38:12 AM
-
Unfortunately it only takes a few bots that shoots continusly to slow down the program to a freeze. I was wondering if there was an option to disable the shots from showing on screen it might speed up the program some?
-
It wouldn't help that much. Most of it is collision detection. Even though 2.42.6 now has a fast shot collision detection routine that is very accurate, it still has to do a bunch of work. Shots are almost as costly as bots. They have quite a bit of state and you need to do collision detection for each and every one for each and every bot every cycle. A few thousand shots slows things down considerably...
I have some ideas about how to improve this that I plan to try in 2.42.7. I will also be doing some profiling. Expect the next release to be faster.
-
I studied this problem for a few months and the solution I found most economical (meaning speadup vs. difficulty programming) would be a hierarchial grid. There aren't alot of references to it online, but basically you just construct a series of grids with different resolutions.
X, 2X, 4X, 8X, etc.
Place bots in whichever grid level is the smallest that can still hold it (or there are other methods for placement). For shots you'd only need to check against adjacent grids, which brings the problem down from n^2 (or kn where k is the number of shots and n is the number of bots) to ck (where c is a constant).