In other languages: Deutsch

Railway/Train path finding: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
mNo edit summary
(fixed history, removed links duplicate with history, added link to pathfinding code)
Line 1: Line 1:
{{Languages}}
{{Languages}}
{{sublinks}}
{{sublinks}}
Before a train moves to a target (In this case, a [[Train stop]]), it calculates the best route based on the railway network at that time.
Before a train moves to a target (In this case, a [[Train stop]]), it calculates the best route based on the railway network at that time.


Line 13: Line 12:
== History ==
== History ==


In v15 a penalty was added to avoid using train stops as through tracks
{{History|0.15.0|
* Train station adds 2000 tiles penalty when path finding, so trains try to avoid stations not related to their path.}}
 
{{History|0.11.17|
* Increased the pathing penalty for non-moving train in manual mode from 200 to 1000.}}


The current algorithm was introduced with v0.11.11.
{{History|0.11.13|
* Stopped, manually controlled train adds additional penalty (related to train path finding) of 200 tiles to the block it occupies.}}


Before v0.11.11, the algorithm was simply: If the next block is occupied, take another route.
{{History|0.11.11|
* The pathfinding is based on penalties for blocked segments now. For trains waiting in station, the more remaining time in the station, the bigger penalty.}}


== See also ==
== See also ==


* [https://gist.github.com/Rseding91/c0d4d08d6feaed618ed4a03f6c6a8fe6 Train pathfinding as of version 0.15 (Code)]
* [https://www.factorio.com/blog/post/fff-68 FFF #68]
* [https://www.factorio.com/blog/post/fff-68 FFF #68]
* [http://www.factorioforums.com/forum/viewtopic.php?f=30&t=4834 bug ticket]
* [https://forums.factorio.com/viewtopic.php?f=30&t=4834 bug ticket]
* [http://www.factorioforums.com/forum/viewtopic.php?f=11&t=8795&p=70586#p70586 Changed weighting]
* [https://forums.factorio.com/viewtopic.php?f=30&t=2237#p62195 Bug ticket explained]
* [http://www.factorioforums.com/forum/viewtopic.php?f=30&t=8795 Changed weighting]
* [http://www.factorioforums.com/forum/viewtopic.php?f=30&t=2237#p62195 Bug ticket explained]

Revision as of 17:58, 23 October 2017

< Railway | Train path finding

Before a train moves to a target (In this case, a Train stop), it calculates the best route based on the railway network at that time.

For calculation it uses a simple A*-algorithm, with the following special weighting-rules:

  • When the rail block is occupied by a train -> Add a penalty of 2 * length of the block divided by block distance from the start, so the far away occupied paths don't matter much.
  • When there is a train waiting in the station -> Add a penalty of 6 tiles per every remaining second in the station. (This also helps the train to choose the best station to queue up for even when all of them are occupied, it picks the one with least time remaining).
  • When the path includes a train stop that is not the destination -> Add a penalty of 2000.

The route is recalculated if the train needs to stop. There is an invisible front point internally called the train_stop_point which is used to determine if the train needs to stop. See Debug mode and turn show_train_stop_point on to see that point. The route also recalculated after a train has stopped on a signal. This is to make pathing as dynamic as possible.

History

  • 0.15.0:
    • Train station adds 2000 tiles penalty when path finding, so trains try to avoid stations not related to their path.
  • 0.11.17:
    • Increased the pathing penalty for non-moving train in manual mode from 200 to 1000.
  • 0.11.13:
    • Stopped, manually controlled train adds additional penalty (related to train path finding) of 200 tiles to the block it occupies.
  • 0.11.11:
    • The pathfinding is based on penalties for blocked segments now. For trains waiting in station, the more remaining time in the station, the bigger penalty.

See also