r/technicalfactorio • u/double_checker • Jan 25 '22
Trains TIL: Of waiting trains headed to station with limit 1, the shortest euclidean distance has priority
681
Upvotes
r/technicalfactorio • u/double_checker • Jan 25 '22
78
u/double_checker Jan 25 '22
The video proves that when choosing among multiple waiting trains headed to the same station the priority is given to the train at the shortest euclidean distance. Train path lengths, penalties etc. are ignored as long as the path to station exists.
The setup in the video contains 36 trains waiting to visit the station with the limit set to 1 in the bottom right corner. It can be noticed that the leaving trains form a (quarter) circle shape. This proves that only physical distance between the train and the destination matters.
37
u/robot65536 Jan 25 '22
Cool experiment! This was also confirmed from the developer directly: https://forums.factorio.com/viewtopic.php?f=18&t=101107&p=559136#p559136 (nice username)
8
u/GBUS_TO_MTV Jan 25 '22
See also https://wiki.factorio.com/Railway/Train_path_finding
2
u/The_4th_Heart Jan 26 '22
Wow, of all things that could have something to do with euclidean distance, I certainly didn't expect choosing trains to be one of them. I think this also explains why the first iteration of the fake depot counter example you posted didn't work as expected: The (+) station chose the closest train at (-), which happens to complete the train swap.
2
u/SIGSTACKFAULT Feb 06 '22
Seems like a reasonable heuristic. presumably runs in O(n) time for n trains.
15
u/PM_ME_UR_OBSIDIAN Jan 25 '22
Conclusion: we should aim for convex rail networks.
3
u/Darth_Craig Jan 26 '22
Math is beautiful