Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Siege slowdown  (Read 1491 times)

Steel

  • Escaped Lunatic
    • View Profile
Siege slowdown
« on: December 17, 2008, 10:55:05 am »

I like to build fortresses which have a means to totally shut out invading armies, by having a moat or drawbridge system of some sort.

When I shut out the enemies there is a massive slowdown, caused, I assume, by the enemies constantly attempting to pathfind a route into the fortress every step.  Is it possible to make it so that only squad leaders attempt to pathfind in this situation or that enemies get near the fort and then only periodically pathfind or something?
Logged

Granite26

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #1 on: December 17, 2008, 11:00:48 am »

I believe that the pathing algorithm knows that it can't get in, so you're probably wrong about the cause.

Could be that the slow down is caused by 40 goblins wondering what to do now.

Dakk

  • Bay Watcher
  • BLARAGLGLGL!
    • View Profile
Re: Siege slowdown
« Reply #2 on: December 17, 2008, 11:01:28 am »

Don't think these things can be found in the raws, so i dunno if you can do anything about it  :-X

You can try one of the little tricks in the wiki to increase DF's performance, like the partial print thing.
Go to your DF folder, then data/init/init.txt, find the [PARTIAL_PRINT:NO:2] line, and change it to [PARTIAL_PRINT:YES:2].

Thi can greatly increase DF's performance and it doesn't affect gameplay at all.

Logged
Code: [Select]
    ︠     ︡
 ノ          ﺍ
ლ(ಠ益ಠლ)  ┻━┻

Table flipping, singed style.

Steel

  • Escaped Lunatic
    • View Profile
Re: Siege slowdown
« Reply #3 on: December 17, 2008, 11:17:14 am »

I believe that the pathing algorithm knows that it can't get in, so you're probably wrong about the cause.

Could be that the slow down is caused by 40 goblins wondering what to do now.

Well if they thought a bit less hard about what to do then perhaps that could solve this then :p

I was fairly sure that was what the problem was, as at the flip of a switch I could go from fast game + goblins moving   to   1/3 speed + gobilns stationary   and then back again when I lowered the bridge.  Oh well, I suppose if they bring siege engines then this'll be less of a problem...
Logged

Mephansteras

  • Bay Watcher
  • Forger of Civilizations
    • View Profile
Re: Siege slowdown
« Reply #4 on: December 17, 2008, 01:36:15 pm »

The other possibility is that you have dwarves that feel some insane need to go out where the goblins are. I know that if I have items marked for trade that are inaccessible that game goes down to about 2-3 fps as the dwarves spam me with messages about how they can't get it.
Logged
Civilization Forge Mod v2.80: Adding in new races, equipment, animals, plants, metals, etc. Now with Alchemy and Libraries! Variety to spice up DF! (For DF 0.34.10)
Come play Mafia with us!
"Let us maintain our chill composure." - Toady One

texmith

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #5 on: December 17, 2008, 04:17:53 pm »

I believe that the pathing algorithm knows that it can't get in, so you're probably wrong about the cause.
How would the pathing algorithm know they can't get in without trying to find a way in? If there is no path then the algorithm has to exhaust all possibilities.. which can take much longer than the the situation the algorithm is optimised for (finding the shortest path as fast as possible).

Perhaps if there's no path, then it gives up till a door opens or something.. I don't think this is the case though.
Logged

Fieari

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #6 on: December 17, 2008, 04:32:56 pm »

I believe that the pathing algorithm knows that it can't get in, so you're probably wrong about the cause.
How would the pathing algorithm know they can't get in without trying to find a way in? If there is no path then the algorithm has to exhaust all possibilities.. which can take much longer than the the situation the algorithm is optimised for (finding the shortest path as fast as possible).

Perhaps if there's no path, then it gives up till a door opens or something.. I don't think this is the case though.

If it was running pure A*, then yes, you'd be right.  But Toady runs a combination of A* and a floodfill connectivity test.  Areas being disconnected is so common that he has a couple bits in the map structure dedicated to determining whether two areas are connected (by walking) or not.
Logged

texmith

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #7 on: December 17, 2008, 04:43:26 pm »

ah ok. I guess they're hammering the floodfill trying to find a dwarf to attack till they exhaust all posiibilities then.
Logged

irmo

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #8 on: December 17, 2008, 05:06:14 pm »

ah ok. I guess they're hammering the floodfill trying to find a dwarf to attack till they exhaust all posiibilities then.

No, the floodfill runs once every time the map structure changes. It tags each square to indicate zones of connectivity (if every walkable square is connected then they're all zone 1, if there's one room with a locked door then the interior of that becomes zone 2...). Then the pathing code checks the source and destination, and if they aren't in the same zone, it returns "no path" and doesn't bother running A*.

Finding a dwarf to attack just requires checking every dwarf, not floodfilling the map.

I suspect what's happening is that the gobs are having to cycle through AI states to find something they can do. Dwarves seem to have some kind of timed idle state (notice the time delay between a job becoming available and an idle dwarf picking it up)--does invader logic not have this? Or is it just that there are so many of them all going idle (and thus, I assume, all having their idle states expire) at the same time?
Logged

LegacyCWAL

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #9 on: December 17, 2008, 05:38:02 pm »

Of course, there's always the solution of replacing the moats and bridges with 3x50 corridors full of weapon traps.  Unless of course 1500 ☼steel large serrated discs☼ is too cheesy for your taste ;)
Logged
HIDE THE WOMEN AND DROWN THE CHILDREN, THE BARON HAS ARRIVED.

texmith

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #10 on: December 18, 2008, 05:56:21 pm »

No, the floodfill runs once every time the map structure changes. It tags each square to indicate zones of connectivity (if every walkable square is connected then they're all zone 1, if there's one room with a locked door then the interior of that becomes zone 2...). Then the pathing code checks the source and destination, and if they aren't in the same zone, it returns "no path" and doesn't bother running A*.
ok, that makes sense. its definetely more than a 'couple of bits' then.
Logged

Creamcorn

  • Bay Watcher
  • [FANCIFUL]
    • View Profile
Re: Siege slowdown
« Reply #11 on: December 18, 2008, 06:23:58 pm »

I like to build fortresses which have a means to totally shut out invading armies, by having a moat or drawbridge system of some sort.

When I shut out the enemies there is a massive slowdown, caused, I assume, by the enemies constantly attempting to pathfind a route into the fortress every step.  Is it possible to make it so that only squad leaders attempt to pathfind in this situation or that enemies get near the fort and then only periodically pathfind or something?

This could be solved by squad leaders doing the path finding, and the squad members just do the following. Course it could already be like this.
Logged
"OH NO! That carp is gulping at me menacingly, even though it cannot really threaten me from here on land!  I KNOW! I'll dodge into the water, where I'll be safe!"

LegacyCWAL

  • Bay Watcher
    • View Profile
Re: Siege slowdown
« Reply #12 on: December 18, 2008, 07:10:41 pm »

As far as I can tell, it's a little of both.  I may be wrong, but what it looks like is that the squad leader does the pathfinding, and if he can get there, he starts on the way as the rest of the squad does their own pathfinding to find a spot within 2 tiles of the eventual destination that they can get to.  Pets and children seem to work the same way, following their owner or parent (respectively) the way soldiers follow a squad leader, which is kinda humorous.

...well, humorous until you station a squad somewhere and wind up with units spread across the entire screen :-\
Logged
HIDE THE WOMEN AND DROWN THE CHILDREN, THE BARON HAS ARRIVED.

profit

  • Bay Watcher
  • Finely Crafted Engravings... Or it didn't happen.
    • View Profile
Re: Siege slowdown
« Reply #13 on: December 19, 2008, 11:14:34 pm »

Course the pathing AI simulation engine could just be recoded to use multiple proccessors and the game would stop lagging so bad for most of us.

(about 55% have multicore processors so most is accurate)
Logged
Mods and the best utilities for dwarf fortress
Community Mods and utilities thread.