Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Optimization thought - segmented search  (Read 1107 times)

Fieari

  • Bay Watcher
    • View Profile
Optimization thought - segmented search
« on: June 10, 2008, 09:00:00 pm »

Just a random thought that came into my head that I wanted to share.

Now, we all know that having massive amounts of inert stone lying around causes major slowdowns.  My understanding for the REASON for this is that every tick, the game polls each of them to see if they are in need of hauling or some other task. I may be wrong, of course.

Now, given that normally, most stones DON'T need to be hauled, it might make sense to have the game engine group inanimate objects like stones in segments.  Each segment has a flag saying "something in my group wants to do something".  The engine, instead of polling all the stones, polls the segments instead.  If the segments get too big, they can be subsegmented, into a tree.

Would this help at all?

Logged

Toady One

  • The Great
    • View Profile
    • http://www.bay12games.com
Re: Optimization thought - segmented search
« Reply #1 on: June 11, 2008, 03:39:00 am »

The game isn't polling every item every tick.  I think it's checking a counter on every fifthieth item to see if its last check failed, doing another check if the counter runs out, and then setting an ever-larger timer if the check fails again.  

Additional optimizations would be good of course, though I don't remember what the last profiling results said about the storage checks -- I don't think they were a big such a deal though.  I imagine how you group the items would have a lot to do with how effective something like segments would work.

Logged
The Toad, a Natural Resource:  Preserve yours today!