Welcome fellow Overseers!
Once again one of my forts fell to the worst nemesis known to overseerkind: FPS death. It was a 2x2 emark and died after only 6 years. I'm obviously doing something horribly wrong. Ask and the holy collection of slabs (DF Wiki) shall provide! Let's talk about
pathfinding in DF, specifically A*.
I found DF after watching a Youtube LP from
Leigh "Deman" Smith a while back and I analyzed his fort design with the nice pathfinding tool on github linked on the DF Wiki:
http://qiao.github.io/PathFinding.js/visual/As it turns out the algorithm really doesn't like his long hallways with large rooms on each side. (The more teal/green you see the longer it takes the algorithm to find a path, slowing down your game.) Imagine a dwarf is at the dark green point and he wants to haul a rock from the red spot:
<- clicky for full size
A* basically flood-fills all the rooms before it can find a path: It takes 16ms and 1089 calculations. Oh dear!
Now we are trying to improve the room layout a bit:
We are down to 9ms and 350 calculations. That's one hell of an improvement for punching a couple of additional holes into the walls!
Further improvement:
We are now at 4ms and 220 calculation. Oi, 4 times as fast and we are saving 10 tiles of hauling a heavy stone!
The "ideal" solution: Knock out all the walls:
4ms, 176 calculations. Our second best result is very close.
I think we don't even have to discuss how the A* path would look for a favorite of mine, the Nautikus Blossom from Quickfort:
Yup, you are paying a price for prettiness, although it is not quite as bad as I feared:
So, how would a more optimized design look like? Probably like this:
4 12x12 workshop areas around a central staircase, framed by bedrooms and offices for your dwarfs with additional staircases if necessary.
I have no idea how DF calculates a path to staircases and other z-levels. That's a bit of a blank spot and I hope you can shed some light on this. Is it better to move bedrooms to their own z-level? More staircases? Do you have a prettier design in mind? My design really could use some help in the aesthetics department...