Friday Facts #299 - Everything is more complex than expected

Regular reports on Factorio development.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 504
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Gergely » Mon Jun 17, 2019 11:33 am

boskid wrote:
Mon Jun 17, 2019 5:38 am
This is programming and every detail matters. If train goes through one segment from two not intersecting relations, train will reserve this section for first pass and then for second pass "it will ignore setting flag because it is already set", but now goes second part: when train finishes its first pass, it will clear this flag so there is no guarante that on second pass there will be no colliding other trains - they could reserve this section as it is no longer reserved and enter it - train collision. How would you prevent this? simple: wait until all passes through section are done. In this case it will be after 2 passes. But why 2? why not 3? not 4? Simple - lets count how many times this section was reserved for distinct passes. This way not every "release signal" will mark segment to be free - only if all "release segment" were done to their complementary "reserve segment"
You are just explaining to me what's already explained in the fff. You forgot that I also said...
Gergely wrote:
Mon Jun 17, 2019 5:17 am
Let's say you expect the train to only ever enter any block in it's path once.
I was just trying to explain the way it used to work. When it was written, this specific scenario wasn't considered.

Bilka
Factorio Staff
Factorio Staff
Posts: 1954
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Bilka » Mon Jun 17, 2019 11:54 am

plumbide wrote:
Sun Jun 16, 2019 10:09 pm
Hey guys, FYI, the main page of the site (https://wiki.factorio.com/Main_Page) hasn't been updated to include this FFF. I thought you'd missed a week!
Huh? It's been updated since Friday, I have a script that does that automatically.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

mrvn
Smart Inserter
Smart Inserter
Posts: 3411
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by mrvn » Mon Jun 17, 2019 12:54 pm

Riktol wrote:
Fri Jun 14, 2019 2:19 pm
I've probably missed something but why can't you limit a train to reserving each block once? The train enters block 3 and removes the reservation on block 2, then reserves block 2 again (unless another train has already reserved it)?

Alternatively you could mark the whole thing as working as designed, people who don't put enough signals :twisted: deserve :twisted: to have their trains crash.
The train reserves everything ahead of it up to the breaking point. A train is easily fast enough that it won't be able to stop before segment 4 before it enters segment 2. So it needs to reserve 2, 3, 2 again, 4 or it already has to be slowing down.

mrvn
Smart Inserter
Smart Inserter
Posts: 3411
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by mrvn » Mon Jun 17, 2019 1:07 pm

Philip017 wrote:
Fri Jun 14, 2019 4:52 pm
trains are indeed a integral part of the game, when we play large maps, running millions of belts, although possible, are certainly more ups intensive than running a bunch of trains.
it is a very good idea to prevent crashes and dsyncs as these are detrimental to fluid game play. still hoping that the save function will eventually be pause free, but would still love to see a message 10 seconds before the inevitable forced stand still, which can sometimes take upwards of 30 seconds or more on very large maps.
with out trains those very large maps and bases would be way more challenging but having a good train network is great. learning how to properly use train signals however can be a tall learning curve, but 2 things i have learned that i consider the best for train networks is:
1) Rail Signals every Big electric pole distance for long runs.
OR further if you are running extremely long trains, the distance between them should be at least the distance of your trains plus wagons, for the majority of your trains. my example for a signal every big pole is good for 1-4 trains. if your rail signals are too close together you could end up with traffic jams. and too far apart will result in slow downs.

2) Chain Signals before every junction, and another rail after all the junctions close.
use of more chain signals in a large junction block allows trains with non-interfering paths to cross though the same junction, which makes them faster. placing a rail signal after all junctions complete, allows the train path to become open again after the train clears, which will allow the next train with what would be an interfering path to enter the junction space.

failure to make proper use of rail signals and chain signals most likely will result in a jam or collision.
although the train logic is being improved dramatically which can allow use of rail signals everywhere, because players like me, where i didn't understand the difference between chain and rail signals, or how to use them properly, resulted in unintended behavior, and forwarded to the devs as bugs, although realistically these issues are more along the lines of: "lack of understanding" or "lets try to break the game".
thanks however to the fantastic developers of this game, they take these things in stride and make adjustments to help with these situations.
Thanks to all of you at WUBE for this fantastic game and all your hard work!
That won't safeguard you.

The rules are simple:

1) You can place chain signals everywhere (see 4 why you don't).
2) You should have a (chain) signal before 2 tracks merge or cross and after 2 tracks diverge or cross.
3) You can change a chain signal to full signal when there is enough space for a train to clear this signal and stop at the next signal and having it stop there doesn't bother you (generally that means it doesn't halt on top of a junction but sometimes that is OK. Halting on top of a crossing is generally never OK).
4) If there are 3 chain signals in a row on a track without merging, crossing or diverging track you can remove the middle one.

Kalanndok
Inserter
Inserter
Posts: 33
Joined: Sat Dec 12, 2015 9:07 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Kalanndok » Mon Jun 17, 2019 3:55 pm

So just to get that straight...

You're saying a train can enter a block that it has reserved itself?
So that would mean that if Block 2 in the example would be accessible to the train by a long right-turn it would be possible for the train (provided it is long enough) to bite it's own tail?

To me it sounds like the error is not that the train frees the block after leaving it but rather that it can enter a block that it has reserved itself.

IMO in that design the train must stop at the 3->2 signal unless it is short enough to completely clear block 2...if that is not possible it should not be allowed to proceed as that block 2 could loopback into itself and the train may collide with itself (Nokia-snake anyone?)

User avatar
Lubricus
Fast Inserter
Fast Inserter
Posts: 213
Joined: Sun Jun 04, 2017 12:13 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Lubricus » Mon Jun 17, 2019 6:32 pm

Kalanndok wrote:
Mon Jun 17, 2019 3:55 pm
So just to get that straight...

You're saying a train can enter a block that it has reserved itself?
So that would mean that if Block 2 in the example would be accessible to the train by a long right-turn it would be possible for the train (provided it is long enough) to bite it's own tail?

To me it sounds like the error is not that the train frees the block after leaving it but rather that it can enter a block that it has reserved itself.

IMO in that design the train must stop at the 3->2 signal unless it is short enough to completely clear block 2...if that is not possible it should not be allowed to proceed as that block 2 could loopback into itself and the train may collide with itself (Nokia-snake anyone?)
Yes. In factorio trains can collide with themselves in roundabouts. That is a "fun" feature.
Trains are reserving blocks far in front of them so they can stopp in time and if the trains reserved blocks that they have reserved, they would block themselves in some situation as roundabout even where it's no risk in running into themselves. And the result would be many confused players wondering why the trains is blocked.

Ormy
Inserter
Inserter
Posts: 21
Joined: Thu Mar 14, 2019 9:05 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Ormy » Tue Jun 18, 2019 12:58 pm

I'm not talking specifically about the particular rail situation pictured in fff, this is a general opinion regarding these type of situations.

Nothing the user can do should ever crash the game, all game crashes are bugs that must be fixed (depending on severity of course).

However, having trains collide and/or deadlock as a result of poor signalling is exactly how the game should behave. Yes rail signalling is somewhat complex and has a steep learning curve but most importantly its a FUN challenge, please please don't remove any of that fun by making rail signalling easier.

HurkWurk
Filter Inserter
Filter Inserter
Posts: 252
Joined: Mon Nov 14, 2016 4:55 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by HurkWurk » Tue Jun 18, 2019 5:19 pm

Kalanndok wrote:
Mon Jun 17, 2019 3:55 pm
So just to get that straight...

You're saying a train can enter a block that it has reserved itself?
So that would mean that if Block 2 in the example would be accessible to the train by a long right-turn it would be possible for the train (provided it is long enough) to bite it's own tail?

To me it sounds like the error is not that the train frees the block after leaving it but rather that it can enter a block that it has reserved itself.

IMO in that design the train must stop at the 3->2 signal unless it is short enough to completely clear block 2...if that is not possible it should not be allowed to proceed as that block 2 could loopback into itself and the train may collide with itself (Nokia-snake anyone?)
sorta.
in the example, its a single train car, and its clearing signals. If it had rail cars attached, the results would be different because the train would not "fit" into area 3, so would never release area 2.

while its possible with bad signaling to have a train hit itself, in this example, its not possible. if the train never leaves 2, it never releases it, so it would never run into this bug.

User avatar
wischi
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Apr 29, 2017 5:17 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by wischi » Thu Jun 20, 2019 10:34 pm

Does that also fix the big where trains (under some circumstances) instantly stop at an intersection?

It "feels" like this happens if two trains race towards an intersection and one train recalculates the path right before the intersection (4 lanes) and the other one instantly stops.

Trebor
Fast Inserter
Fast Inserter
Posts: 184
Joined: Sun Apr 30, 2017 1:39 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by Trebor » Sun Jun 23, 2019 7:44 pm

mrvn wrote:
Mon Jun 17, 2019 1:07 pm
The rules are simple:

1) You can place chain signals everywhere (see 4 why you don't).
2) You should have a (chain) signal before 2 tracks merge or cross and after 2 tracks diverge or cross.
3) You can change a chain signal to full signal when there is enough space for a train to clear this signal and stop at the next signal and having it stop there doesn't bother you (generally that means it doesn't halt on top of a junction but sometimes that is OK. Halting on top of a crossing is generally never OK).
4) If there are 3 chain signals in a row on a track without merging, crossing or diverging track you can remove the middle one.
I use a simpler rule that doesn't conflict with the above to decide which type of signal to use:
If a train is allowed to stop place a normal signal otherwise use a chain signal.

mrvn
Smart Inserter
Smart Inserter
Posts: 3411
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by mrvn » Mon Jun 24, 2019 9:20 am

Trebor wrote:
Sun Jun 23, 2019 7:44 pm
mrvn wrote:
Mon Jun 17, 2019 1:07 pm
The rules are simple:

1) You can place chain signals everywhere (see 4 why you don't).
2) You should have a (chain) signal before 2 tracks merge or cross and after 2 tracks diverge or cross.
3) You can change a chain signal to full signal when there is enough space for a train to clear this signal and stop at the next signal and having it stop there doesn't bother you (generally that means it doesn't halt on top of a junction but sometimes that is OK. Halting on top of a crossing is generally never OK).
4) If there are 3 chain signals in a row on a track without merging, crossing or diverging track you can remove the middle one.
I use a simpler rule that doesn't conflict with the above to decide which type of signal to use:
If a train is allowed to stop place a normal signal otherwise use a chain signal.
That is rule 3. That rule alone doesn't tell you where to place signals, only what kind.

User avatar
BattleFluffy
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Sun Mar 31, 2019 4:58 pm
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by BattleFluffy » Thu Jun 27, 2019 8:57 pm

mrvn wrote:
Mon Jun 24, 2019 9:20 am
The rules are simple:
Trebor wrote:
Sun Jun 23, 2019 7:44 pm
I use a simpler rule that doesn't conflict with the above to decide which type of signal to use:
mrvn wrote:
Mon Jun 17, 2019 1:07 pm
That is rule 3. That rule alone doesn't tell you where to place signals, only what kind.
I just wanted to chime in that I think it's better to spend time learning and thinking about what rail and chain signals actually do, and how they fundamentally work... Rather than learning a set of "rules" recommended by others in the community.

If we all just blindly followed the same rules then there would never be any new signalling innovations. :>

mrvn
Smart Inserter
Smart Inserter
Posts: 3411
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Friday Facts #299 - Everything is more complex than expected

Post by mrvn » Mon Jul 01, 2019 12:45 am

BattleFluffy wrote:
Thu Jun 27, 2019 8:57 pm
mrvn wrote:
Mon Jun 24, 2019 9:20 am
The rules are simple:
Trebor wrote:
Sun Jun 23, 2019 7:44 pm
I use a simpler rule that doesn't conflict with the above to decide which type of signal to use:
mrvn wrote:
Mon Jun 17, 2019 1:07 pm
That is rule 3. That rule alone doesn't tell you where to place signals, only what kind.
I just wanted to chime in that I think it's better to spend time learning and thinking about what rail and chain signals actually do, and how they fundamentally work... Rather than learning a set of "rules" recommended by others in the community.

If we all just blindly followed the same rules then there would never be any new signalling innovations. :>
That's called understanding the rules. :) And I forgot one rule: Never place 2 trains in the same segment.

There is still plenty of freedom to place signals even with the rules. The rules just prevent obvious deadlocks because a train stops in the middle of a crossing and such. The most obvious freedom is how many signals you place. It's a balance between resources (to build signals, time to place them and UPS) and performance.

Post Reply

Return to “News”

Who is online

Users browsing this forum: No registered users