Railway/Train path finding: Difference between revisions
Jump to navigation
Jump to search
(A few grammar edits) |
m (Minor grammar fixes) |
||
Line 2: | Line 2: | ||
{{sublinks}} | {{sublinks}} | ||
Before a train moves to a target [[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. | ||
For calculation it uses a simple A*-algorithm, with the following special weighting-rules: | 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 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 even when all of them are occupied). | * 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). | ||
The route is recalculated if the train | 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 == | == History == | ||
Line 14: | Line 14: | ||
The current algorithm was introduced with v0.11.11. | The current algorithm was introduced with v0.11.11. | ||
Before | Before v0.11.11, the algorithm was simply: If the next block is occupied, take another route. | ||
== See also == | |||
* [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] | * [http://www.factorioforums.com/forum/viewtopic.php?f=30&t=4834 bug ticket] |
Revision as of 23:24, 21 December 2016
< 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).
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
The current algorithm was introduced with v0.11.11.
Before v0.11.11, the algorithm was simply: If the next block is occupied, take another route.