v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing Path

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

If you are creating a redirect to the current version's page, do not use any namespace. For example: use #REDIRECT [[Cat]], not #REDIRECT [[Main:Cat]] or #REDIRECT [[cv:Cat]]. See DF:Versions for more information.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{Quality|Exceptional}}
+
{{Quality|Exceptional|21:45, 30 September 2016 (UTC)}}
 
{{av}}
 
{{av}}
  
[[File:pathing_preview.png|right]]'''Pathing''' is a videogame concept that refers to the path the AI selected to route from point A to B. It has important implications for [[workshop design|fortress design]], [[security design]] and [[framerate]] management.
+
'''Pathing''' is a videogame concept that refers to the path the AI selected to route from point A to B. It has important implications for [[workshop design|fortress design]], [[security design]] and [[framerate]] management.
  
== Basic movement ==
+
== Implications ==
Creatures can move in the four cardinal directions (north, south, east, and west), and four diagonal directions (northeast, southeast, southwest, northwest), as long as the target space is not blocked. This means creatures can path through diagonal gaps on the same Z-level. For example, this rat (<tt>r</tt>) can reach the cheese (<tt>%</tt>):
+
''Dwarf Fortress'' uses a modified [http://en.wikipedia.org/wiki/A*_search_algorithm A* search algorithm] ([http://qiao.github.io/PathFinding.js/visual/ a nice demo]) ([http://www.gamasutra.com/view/feature/131954/interview_the_making_of_dwarf_.php?page=8 confirmation]), which quickly calculates a decent path between points. The A* method takes point A and tries to quickly calculate a decent path to reach point B. This path is not always the quickest path - in fact, in a game with as complicated and ever-changing an environment as ''Dwarf Fortress'', pathing probably rarely chooses the quickest path. The purpose and utility of the algorithm is to find a useful path without using a lot of processing space, balancing speed and computability.
  
<diagram>
+
Pathing to raw materials uses the so-called [http://en.wikipedia.org/wiki/Manhattan_metric Manhattan metric]: meaning the material is checked by distance from the [[dwarf]]'s current position, rather than by an actual search. Thus, when constructing things, the valid materials list will be ordered from nearest to farthest; this, however, ignores any walls or obstacles in the way. An important part of fortress design is to be as open as possible, as more doorways will result in quicker paths (and thus better performance) as well as avoiding the hurdles of cross-map walks to find something the metric says is a short distance away. Workshops automatically path to the nearest valid raw materials; building things allows you to choose what to grab.
r░
 
░%
 
</diagram>
 
 
 
Creatures can move directly up or down, as long as the target space is not blocked and the movement is possible (via flying, climbing, swimming, stairs, etc.). Creatures can move diagonally across Z-levels only when both lateral and vertical movement are simultaneously possible (e.g., when using a ramp), with one exception[http://www.bay12forums.com/smf/index.php?topic=144364.msg5705256#msg5705256] (see below). For example, this giant sparrow (<tt>S</tt>) can not attack the cat (<tt>c</tt>):
 
 
 
<diagram>
 
<frame type=level level=0>
 
 
 
S░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
< to go up one z-level.
 
</frame>
 
 
 
<frame type=level level=1>
 
░░░░
 
░ c░
 
░░░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
> to go down one z-level.
 
</frame>
 
 
 
<frame type=level level=2>
 
 
 
░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
> to go down one z-level.
 
</frame>
 
</diagram>
 
 
 
=== Exception for diagonal movement between Z levels ===
 
 
 
Diagonal movement between Z-levels is possible when the floor is missing from the space above the wall, which would otherwise block movement. Flying and swimming creatures can pass through the gap caused by the missing floor. Common causes for a missing floor include building an up-down or down stair (without the matching up staircase below it), or constructing a wall underneath tree branches.[http://www.bay12games.com/dwarves/mantisbt/view.php?id=7130#c26072] For example, this giant sparrow ''can'' attack the cat, because the down stairs (<tt>&gt;</tt>) on level 2 has removed the floor, creating a hidden gap:
 
 
 
<diagram>
 
<frame type=level level=0>
 
 
 
S░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
< to go up one z-level.
 
</frame>
 
 
 
<frame type=level level=1>
 
░░░░
 
░>c░
 
░░░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
> to go down one z-level.
 
</frame>
 
 
 
<frame type=level level=2>
 
 
 
░░
 
 
 
 
 
This diagram has multiple z-levels! Press
 
> to go down one z-level.
 
</frame>
 
</diagram>
 
 
 
== Path finding method ==
 
''Dwarf Fortress'' uses a modified [[wikipedia:A* search algorithm|A* search algorithm]] ([http://qiao.github.io/PathFinding.js/visual/ a nice demo]) ([http://www.gamasutra.com/view/feature/131954/interview_the_making_of_dwarf_.php?page=8 confirmation]), which quickly calculates a decent path between points. The A* method takes point A and tries to quickly calculate a decent path to reach point B. This path is not always the quickest path - in fact, in a game with as complicated and ever-changing an environment as ''Dwarf Fortress'', pathing probably rarely chooses the quickest path. The purpose and utility of the algorithm is to find a useful path without using a lot of processing space, balancing speed and computability.
 
 
 
Choosing the nearest raw materials uses the shortcut of checking the [[wikipedia:Manhattan distance|Manhattan distance]] from the [[dwarf]]'s current position, rather than an actual search. Thus, when constructing things, the valid materials list will be ordered from nearest to farthest; this, however, ignores any walls or obstacles in the way. An important part of fortress design is to be as open as possible, as more doorways will result in quicker paths (and thus better performance) as well as avoiding the hurdles of cross-map walks to find something the metric says is a short distance away. Workshops automatically path to the nearest valid raw materials; building things allows you to choose what to grab.
 
  
 
== Applications ==
 
== Applications ==
 +
In the following examples, A is a creature and B is its goal.
  
For workshop jobs, the closest available valid material is used for the job. The simplest way to use pathing to your advantage is to surround a workshop with a stockpile accepting only specific raw materials that you want it to be using. While this is usually better handled by using linked stockpiles, it remains useful when trying to understand why, instead of decorating some beds in your furniture stockpile, your [[gem setter]] decides to fancify some commoners' [[coffin]]s in the next-door [[mason's workshop]].
+
For workshop jobs, the closest available valid material is used for the job. The simplest way to use pathing to your advantage is to surround a workshop with a stockpile accepting only specific raw materials that you want it to be using; in previous versions, this was the only way to ensure [[magma-safe]] materials would be used for application with [[magma]], and the only way to ensure certain jobs would be done in a certain way. Now, this process is better handled by linked stockpiles instead. Nonetheless, it remains useful when trying to understand why, instead of decorating some beds in your furniture stockpile, your [[gem setter]] decides to fancify some commoners' [[coffin]]s in the next-door [[mason's workshop]].
  
The way pathing is handled should influence the way you design your fortress. An important part of fortress design is to be as open as possible, as more doorways will result in quicker paths (and thus better performance) as well as avoiding the hurdles of cross-map walks to find something the metric says is a short distance away.
+
The way pathing is handled should inform the way you design your fortress. An important part of fortress design is to be as open as possible, as more doorways will result in quicker paths (and thus better performance) as well as avoiding the hurdles of cross-map walks to find something the metric says is a short distance away.
  
 
[[File:Pathing.jpg|thumb|right|300px|Applications of pathing (aka pathing abuse). Note that they do see every path, so if the green bottom bridge is raised, they will take the caravan entrance instead.]]
 
[[File:Pathing.jpg|thumb|right|300px|Applications of pathing (aka pathing abuse). Note that they do see every path, so if the green bottom bridge is raised, they will take the caravan entrance instead.]]
Line 136: Line 63:
  
 
If you want to use this, keep those (path-through) restricted areas as small as possible. On the other side, the higher the restricted costs, the more likely dwarves stick to the correct site. The same is true for longer tunnels. And the longer the tunnel, the less additional pathing will be done. If the tunnel is at least as long as the costs of the restricted area, you don't have to bother additional costs. So, this should only be used for long tunnels. Never use it to control traffic inside your fort between rooms unless you restrict most of your fort's area!
 
If you want to use this, keep those (path-through) restricted areas as small as possible. On the other side, the higher the restricted costs, the more likely dwarves stick to the correct site. The same is true for longer tunnels. And the longer the tunnel, the less additional pathing will be done. If the tunnel is at least as long as the costs of the restricted area, you don't have to bother additional costs. So, this should only be used for long tunnels. Never use it to control traffic inside your fort between rooms unless you restrict most of your fort's area!
 
==Other dwarves==
 
It is possible for entities such as dwarves to walk over each other when necessary. However, moving over occupied tiles in this manner is much slower, and dwarves will try to path so that they can avoid it. This introduces an important consideration to fortress design.
 
 
If you have a long, 1-tile wide corridor which already has a dwarf moving through it, other dwarves who need to get from one side of the corridor to the other will try to avoid colliding with that dwarf, by pathing elsewhere. If it so happens that the corridor is long, and there are no nearby alternative routes, this may cause a very significant increase in pathfinding burden.
 
 
For this reason, it's best to make high-traffic routes at least 2 tiles wide, and avoid single doors and single stairs. This ensures that when a dwarf tries to find a detour around another dwarf in his way, he will be able to do so easily and without modifying his current path much.
 
  
 
{{Translation
 
{{Translation

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)

This page is a member of 2 hidden categories: