6

I have a refinery with a number of unloading stations for ore. Trains enter from the bottom right and exit to the bottom left.

However, for some reason the trains aren't using the stations effectively. I've sat here for minutes and watched as trains pile up in the Foundry Yard, waiting for an unloading train to finish and depart before moving up to replace it, while the top four stations sit idle.

Screenshots

Map overview. "Foundry Yard" is a 0-second stop set on every train's route just before "Foundry Unload". I thought adding such a stop would cause the train to re-calculate its destination, but it didn't seem to have any effect.

Map view

Closeup of stations. Blueprints were used to duplicate each one, so they are all identical.

Closeup of station

Screenshot with the "show_train_stop_point" debug option enabled. A train in the yard is waiting for an occupied stop to become free when there are several empty stops above it (off screen)

show_train_stop_point enabled

Save file

Here's my saved game and mod pack, from Factorio 0.12.

  • I Recall you used to have to assign stations to the train routes. And a train would only the assigned stations, not any other. Im not sure if you can trick this with similar names? Is there an entry for every similarly named stop in the list, or are they grouped together? – antipattern May 31 '16 at 10:34
  • @antipattern Using the same name for multiple stations makes that name appear only once, and trains will find any (the closest, usually) station with that name. – Darkhogg Jun 8 '16 at 14:52
4

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.

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.