Why aren't trains using all the available stops?

Solution 1:

From my tentative understanding of Factorio train mechanics, and tidbits I found on the web (I've been working on a very similar type of system recently), there are two factors here:

  • A train does not recalculate its path every time it is stuck, but only when it leaves a stop or it passes a regular signal. (There's also some kind of timeout or scheduled recalculation so trains don't remain stuck forever, though I think that might be newer than the version you were using.)

  • When a train is choosing a stop, it doesn't matter if another train is already planning to go there, but only whether the block is currently occupied.

Therefore, two trains may pick the same stop while some distance away and not notice the interference. Here's how to help them notice, at least within your Yard:

  • Do not allow any stacking of trains before the Yard stops. Branch the track as close to the stops as you can, and use a chain signal at the entrance to the branching. This ensures that a train will be seen to occupy the stop as soon as possible after it's actually committed to that stop.

  • Place a regular signal shortly before the branching point, even though that means it's right before the previously mentioned chain signal. This will ensure that the train has picked a free stop based on the latest available information.

Unfortunately, there is a case where a train is doomed to wait unnecessarily: when all stops of that name are occupied. In this case, it will always pick one and head as close to it as signals allow, then wait there until the time-based recalculation sends it elsewhere (or that one stop becomes available). The way to make the best of this is to be sure to use chain signals to prevent the train from heading down a branch before that branch's stop is available.

(Your Unload stations seem to be designed suitably already, so it might be simply that the Yard isn't efficient enough to feed them.)

Finally, one weird possibly-bogus fact that you might bump into if you expand this further: from my own testing, it seems that a train will only choose between 10 same-named stations. Any more than that, and it will only check the nearest 10. You can work around this by using tricks like having trains arriving in different directions (having a different idea of the 10 nearest), or a multi-stage choice (e.g. each yard stop goes to a different set of 10 unloading stops), which is what I'm doing.

Solution 2:

Connect the train stop to a circuit network with a red or green wire. A lamp or power pole will be sufficient (we don't actually need or want another device in the loop, or their signals might interfere, we just need to attach a wire to the train stop to turn on its circuit boxes).

Check "Enable/disable" and "Read stopped train". Uncheck other boxes.

By default, the number ID of the train at the station will now read as [T]. If there is no train, [T] will be equal to zero.

Set the train stop to be enabled when [T]=0. [T]=0 isn't the same as [T]=[0] so don't make that mistake.

This means the train stop will turn on when there is no train stopped at it, and off when a train arrives. This forces the other trains behind it that were pathing to the same stop to look for another open stop and path to it instead. Then they will use all your stations, starting with the nearest open one.