Page 1 of 1

[0.15.36] [Dominik] Reproducible Train Collision

Posted: Fri Oct 13, 2017 7:17 am
by Kli_Womagni
Trains were colliding in my large base, despite what I think is proper signal placement. The fast train fails to reserve an intersection even though it can't stop in time. I don't think trains should forget to mark signal blocks as reserved, especially not at high speed.

Here's a video that shows the whole collision process. Sorry about the low framerate, potato computer.
https://webmshare.com/play/MJPxd

The blue train reserves the intersection, entering at high speed. When it is completely inside the upper loop it stops reserving the intersection, even though it can't stop in time. It still reserves the blue exit block, just the intersection is unreserved. Meanwhile, the green train sees the intersection become free and enters, travelling towards the green exit block. The blue train reenters the intersection at high speed and causes a collision.

Here's a screenshot of the moment the blue train erroneously releases its reservation on the intersection. I've marked all the signals so you can more easily see the colours. The blue train is travelling at high speed while the green train is stationary. Also notice that the debug braking distance at the moment the blue train exits the intersection is already back inside the intersection. If that distance is inside the loop instead, the bug doesn't occur.
Screenshot of the moment blue train unreserves intersection
Screenshot of the moment blue train unreserves intersection
Crazy Trains - Markup.png (4.34 MiB) Viewed 1584 times
I've attached a small save that demonstrates the problem, just short-circuit the combinator to start the trains.

I've tried some variations and they illustrate the inconsistency of this problem.
  • If the blue train is slower (connect the shorter track on the right), it properly sets the intersection signals to yellow.

    If the blue train is instructed to use the alternative train stop (delete Blue Exit in the blue train), it slows down enough and properly sets yellow signals.

    If the green train is instructed to use the alternative train stop (delete Green Exit in the green train), it sees the blue train reserve that exit block (but not the intervening intersection) and correctly doesn't pass the chain signal into the intersection because its desired exit is busy.

    If the two signals in the loop are removed (rail and chain signals), the loop becomes part of the intersection block and of course the intersection doesn't get unreserved. I don't consider this to be a solution, it just hides the problem.
It's possible this is a duplicate of viewtopic.php?f=11&t=49581, but much cleaner reproduction, and it's definitely still happening in [0.15.36]. As far as I can tell there is no repathing, just that the fast train unreserves the intersection when it first leaves, not realising it needs to reuse the intersection and is going too fast to stop.

Save, log, and video are also available at https://www.dropbox.com/sh/gtu7z6yjuifz ... kFqTa?dl=0

I apologise for the biters which attack the factory, they don't come near the railway so it shouldn't interfere with the demonstration.

Re: [0.15.36] [Dominik] Reproducible Train Collision

Posted: Mon Oct 16, 2017 12:53 pm
by Dominik
I think that what is happening is that the train makes the reservation request for the future entry, as you say, but it is already on the block at that moment, so it does not add anything. And when it leaves the block as it enters the top loop, it unregisters from it completely, removing the future reservation too. Let me check it and get back to you.

Re: [0.15.36] [Dominik] Reproducible Train Collision

Posted: Tue Oct 17, 2017 10:51 am
by Dominik
I have tried your save. It indeed does occur in 15.36, but it is fixed in our current branch for 0.16. So thanks for the report and look forward to the new version :)