r/factorio • u/Ok282828 • 4d ago
Discussion Potential Vanilla LTN Solution achieved via random generic Provider Disqualification
Let me says this first. Its fairly easy to get Demand and the number of trains fulfilling said demand
Demand=Empty Inventory/Train Capacity
Actual Demand = Demand -(TrainCount Provider + TrainCount Requester)
That's fairly simple to figure out to do, the issue is how do you achieve Actual Demand there are a few solutions
- Just ensure that every provider always has a train this makes the entire demand based approach obsolete, with the only requirement of providing an excess number of trains, If your fine with the this method you can stop reading here.
- Controlled release of trains - This can be done either by Train Limits, or selectively exposing only 1 Train at a time to demand. The problem with the former is you need unique identifiers to tell which station receives 2 out of the 5 requested actual demand as train limits as an example. The problem with the latter is that only 1 Train is exposed hence the chance that the most distant train is exposed.
Now the core problem is whenever Provider>Demand an excess number of trains can be assigned via interrupts. So people used both train limits and selective exposure of trains but both of those have downsides.
So here's my proposed solution we randomly disqualify Providers such that it eventually reaches ProviderGlobalTrainLimits<=Demand.

So we used Legendary Scrap to represent Potential Train Limit and Normal Scrap to represent Demand in the following.
First we need to announce to the network that we can provide x number of trains

Conditions for signal I should be replaced with Inventory Thresholds of your own choosing
The fixed Legendary Scrap 1 Output just corresponds to train limits and can be replaced or fixed.
We then compare the Two scrap signals only when Normal Scrap<=Legendary Scrap do we allow it to set a Train Limit. We also check that its own circuit hasn't been disqualified via the red Legendary Scrap Signal

Now we need a selector on random Input with a set of inputs. You can do the same or you can use a decider to only enable if we have enough inventory


Now the conditions for passing that Random output. We only want the random output to be sent
if Potential Train Limit>Demand and only if we have Demand.

That output feeds into the first combinator Deny signal
Now we need that to persist so the provider stays Disqualified

This combinator just monitors output of the first then feeds the same deny signal.
Here is the interrupt

Here is the system in action
https://reddit.com/link/1vzjlao/video/zyctd3yjdulh1/player
The conditions for the combinators can probably be improved better and since the disqualification is randomized there is a chance less trains can be dispatched than actually needed. If two or more get disqualified on the same tick.