Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Modding PATH_COST  (Read 1143 times)

Gnomechomsky

  • Bay Watcher
    • View Profile
Modding PATH_COST
« on: August 18, 2008, 10:48:11 pm »

The init.txt file says that if you put the "restricted" cost too high, that pathfinding will lag.  I've done some A* implementations, so I understand why that is (dwarves will consider lots of long alternative paths before considering the path through the restricted square).  But this is a relative thing, right?  If my numbers were, say, 10:11:50:250, would it lag any more than the default 1:2:5:25?  I'm thinking no, but can anyone confirm?

The reason I ask is that designating the center of my three-wide hallways to cost 10, while the outside "lanes" cost 11 should make my dwarves stick to the middle for long trips, but not bother if they're going fewer than 10 or so tiles.  If it's set at 1 and 2, then essentially no trip is short enough that the dwarves wouldn't hop to the center lane immediately.

Has anyone tried this?
Logged

Skanky

  • Bay Watcher
  • I'm building a wagon!
    • View Profile
Re: Modding PATH_COST
« Reply #1 on: August 18, 2008, 11:19:21 pm »

If you set the costs to 10 and 11, then they will still go to the middle of the 3-tile hallway for trips longer than 2 steps into that hallway. Any way you look at it, 32<33, so it will always be chosen.

Code: [Select]
D...#
#*..#
#.*.#
#*..#
D...#
The pathfinder will always return the path marked with * as the shortest route.
Logged
"Quickly now, the goblins are more devious these days." - Captain Mayday

Gnomechomsky

  • Bay Watcher
    • View Profile
Re: Modding PATH_COST
« Reply #2 on: August 18, 2008, 11:22:14 pm »

Ohh...yeah...a diagonal move doesn't cost sqrt(2) times as much as an orthogonal one, huh?  That does put a crimp in that plan.  Oh, well.
Logged

G-Flex

  • Bay Watcher
    • View Profile
Re: Modding PATH_COST
« Reply #3 on: August 19, 2008, 06:15:51 am »

Actually, I've heard that toady does implement diagonal movement at around 1.4 times the cost. But I'm not sure.
Logged
There are 2 types of people in the world: Those who understand hexadecimal, and those who don't.
Visit the #Bay12Games IRC channel on NewNet
== Human Renovation: My Deus Ex mod/fan patch (v1.30, updated 5/31/2012) ==