## Why train chooses long distance?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
datarza
Long Handed Inserter
Posts: 90
Joined: Thu Sep 15, 2022 1:55 am
Contact:

### Why train chooses long distance?

On the second image train #2 wants to go on the long rails instead of chooses the short rail, why?

PS: on the first image the train selected the correct rail.
Attachments
Screenshot 2023-02-24 185956.png (3.28 MiB) Viewed 1499 times
Screenshot 2023-02-24 185718.png (3.67 MiB) Viewed 1499 times

datarza
Long Handed Inserter
Posts: 90
Joined: Thu Sep 15, 2022 1:55 am
Contact:

### Re: Why train chooses long distance?

datarza
Long Handed Inserter
Posts: 90
Joined: Thu Sep 15, 2022 1:55 am
Contact:

### Re: Why train chooses long distance?

In addition: the same situation like on the first image (good image), but train selected wrong rail. Some times train selects good rail, but sometimes wrong.
Attachments
image_2023-02-24_191646328.png (3.53 MiB) Viewed 1480 times

robot256
Filter Inserter
Posts: 634
Joined: Sun Mar 17, 2019 1:52 am
Contact:

### Re: Why train chooses long distance?

If a train is occupying the short rail at the moment a second train is computing a path through the intersection, it's possible the second train thinks the longer path is a safer option. It won't necessarily check if the shorter path becomes available before it gets to the intersection as long as the longer path stays available.

SoShootMe
Filter Inserter
Posts: 514
Joined: Mon Aug 03, 2020 4:16 pm
Contact:

### Re: Why train chooses long distance?

Expanding on what robot256 wrote: the Train path finding information in the Wiki explains how this works. The key points in this case are that there is a penalty for occupied blocks and (roughly speaking) as long as the train can keep going it will not change its path (none of the conditions that cause a repath will apply).

Because using the east-to-south chord is only slightly shorter than using the roundabout, it is very likely that if the chord is occupied and the roundabout is not, the roundabout will be chosen. Using the roundabout instead will block a train from the north turning west, so the effect may be more than just being a longer path, but in most cases the difference will still be pretty small.

disentius
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

### Re: Why train chooses long distance?

And: pathfinding happens when a train wants to leave its station, not in real time, unless there is a repath condition.

Tertius
Filter Inserter
Posts: 799
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

### Re: Why train chooses long distance?

The way through the roundabout isn't longer. Count the tracks: it's the same amount of rail pieces. At least if I count them with the blueprint I use for this type of intersection:
1.png (476.15 KiB) Viewed 1364 times
By the way, you might notice I use less signals and less blocks. It's still sufficient. More signals and smaller blocks will not make trains wait less.

datarza
Long Handed Inserter
Posts: 90
Joined: Thu Sep 15, 2022 1:55 am
Contact:

### Re: Why train chooses long distance?

I have calculated the length and both directions contain 17 rails, so yes, they have the same length