Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Confused about Traffic Areas and costs  (Read 2790 times)

Showbiz

  • Bay Watcher
    • View Profile
Confused about Traffic Areas and costs
« on: June 10, 2015, 12:30:43 pm »

Hello Community

I'm not sure how Traffic Areas work. Especially the Traffic Costs confuses me. What are they exactly?
Logged
Pardon for my mistakes
english isn't my native language

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #1 on: June 10, 2015, 12:55:46 pm »

The traffic costs don't work very well, and should definitely not be relied on.

My understanding of the traffic costs is that when planning movement, movement of one tile has the standard normal cost, while movement over tiles designated with other costs will use those. When moving from position A to position B the route with the minimum adjusted cost is chosen. However, given the computational effort of actually calculating the true minimum path, an algorithm that removes most of the paths at an early stage is probably used, meaning that sometimes a different path from the optimal one is chosen, although it should still be a fairly good one.
A result of the above is that a straight single tile wide line of maximum cost will probably not affect the actual paths of the dorfs except near the ends, since the resulting cost of crossing the high cost line is still lower than going around (if the line is reasonably long).
Using costs to stop dorfs channeling out a piece of rock for cave-in purposes getting stranded on top of the island is totally futile, for instance. The dorfs will strand themselves anyway, and other methods have to be used (such as leaving one tile unchanneled, get the bugger to dig elsewhere, and then come back, e.g. using the work priority system).
Logged

MonkeyHead

  • Bay Watcher
  • Yma o hyd...
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #2 on: June 10, 2015, 01:04:47 pm »

The traffic costs are useful to form "highways" which encourage dwarves to use routes you want them to use. They will not affect which jobs dwarves choose, and dwarves will still path into low and restricted traffic areas if they absolutely have to. I strongly recommend using restricted path designations over the entrances to large sections of mined out dead ends or caverns, as IIRC it prevents the path finding algorithm seeking out paths which it will not find in any case within the large dead ends beyond the restricted tiles. I have noticed about a 10% gain in FPS on my low end laptop by careful use of high and low cost designations in this way. The wiki page on it is quite useful... http://dwarffortresswiki.org/index.php/DF2014:Traffic

Eldin00

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #3 on: June 10, 2015, 02:11:19 pm »

The only use I've found for the traffic designations is putting narrow bands (1-3 tiles wide) of 'restricted' traffic to separate areas where the majority of the traffic won't cross from one area to the other. This has the effect of making pathfinding that should stay within one area cheaper, at the cost of making the pathfinding that legitimately needs to move between areas more expensive.
Logged

Dunamisdeos

  • Bay Watcher
  • Duggin was the hero we needed.
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #4 on: June 10, 2015, 07:32:09 pm »

I have found traffic costs to be hugely useful. You can use them to designate walking areas in large rooms. I use them to regulate traffic between workshops and storage. I tend to have, for instance, a stone stockpile directly next to the masonry shops. Using Traffic costs, I can make it so that stone delivery to the stockpile comes in such a way as to avoid the masons, and also avoid other dwarves moving finished goods/furniture to their stockpiles. It can really help prevent dwarves from crowding each other.
Logged
FACT I: Post note art is best art.
FACT II: Dunamisdeos is a forum-certified wordsmith.
FACT III: "All life begins with Post-it notes and ends with Post-it notes. This is the truth! This is my belief!...At least for now."
FACT IV: SPEECHO THE TRUSTWORM IS YOUR FRIEND or BEHOLD: THE FRUIT ENGINE 3.0

Albedo

  • Bay Watcher
  • Menacing with spikes of curmudgeonite.
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #5 on: June 11, 2015, 12:51:34 pm »

Hello Community

I'm not sure how Traffic Areas work.

They work just fine, thanks for asking.

Quote
Especially the Traffic Costs confuses me. What are they exactly?

Oh - that's a different question... ;)

Normally, any square costs "1" to enter (altho' diagonal movement is appropriately more - like 1.4 or something). So, when the computer tries to find "the shortest path" between point where a dwarf is and where he wants/needs to go, it counts the tiles, and takes the lowest value.

Let's say a dwarf is trying to get roughly from one corner of an embark tile (48x48) to another on the same level. If going 45 down one long hall, turning and going 45 down another hall on the same z-level is 90 tiles, but going back a few, up to the surface, diagonally across the open ground and down again is 89 or less, he'll take the shorter path if it's open. Likewise, if he has a choice between a winding path inside your fortress, or going outside, around the straight walls and back in the far side, he'll again take the "shorter" path as the computer counts it.

What the different Traffic Areas do is change the "cost" of a tile, so to the computer it seems to be a "cheaper" (shorter/faster) or "more expensive" (longer/slower) path. High traffic costs .5/tile, Low traffic costs 2/tile, and Restricted costs 25/tile.


If you use the High or Low Traffic cost (1/2 or 2), then dwarfs will ~tend~ to stick to/away from those squares, but since the diff is not great, it's not uncommon at all for them to drift. Still, a High Traffic "path" thru a larger area will tend to invite traffic to keep toward that stripe - perhaps keeping them from drifting into undesired areas.


If you use the Restricted cost (1 tile = 25), the computer will prefer a path that's 24 tiles long to taking one step into that square. This "restriction" is strong, but not bullet-proof - it can sometimes fail when 2 dwarfs need to step around each other in a tight area, or (of course) when a task takes them TO that square. Also, animals, invaders and dwarfs in combat don't care about path costs.

Just remember that if a dwarf HAS to go to that area (or thinks he does), then to the computer it's only as if it was 25 normal tiles further - just a longer trip.


I place 1 Restricted mark on all nearby saplings when I embark in a low-tree area and any high-value plants I plan to harvest to keep them from being trampled while the dwarfs build their defenses and get the supplies underground , updating them each season and/or when I finally cut the tree/gather the plant. Also around any "danger" areas.

More thoughts in the wiki: http://dwarffortresswiki.org/index.php/DF2014:Traffic
Logged

Eldin00

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #6 on: June 11, 2015, 03:39:52 pm »

You normalized all the costs EXCEPT restricted to normal having a cost of 1. Restricted is only 12.5x more expensive than normal, with the default values. Also, I believe DF does actually multiply costs for a diagonal move by 1.4.

Other than those 2 nitpicks, everything else Albedo said is an accurate (by my understanding) description of how DF determines the "shortest" path.
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #7 on: June 11, 2015, 06:23:06 pm »

I don't see why diagonals would cost more when they take exactly the same time to traverse. The Pythagorean Theorem doesn't exist in the DF universe.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Loci

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #8 on: June 13, 2015, 09:55:20 am »

I don't see why diagonals would cost more when they take exactly the same time to traverse.

Who says they do?

Quote
Median dwarves take approximately 10.5 time units and 14.9 time units to travel orthogonally or diagonally respectively.
source
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #9 on: June 13, 2015, 11:59:30 am »

The quote is from the link which refers to the 0.31 version. The corresponding page for the 0.40 version does not have anything to say about diagonal movement.
Logged

Loci

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #10 on: June 13, 2015, 11:44:43 pm »

Which means that either Toady removed realistic distance calculations from his simulation, or the wiki is incomplete. I know which one I think is more likely, but the good news is that you can test this yourself quite easily. Embark in a flat area with some stones, designate a several walls both orthogonally and diagonally, unpause and watch to see what happens. In most cases, the orthogonal walls will be completed before the workers even reach the diagonal sites. (Note that randomly-generated strong dwarves can throw off the results, but with a large enough sample size the pattern becomes clear.) Dwarves take longer to walk a diagonal path, as they mathematically should.
Logged

Showbiz

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #11 on: June 15, 2015, 08:27:25 am »

Thanks for your replys. I think it makes more sense now.
Logged
Pardon for my mistakes
english isn't my native language

Uggh

  • Bay Watcher
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #12 on: June 16, 2015, 07:05:52 am »

Something else to remember is that traffic designations only apply to your dwarves. While you can use them to keep your dwarves from dangerous places, albeit not perfectly, the caravan will happily walk over that frozen lake in the first days of spring. And drown.
Logged

Albedo

  • Bay Watcher
  • Menacing with spikes of curmudgeonite.
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #13 on: June 16, 2015, 11:29:42 am »

...and blame it on you.

\o/
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Confused about Traffic Areas and costs
« Reply #14 on: June 16, 2015, 08:41:20 pm »

What the different Traffic Areas do is change the "cost" of a tile, so to the computer it seems to be a "cheaper" (shorter/faster) or "more expensive" (longer/slower) path. High traffic costs .5/tile, Low traffic costs 2/tile, and Restricted costs 25/tile.

High costs 1/tile, normal 2/tile, low 5/tile, restricted 25/tile.