Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Pathing/layout questions.  (Read 808 times)

BoogieMan

  • Bay Watcher
  • Hi
    • View Profile
Pathing/layout questions.
« on: April 05, 2011, 10:34:51 pm »

To make the game run better with a large fortress and many inhabitants, what are good things to keep in mind when designing the layout?

And specifically I'd like to ask - is many possible routes from A to B better as far as less CPU usage, or is fewer so there are less paths to look for?

What exactly do things like high traffic vs. low traffic routing do, what's with the cost?

Logged
(╯°□°)╯︵ ┻━┻ BoogieMan, Forumscrub cancels tantrum: Seeking Dr. Pepper

bobhayes

  • Bay Watcher
    • View Profile
Re: Pathing/layout questions.
« Reply #1 on: April 05, 2011, 10:41:03 pm »

To make the game run better with a large fortress and many inhabitants, what are good things to keep in mind when designing the layout?

And specifically I'd like to ask - is many possible routes from A to B better as far as less CPU usage, or is fewer so there are less paths to look for?

What exactly do things like high traffic vs. low traffic routing do, what's with the cost?

Short distances. Limited routes. Avoid multiple paths to the same place. Put restricted traffic zones on all dead-end spaces (ie, workshops, storerooms) that you don't want dwarfs pathing through or that they can't path through. This encourages the pathfinding algorithm to not bother looking into those spaces when figuring a route.

Fewer routes is always better.

Basically the traffic cost routing basically means that the dwarf will count that square as its cost in squares when figuring out a route. IE, if you have high traffic = 1 and restricted traffic = 25, then a dwarf will route over 49 high traffic squares before routing over 2 restricted traffic squares.

But it's all very complicated and nobody really understands it fully, except (we hope) Toady.
Logged

Krelos

  • Bay Watcher
  • Was nauseated by the sun recently.
    • View Profile
Re: Pathing/layout questions.
« Reply #2 on: April 05, 2011, 11:55:20 pm »

Also, it's almost always better to use ramps than it is to use stairs. Have as few stairs as possible in places that your dwarves frequent.

Designing a fortress with ramps instead of stairs takes some getting used to, but once you do, everything works quite a bit better.
Logged
Quote from: Ravenplucker
Quote from: Aklyon
Quote from: smokingwreckage
In order to improve the universe's frame rate, we must all throw rocks into volcanoes and then do absolutely nothing, worldwide, for a week, to take pressure off pathfinding.
or maybe throw them into the large hadron collider to atom-smash them instead.
Not to mention to throw all available animals into tiny pits.

Jurph

  • Bay Watcher
  • Minister of Belt-fed Weaponry
    • View Profile
Re: Pathing/layout questions.
« Reply #3 on: April 06, 2011, 08:03:21 am »

Two of the best things you can do to reduce lag are to go vertical, and to make use of traffic zones and doors to game the pathfinding algorithm.

A vertical layout that works very well for me at reducing lag is a 15-tile diameter cylinder with a "plus"-shaped 5-tile stairway in the center.  Place workshops one tile back from the stairway, and put their input stockpiles (raw materials that the workshop will take in) adjacent to the stairway; put a two-tile-wide output pile around the other three sides of each workshop.  Then I designate the stairway and a short straight-line path to the center of each workshop on each floor as "high traffic", and designate a 1-tile border around that region as "low traffic" and a 1-tile border around that region as "restricted".  Move up or down a floor and repeat, stacking these 15-tile circles on top of each other and skipping one floor every 4 or 5 floors for future use.  Put workshops with similar functions together on the same floor to minimize hauling distances.  If you don't think this is more efficient, try to calculate the total hauling distance required to create, say, a dyed cloth bag... and then add up how many of those hauling jobs are performed by skilled dwarves vs. unskilled haulers (a skilled dwarf has to haul the item from the input stockpile to his workshop for each skilled task).  Reducing total path distance reduces the number of iterations of the pathfinding algorithm that each dwarf has to go through.

As for gaming the algorithm, I've already described my traffic zone layout.  In addition to aggressive zoning, anywhere you decide to dig long horizontal paths, start with a one-tile doorway and place a long restricted zone in the tunnel.  Your miners will still path to the exploratory mining jobs, and your haulers will still go there to recover gems, but most pathing checks will ignore it.  If you're not actively working the branch, forbid the door and the pathing algorithm will ignore that entire region.

Logged
Dreambrother has my original hammer-shaped Great Hall.  Towerweak has taken the idea to the next level.

BoogieMan

  • Bay Watcher
  • Hi
    • View Profile
Re: Pathing/layout questions.
« Reply #4 on: April 06, 2011, 08:52:51 am »

Thanks for the tips, I'll definitely put them to good use.
Logged
(╯°□°)╯︵ ┻━┻ BoogieMan, Forumscrub cancels tantrum: Seeking Dr. Pepper