Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Pathfinding (and other FPS improvement)  (Read 1344 times)

ImagoDeo

  • Bay Watcher
  • [NOT_THINK:UNTHINKABLE]
    • View Profile
Pathfinding (and other FPS improvement)
« on: September 19, 2014, 08:29:33 am »

While configuring my d_init.txt from the 40.13 release, I realized I'd never really bothered to change the numbers with the pathfinding tool. On top of that, I don't know what limits it has.

Is it possible to set a pathing setting to 0 so that dwarves will always follow that route exactly? Or will the pathfinding system find that confusing somehow?

Beyond pathfinding, what do you all do to help with framerate?

I already use minecart quantum stockpiles, smash all useless items and garbage, and try to keep animal populations down. My computer is barely good enough to run Minecraft so long as I keep all the graphical settings on minimum, so DF's FPS kills me sometimes too when I get to the lategame.
Logged
What would it be like to live in a world that was copy/pasted? Would we even notice? If not, how many times have we switched celestial harddrives or whatever?

Tacomagic

  • Bay Watcher
  • Proud Sir Wordy McWordiness at your service.
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #1 on: September 19, 2014, 08:55:48 am »

I use fixster to sterilize magma crabs.  Keeping their populations under control is a big priority since they don't path off the map properly.

Command for that is:

$fixster ster only:MAGMA_CRAB

Alternately, take away their magma/heat immunity in the raws.  That's actually much more effective, but it means you'll never enjoy magma crab roast.
« Last Edit: September 19, 2014, 09:21:46 am by Tacomagic »
Logged

Trouserman

  • Bay Watcher
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #2 on: September 19, 2014, 11:11:38 am »

If you set a pathing cost to 0, that violates an assumption made by the algorithm to guarantee finding a shortest path. If used sparingly, it will probably still give you paths that are close enough to what you want, but I doubt it will improve your FPS.
Logged

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #3 on: September 19, 2014, 12:19:51 pm »

If you set the pathing cost to zero, not much else -really- happens, on its own.  Pathing costs are a combination of three items.  Let's say you start on 1,1 and you want to go to 2,5.  That's a difference of 5 blocks, as you'd need to go 4 to the right, and 1 up.  When you start pathfinding, then it factors in the distance from your destination, the distance from your origin, and the arbitrary pathing cost.  In this case, if you start at 1,1 then the point 0,1 would be 6 distance from your destination, so it's 'less desirable'.  Being 1 distance from the origin also makes it less desirable.  The arbitrary additional cost set by pathing options ALSO makes it less desirable.  HOWEVER, the point 1,2 is 4 away from the origin, making it MORE desirable, while the distance from origin and the pathing options are the same.  This way, the dwarf realizes "If I go to the right, my distance from 2,5 decreases by 1" and movement occurs.

So, in effect, every tile has a "cost to move into" and that's distance_from_origin + distance_from_target + pathing.  If the traffic option sets the pathing to 0, then you get totally non-weighted pathing.

The result of this?  If you have two paths that both arrive at the same destination over the same number of tiles, but one is arbitrarily costing more, then the dwarf will take the arbitrarily less costly path.  If the path has zero arbitrary cost, then it doesn't become the automatic path, it just becomes much more desirable.

TL;DR - Pathfinding settings only add arbitrary weight for or against taking a path, nothing magical.

If you want to use pathfinding to streamline movement, then put unused areas in Restriction, such as exhausted mine tunnels, or better yet wall them off.  Put infrequent areas as Low, such as the entire surface, where only your woodcutter goes.  Put direct hallways as High, since you WANT the dwarves to path through hallways.  Put workshop nooks and stockpiles as Normal.

Do NOT put frequently used stockpiles or workshops as Low or Restricted, because dwarves trying to go there will pathfind down every other hallway that costs less, until finally settling on the direct path.  If the entrance to your dining hall is 25 cost, and the hallways are 1, then dwarves going to the dining hall will reach the doorway, then look 25 tiles down every hallway before deciding to enter the door.  If you leave it as Normal 2 cost, then dwarves will only path 2 tiles down the hallway.

SOME OTHER TIPS:
Pathing is a 'flood' operation, so imagine you have a large- well, you're a dwarf fortress player, so of course you have a large cistern of water suspended above your fortress for no good reason.  Anyways, it bursts, and water floods out from one point, into every adjacent tile.  If it bursts on one end of a hallway, and the drain is at the far end, then the water will flow through every room along the hallway until it hits the drain.  If you make traffic Restricted, then you're just adding sandbags on those tiles, so the water has to raise further before it crosses over the taller barrier, and it has to flood MORE of your fortress.

Now imagine you're trying to conserve water.  If the rooms on either side of the hallway are small, then only a little water gets in.  If you've got mine shafts and dining halls on either side of the hallway, then it takes a lot of water to fill them up.  When possible, make your hallway rooms small, and your large rooms at ends.  HOWEVER this can very easily put your dining hall at the back of the fort and your large training zone at the front, so your soldiers end up walking all the way across your fort to eat.  It's important to balance 'efficient pathfinding' against 'efficient fortress'.  Pathing aid will increase your frames per second, but fortress aid will increase your work per frame.  You may get lower FPS but end up with a faster running fortress, if you've done things wrong.

Slogo

  • Bay Watcher
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #4 on: September 19, 2014, 12:24:34 pm »

Setting paths to 99 though will makes restricted areas much more restricted and can be worth doing out of dwarven safety at least, but also out of making those areas incredibly unlikely to be considered by pathfinding.

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #5 on: September 19, 2014, 12:28:41 pm »

Setting paths to 99 though will makes restricted areas much more restricted and can be worth doing out of dwarven safety at least, but also out of making those areas incredibly unlikely to be considered by pathfinding.
Just be aware that pathfinding only covers the route they take to get somewhere.  Pathfinding will not deter a dwarf from fetching a sock atop a spike trap, but pathfinding WILL determine what direction the dwarf takes to get to that sock.  Pathfinding is also like a spice.  Use it sparingly and smartly to accent, but let the main centerpiece be the real carrier.

Slogo

  • Bay Watcher
    • View Profile
Re: Pathfinding (and other FPS improvement)
« Reply #6 on: September 19, 2014, 12:36:11 pm »

Setting paths to 99 though will makes restricted areas much more restricted and can be worth doing out of dwarven safety at least, but also out of making those areas incredibly unlikely to be considered by pathfinding.
Just be aware that pathfinding only covers the route they take to get somewhere.  Pathfinding will not deter a dwarf from fetching a sock atop a spike trap, but pathfinding WILL determine what direction the dwarf takes to get to that sock.  Pathfinding is also like a spice.  Use it sparingly and smartly to accent, but let the main centerpiece be the real carrier.

Yeah, it doesn't deter goals at all, but it's still pretty strong for incidental pathing issues like traveling over/through rivers (frozen or drained).