Allow trains to path around blocked segments by pathing through empty stations

Ideas that are too old (too many things have changed since) and ones which won't be implemented for certain reasons or if there are obviously better suggestions.

Moderator: ickputzdirwech

Post Reply
j3robins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu May 11, 2017 1:16 am
Contact:

Allow trains to path around blocked segments by pathing through empty stations

Post by j3robins »

I noticed a weird & unnecessary bottleneck in my train network that I initially thought was a bug and has had me reviewing the train path finding rules here: https://wiki.factorio.com/Railway/Train_path_finding

In my network I have trains which livelock (that is, they wait on the main line until the destination station is free). Trains _could_ path around the livelocked train but refuse to because of the following rule:

Code: Select all

When the path includes a train stop that is not the destination -> Add a penalty of 2000
This results in weird paths that intuitively (as a human) there's an obvious solution to, but the pathing logic will take 5-6 minutes before identifying the bypass.
The second train is waiting for the first train to leave the station. Meanwhile the third train is waiting for the second train instead of going around it.
The second train is waiting for the first train to leave the station. Meanwhile the third train is waiting for the second train instead of going around it.
path_with_station.jpg (597.75 KiB) Viewed 3489 times

After scrutinizing the rules I find a few odd ones:

Code: Select all

When the path includes a train stop that is not the destination -> Add a penalty of 2000.
When the path includes a train stop with a train stopped in it -> Add a penalty of 500.
When the path includes a train that doesn't have a path -> Add a penalty of 1000
Currently, the pathing logic would rather take you through a dead train than an empty station. And for some reasons empty stations have a higher penalty than occupied stations.




Here's my suggested improvements:
1. Reduce the empty station penalty. A penalty of 500 would allow pathing through an empty station to get around: circuit controlled red light, stopped train with no schedule, and train with no path.
2. Increase the stopped train penalty from 0.1/tick to 1/tick. This change along with #1 would allow a train to path through an empty station around a train that has been stopped for ~6 seconds instead of 5-6 minutes currently.
3. Increase the occupied stations penalty. A penalty of 2000 makes sense here as occupied stations should be avoided unless it is the destination. Assuming the penalties for empty & occupied stations are additive this change along with #1 will keep the penalty static (2500).

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 228
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by Nosferatu »

When building a train station branched of your mainline you usually want it to be accessible from all directions.
But what you don't want is that all your trains start using it if they want to make U Turns for some reason.
That's why that penalty is that high and I think it should stay that way ;)

j3robins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu May 11, 2017 1:16 am
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by j3robins »

When building a train station branched of your mainline you usually want it to be accessible from all directions.
But what you don't want is that all your trains start using it if they want to make U Turns for some reason.
That's why that penalty is that high and I think it should stay that way
The stations in the screenshot have a switching station immediately before them so they are accessible from all tracks. I think I'm not understanding what you mean by the station should be accessible from all directions.

When you say U Turns do you mean the train reverses direction? I thought that could only happen after the train stopped at a destination station in which case the station penalty would not contribute to switching directions.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by ssilk »

The problem here is, that you apply all stops in a line. Why don’t you make the stops in parallel, like everybody else does? :) is there a good reason? Because I see only disadvantages in this lined up layout: even with your new rules you suggest, the trains will sometimes need to wait and it tends to create hard deadlocks.

Also in real live: you will not find station layouts in line, because of the above mentioned disadvantages.

See
https://www.google.com/search?q=factori ... ion+layout (-> pictures, they are all parallel layouts, nobody comes to the idea of doing that in a line).

For example (I searched a bit for similar layouts, please ignore that deadlock situation):
Image
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 228
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by Nosferatu »

@j3robins: I wasn't talking about your stations but about those most commonly used.
If your suggestion is accepted stations like the one silk posted will get the problems I described above.

j3robins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu May 11, 2017 1:16 am
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by j3robins »

The screenshot is a demonstration of the problem, not a recommended train station setup ;)

What I'm trying to illustrate is that if a train is stopped on the mainline for one of the three reasons mentioned then other trains will block behind that train rather than use a station to route around it. Obviously the best solution is to NOT have trains stop on the mainline but it's counterintuitive to me that a train refuses to route through a station and would rather queue up behind the train sitting on the main line.

j3robins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu May 11, 2017 1:16 am
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by j3robins »

Here's another example illustrating the point. That train blocking the mainline has to be there for 5 minutes before trains decide to path around it.
example2.png
example2.png (3.63 MiB) Viewed 3362 times

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by ssilk »

Then why is it stopped?

It makes no sense to have a train waiting on your “main line” and hope, that another train that goes around is faster. Because the train waits either for
- the signal before him to be free (because there is another train, that waits to continue etc.) or
- waits for a green signal to leave the main-line to load/unload stuff on a train stop.

In case 1 the passing is over, when the train wants back to the main-line. Bad idea, because that train does also hinder the trains in the train stop to leave the stop fast, so that it can be used by the next train following. Deadlock danger... so it is a good idea, that the trains don’t use the rails with train stop. Solution: keep the main line clean.

In case 2 I need to say, that you eventually have build you rails too narrow. Not using enough space, so that the train can leave the main line ASAP. Build bigger, let more space for the trains to leave the main line without waiting. Build extra lines around that bottleneck.

The penalties aren’t gonna be changed - I’m nearly sure of that, because it was a very long process (about 4 years) to come to the current penalty-weights, which are quite balanced out. The support the concept of a “main-line” or fast-path very well. The remaining issues - as you show one here - are definitely part of the game: find a solution to this problem yourself. :)

You can surely get help in the game-play-help-board.

And I think these penalties can be modded, but I’m quite sure, that if you play with that you will soon see, that the current balance is much better, because it enables a good mix between freedom and pressure. :)

j3robins
Burner Inserter
Burner Inserter
Posts: 17
Joined: Thu May 11, 2017 1:16 am
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by j3robins »

Then why is it stopped?
The three scenarios are:
1. circuit controlled red light
2. stopped train with no valid stops
3. train with no path

#1 can happen for lots of reasons - maybe a logic error in your circuit design
#2 is bad scheduling or maybe you added more trains than your station has capacity to handle (my situation and how I discovered this issue)
#3 can happen if you remove a segment or biters remove a segment or a stop is otherwise made inaccessible

For all 3, this will likely cause all trains to stop on your mainline until you fix the situation or 5 minutes pass.

In all three cases the train will still route around a stopped train - but the train must be stopped for 5 minutes. My suggestion is basically to reduce that wait time to 5 seconds. Maybe 5 minutes is the "correct" wait time based on other balancing that has been done. Based on FFFs it appears the devs discovered bugs that have been there for 3 years. I know a lot has gone into reworking & fixing bugs in the pathing for trains but I noticed this pathing scenario and maybe it is a side-effect or maybe it is intentional, of that I'm unsure and the devs should decide.

I guess I'm trying to highlight an unintuitive situation where the train sometimes passes the stopped train and sometimes doesn't and you have to dig deep into the rules & penalties for train pathing to understand why. Once I understood why, it is clear to me that you shouldn't expect trains to path through unoccupied train stops except in rare circumstances: manually controlled stopped train or automatic train without a schedule or train has been stopped for 5 minutes.

User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by ptx0 »

most of us spend a lot of time building rail so the things you're asking for specifically will not happen. i don't want trains filling up stations just because it was open while the mainline is blocked. this actually happens sometimes if a train runs out of fuel while the map is running overnight on a server - and it's really frustrating. i have to manually back trains out of stackers or play a game where i send trains on their merry way.

so many people have perfectly functional rail designs you can look at on youtube to see what you can do differently.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by ssilk »

j3robins wrote:
Fri May 14, 2021 7:49 pm
Then why is it stopped?
The three scenarios are:
1. circuit controlled red light
2. stopped train wwith no valid stops
3. train with no path

#1 can happen for lots of reasons - maybe a logic error in your circuit design
#2 is bad scheduling or maybe you added more trains than your station has capacity to handle (my situation and how I discovered this issue)
#3 can happen if you remove a segment or biters remove a segment or a stop is otherwise made inaccessible
That’s all quite irregular things. It’s completely ok to stop everything if that happens, because it’s the safest way to make things not so more worse. Routing around will probably make things very, very worse. That’s (one of the) the reason for this high penalty for train stops - as already explained.
For all 3, this will likely cause all trains to stop on your mainline until you fix the situation or 5 minutes pass.
The more trains wait, the higher the chance, that you see it sooner. :)
I guess I'm trying to highlight an unintuitive situation
Because it’s unintuitive for you doesn’t mean it’s for everybody unintuitive. ;)
For most people it’s quite clear, that taking a path over a train stop isn’t a good idea.
... where the train sometimes passes the stopped train and sometimes doesn't and you have to dig deep into the rules & penalties for train pathing to understand why. Once I understood why, it is clear to me that you shouldn't expect trains to path through unoccupied train stops except in rare circumstances: manually controlled stopped train or automatic train without a schedule or train has been stopped for 5 minutes.
There are mods, that alarm you, if trains stand still for x seconds.

https://mods.factorio.com/mod/TheFatController
https://mods.factorio.com/mod/SchallRailwayController
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Haladon
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun Mar 31, 2019 11:03 am
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by Haladon »

There is one obvious problem with OP's suggestion. If their train network is poorly designed that trains can stop in the middle of anywhere for >5 minutes, then what is preventing the train that will reroute through a station from stopping at that station. This will prevent legitimate use of that station and is in general a recipe for deadlocks.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Allow trains to path around blocked segments by pathing through empty stations

Post by ssilk »

After re-reading moved to not implement
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Post Reply

Return to “Outdated/Not implemented”