With Factorio 1.1 a simple yet game-changing feature was introduced: Train Stop Limits.
Normally I always stick to LTN or TSM, or
With just a few combinators we can emulate the logistic network with trains almost exactly. (Still no easy support for cargo-agnostic train deliveries though.)
So what does it take to have a logistic train network in unmodded Factorio?
Well turns out we can break down the steps fairly easily…
Components of a Logistic Network
For our network we will define a few requirements:
- Providers supply a single type of cargo
- Requesters receive a single type of cargo
- Trains only move when both supply and demand exist
This mimics the bot logistic system, but does not deal with the intricacies involved in buffer or active provider / storage chest situations. We only handle a single item per stop to avoid crazy long train schedules or deadlocks that could potentially stall the network.
In order to support this method we need a few additional requirements:
- Without any active Providers or Requesters, Trains need somewhere to be (they can’t stack in a roboport like bots can)
- No global circuit network (we won’t run circuit networks across every Station)
Since disabling all stops for a train by circuit condition causes the train to immediately halt, we can’t use that method without jamming our whole train network, so instead every stop needs to use the train limits only.
So given these restrictions, I’ve formulated a strategy for what I believe to be an extremely useful approach to create vanilla logistic train networks. (VLTN)
Logistic Emulation Rules
- Never allow a higher Stop Limit than can fit in your Stop’s stacker
- Never circuit-disable a provider Stop (always use Stop Limit instead)
- Never have more trains of a type than there are total train spots, minus one
Maximum Stop Limit
Just as the case with non-logistic train stops, we need to make sure that we don’t allow more trains in a station’s stacker than it can support in order to prevent deadlocks on a main line.
Since we’re going to be controlling the stop limit via a circuit we will need additional logic to ensure the max stop limit is respected. This is done using a simple comparison: output the lower value of (max stop limit, current desired limit).
Do not circuit-disable a stop
Normally it would be easier to just toggle the station on and off depending on whether it’s needing items, but doing a simple boolean approach does not work well to request only as many trains as desired, while it may work for a single station for awhile, there are other problems as well.
Most importantly, if both the requester and provider get circuit-disabled at the same time a train moving between them will freeze and stall the line it’s on.
Instead we will simply bring the stop’s limit to zero, this allows trains currently en-route to finish their trip even after the request has been satisfied. This prevents stalled trains sitting on the main lines.
Never have more trains than available spots
For a single item type, make sure you never have more trains than could fit in all available slots, otherwise deadlocks will occur. Keeping at least one spot open for each item type will ensure that trains can keep flowing.
As an example, if I have a 3-spot iron provider and a 3-slot iron requester, I should not have more than 5 trains servicing iron requests.
To help alleviate this, it’s possible to add a refuel or depot stacker stop, but I think that is not a great approach in terms of required travel-per-request efficiency.
Building the VLTN
TLDR: set trainload size in leftmost divider, set negative request and max train limit in the constant combinator.
For the requester our combinator process is so:
- Figure out how many trainloads we desire.
- Compare the desired demand to the maximum demand.
- Output the minimum of the desired and the maximum.
The first step is simple, we just take the requested number of items and divide by the size of a trainload, we use a negative number to represent demand for an item.
In order to output the minimum we require two combinators for the comparison, one for the case where we’re below the maximum, and one for the case where the desired trainloads is greater than the maximum.
Providers are basically the exact same setup, but this time a positive number from the stop’s buffer is used as the supply, so we simply divide the supply by the train size as the desired stop limit.
The circuitry for the maximum stop limit is the same, so you could even just reprogram the requester as a provider.
Bringing the system together
With a functioning Requester and Provider, we’re ready to start deploying these stations and using them.
You can deploy as many of these stations as you want, and keep adding copies of the same train for an item so long as you don’t add more trains than your stops can handle. I recommend refueling at either the provider or requester instead of using a fuel depot so that you can cut down even further on network congestion.
Eventually I’ll add a complete blueprint book with a few different trainload capacities, but for now all you really need to get started is the two blueprints I left above.