[1.1.1] trains limit: over-commits by 1 if using circuit logic

Bugs that are actually features.
Post Reply
Saibantes2
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Oct 09, 2020 7:27 pm
Contact:

[1.1.1] trains limit: over-commits by 1 if using circuit logic

Post by Saibantes2 »

"Obvious" use case for the new trains limit on train stops is to use circuit logic to set the limit to the amount of items available for pickup divided by the train capacity.
Since the train currently stopped at the station counts towards the limit (it still reserves a spot until leaving), the amount of items already loaded should be included in the calculation. Therefore L = (stuff_in_chests + train_contents) / train_capacity.

However, this results in one train to many to go for this train stop, because the train leaving the station will immediately release its reservation, but the decrement of the train limit will take at least one more tick to propagate through circuit logic. During this single tick another train may route for the stop and it will continue even when the limit decreases one tick later.
It may appear unlikely that a train decides to go for this stop in exactly this one tick, but this will always happen, if a train is already waiting in the "Destination full" state.


See the attached savegame as example. The train stop limit is set as described above. There is enough material for two trains, but three trains are available. The third train will go for the train stop exactly at the moment the first one leaves.
After loading the safe game, start it by disabling the Constant Combinator blocking the train signal.


Possible fix in the game logic: Have the trains leaving a train stop keep their reservation for at least a few ticks longer so that circuit logic can propagate. This may have the opposite effect of under-committing, but this is less problematic as trains already en route will still continue, and new trains would only be delayed by a few ticks.

Possible fix by the player:
(1) Don't include the train contents in the calculation. This way one additional train that could already go for the stop will be delayed while another train is currently loading.
(2) Include the train contents in the calculation, but only as long as the train is not "almost full" (i.e. "full" minus the combined hand sizes of all inserters).
Attachments
test_train1.1.zip
(2.39 MiB) Downloaded 59 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2255
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.1] trains limit: over-commits by 1 if using circuit logic

Post by boskid »

Interesting (including loaded cargo into limit) but Not a bug. Circuit network has its own delay (as you noticed) and i will not be solving this "by adding couple of extra ticks".

-- edit:
Simplest solution from the "player can" is to have departure condition set to Circuit network, that way you can manually send a train out making sure the limit signal is reduced by 1 in advance.

Post Reply

Return to “Not a bug”