Page 1 of 1

[1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Thu Oct 13, 2022 9:25 pm
by mrtux
I have observed the following bug/unwanted beghavior:

* Two trains have a stop with a limit as their target.
* The limit changes, so that the stop cannot accommodate both trains

Expected: The trains will jump the stop and execute the next task in their schedule or it will go to the station regardless.
What happens: The trains stop where they are saying that the destination is full.


To demonstrate the issue I have created a blueprint that can be pasted into a (sandbox) game:

Code: Select all

0eNqtm99v2zYQx/8VTS9pBycTf0o0sD6se+ywAe2elsCQbSYRpkiGRCcNgvzvIyU7ttNTwjvspbAa8qMveTzqxDs9pct6azdd1bh0/pSubb/qqo2r2iadp98e2sR1ZdX0yU2bLK17sLZJeleGv/fJZfrnxjaXaVI2a3/xpbqrnF1fphfJt1ubrHwTVzbO/7hbVk3p2i4p67p96BPnsduuSZxvNvCTOvRNrn2TI05y1jZnv5y119dnF5fNZfN7O/S4bgOlam68Ervp55fNzye9AtoGQb6jv/zwULnb5PNezecXNR+T80/Jb63/42GMXtl+VAH7R9lsvebHpLd+iP7md2OLw808wg/2MXmo6jpZBthDuItvdTOo7ewsWW5d0peP/rJ0wwj8LLugwc9iUvXJ9db3/WC/b+zKQz+GG3/1ole3Q2NAedI2oZG/95/NfgYHAeMI6p26sUmwRRuUHDf0RK85yEv8vHsNv35K/m72En5KZ2kV7JfO/3lK++qmKeuwOtzjxvpl4eF3vkVT3oWruvUGbl11b9Nn361Z2+/pnD3PaB052PG+6pw3xKHv2OL8y1FPgerZ2fVRX/l8NUtt4ypX2XHQw8XjotneLW3nx/PSf7Xt7u363E9lgG7avhqd5Sn1nHOp5Sx9TOc6yzx9XXV+Poc/66DuFZQfRAXT3Ny6SawyA1YZc4rlAFYgsHk8ViKwKh6rEFgRj9UILIvH5vFYiTBZgcAiTGYQWITJWIbgImzGGIKLMBpDOJpAWI0hPE0gzMYQriYwdkP4msDYDeFsAmM3hLdxjN0Q7sYxdkP4G0fYjSP8jSPsxhH+xhF24wh/Ywi7cYS/M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MxRniyTOkiHIMreJNihHPwKRTBCzTssYyQ7ZlAccKzQcPrnROeDVMojk0u6ojghR1VH0RnBbWMyQoyLrGPIB0RzjBM/cE+k52zGLDGlkPmMmL7PKo/iMznv8bC1V8FPon9ehoECDb4jH4uXq8IuLIsw6f0Y9EMXXaq8ygwRxeeRoIFuvQ0EizRxaeRYIUuP40Ea3QBaiQ4R5egRoILdBFqJNigq1DjwJgiBokxHqKmYV+HGgnm6ELUSLBAV6JGgiW6FDUSrNC1qJFgjS5GjQTn6GrUSHCBLkeNBBt0PWocWGXogtRIMENXpEaCObokNRIs0DWpkWCJLkqNBCt0VWokWKPLUiPBObouFQBfzdJ+dWvX23r36dDhnC5c53JmzFGbMR11evY/Sx/Kyi1WbbOudofLvpGnbMrOLnYn00NebPfbVXfhENBVq3/7UIXxfDV8/PTDcfP/Ab4acl/hy6350beCs7Qul7YOHwkOX5UNd0y+joMM3+b91bXLevjc6952/ThXhd/sDM81M8aI4vn5P47AVdc=
factorio_station_limit_overview.jpg
factorio_station_limit_overview.jpg (464.39 KiB) Viewed 1901 times
(Not that the left station has no limit, the right station has its limit set to 0 or 1 with the Constant Combinator to allow easy change.)

Two trains go between the stops "Open" and "Limited". The constant combinator allows to turn the train limit for "Limited" 'on'/'off'.

To reproduce:
* "Limited" turned "off" (with Constant Combinator) -> Both trains go to "Open"
* Manually send them to "Limited" -> They will both want to go there, but say that the destination is full (expected)
* Switch the Constant Combinator on
* -> One train will go to limited
* -> The other train will stay where it is => Unexpected!

One of the trains will keep standing on the main track, ultimately blocking everything.


In a scenario with only one train the expected behavior actually happens: The train will go to the stop, even though the limit does not allow it.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Thu Oct 13, 2022 9:27 pm
by mrtux
The actual scenario where I observed this behavior has stops with a constant limits, but activation changing on available items/fluids. Now and then I saw trains standing around saying that their destination is full instead of going back to the open station. I need to resolve this manually.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Thu Oct 13, 2022 9:49 pm
by Loewchen
mrtux wrote:
Thu Oct 13, 2022 9:25 pm
* Manually send them to "Limited" -> They will both want to go there, but say that the destination is full (expected)
* Switch the Constant Combinator on
* -> One train will go to limited
* -> The other train will stay where it is => Unexpected!
You have a limit of 1, you have 2 trains, only 1 train will go. That is fully expected.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Thu Oct 13, 2022 10:48 pm
by robot256
mrtux wrote:
Thu Oct 13, 2022 9:27 pm
The actual scenario where I observed this behavior has stops with a constant limits, but activation changing on available items/fluids. Now and then I saw trains standing around saying that their destination is full instead of going back to the open station. I need to resolve this manually.
Trains will only skip an entry in their schedule if every stop with that name is disabled. If one stop is enabled, and it already has enough trains to meet its limit, then that forces every other train to pause their schedule until space becomes available or that one stop is disabled again.

The pause is unavoidable. The station must remain enabled long enough for the first train to arrive. The train will not depart early if you disable the stop immediately after its arrival, so you can shorten the waiting time by detecting the presence disabling the stop in that case. Without a train limit, the paused trains would simply be wasting fuel going toward the already-full stop, before repathing when the stop disablea again. This won't help if your intention is to have a train limit of 2 or more.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 12:10 pm
by mrtux
Loewchen wrote:
Thu Oct 13, 2022 9:49 pm
mrtux wrote:
Thu Oct 13, 2022 9:25 pm
* Manually send them to "Limited" -> They will both want to go there, but say that the destination is full (expected)
* Switch the Constant Combinator on
* -> One train will go to limited
* -> The other train will stay where it is => Unexpected!
You have a limit of 1, you have 2 trains, only 1 train will go. That is fully expected.
Yes, that would be fully expected. If there are two stops (same) name with a limit of 1 each, two trains will go. If one station gets disabled one train will go and the other will stop dead where it is - usually on the main track. That is the issue.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 12:26 pm
by boskid
mrtux wrote:
Fri Oct 14, 2022 12:10 pm
Yes, that would be fully expected. If there are two stops (same) name with a limit of 1 each, two trains will go. If one station gets disabled one train will go and the other will stop dead where it is - usually on the main track. That is the issue.
I do not care about this case anymore. Train stop limits and disabling train stops do not work well with each other. There were already tiny tweaks applied to trains logic for 1.2 as stated here: viewtopic.php?p=574563#p574563

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 2:00 pm
by mrtux
I see, so I need to work around this in any case. Thanks for the reply.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 3:08 pm
by mrtux
boskid wrote:
Fri Oct 14, 2022 12:26 pm
Train stop limits and disabling train stops do not work well with each other.
This actually helped me fix the issue: I am still mixing the systems, but knowing that they don't work well together I made sure that no train will be on the tracks stations are disabled by making sure that each station has a limit set so that it will not be disabled until all allowed trains have arrived.

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 3:27 pm
by FuryoftheStars
In the same logic that you cause one of the stations to disable, try also lowering the limit of the other station to 0. This may solve that.

Alternatively, instead of disabling, use the circuits to lower the limits of both to 0 (this won’t stop the second train from arriving if it’s already enroute, but at least it won’t stop on the main line).

Re: [1.1.69] Trains don't switch target when stop becomes unavailable due to Train Limit

Posted: Fri Oct 14, 2022 3:50 pm
by Loewchen
I close this now, if you want to discuss this further open a Gameplay help topic.