Author Topic: Shots that don't decay is a nice feature.  (Read 2473 times)

Offline Testlund

  • Bot God
  • *****
  • Posts: 1574
    • View Profile
Shots that don't decay is a nice feature.
« 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?
The internet is corrupt and controlled by criminally minded people.

Offline EricL

  • Administrator
  • Bot God
  • *****
  • Posts: 2266
    • View Profile
Shots that don't decay is a nice feature.
« Reply #1 on: June 16, 2006, 01:11:43 AM »
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.
Many beers....

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Shots that don't decay is a nice feature.
« Reply #2 on: June 16, 2006, 03:41:39 PM »
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).