Add functionality to limit the number of incoming trains per station.

Suggestions that have been added to the game.

Moderator: ickputzdirwech

ruspartisan
Burner Inserter
Burner Inserter
Posts: 15
Joined: Mon Jul 15, 2019 7:53 pm
Contact:

Add functionality to limit the number of incoming trains per station.

Post by ruspartisan »

TL:DR
Add LTN-like functionality that limits the number of trains that can have a particular station (out of many with the same name) as a destination.
OR
Add some more signals for trains and stations so players can implement the limit themselves.
What
The easiest (for a player, I mean) way would be to have a configurable signal limit how many trains can have this particular station out of many with the same name as their current destination, so first N trains will go to this station, but for others it's effectively disabled and the station gets re-enabled for them only when the train leaves the station or some of the trains that had locked it's place in a queue decided to repath to some other station with the same name.
PROS: Very easy for the player.
CONS: Some may say it's too OP: effectively you make many vanila train control circuits obsolete, but the player still needs to dispatch trains only when there is demand.

Another, idea that is more difficult to implement (both for the player and for the developers):
1) Each station can provide a signal how much trains have it as their current destination
2) When leaving the current station train provide for a couple of ticks it's destination id signal through the current station. Player checks this signal, checks how many trains is the destination awaiting already, and send a signal to the train to wait more or proceed. If the train gets "wait signal", it tries to recalculate it's path to another station with the needed name once every N seconds.
3) Player should have some checkbox in a train schedule GUI that enables/disables choosing another destination when already on route.
PROS: Probably not-so OP as it needs more circuitry/knowledge
CONS: Worst-case scenario: you need a new wire signal for each station for providing incoming trains count, and there is a limited number of wire signals. Not clear what signal should the train provide as a destination station ID (probably it can be the same signal as a station uses). More things to implement. Doesn't sound very intuitive for a new player.
Why
Designing rail systems is one of the most interesting part of the game for me, and I really like playing with LTN mod. I know there are some vanila-train circuit networks with similar goals, when you have N stations with the same name providing materials, and a train can go to whatever station is open, but to my knowledge all of those have some problem with a situation when, say, you have 16 trains for delivering green circuits, waiting in the depot, and then one station can provide them, and suddenly all 16 trains decide to go to this station.

HTN, as far as I know, has something like this: if there is one train load available at any of the provider stations, allow only one train to exit depot, 5 loads - 5 trains will be dispatched, but even if these 5 loads are distributed over 5 provider stations all 5 trains will go to the nearest station at first and only when the first train arrives, signal-controlled rail signals will go red severely penalizing paths through this station 4 trains will go to the next provider.

As you can imagine, it makes designing stackers difficult when you don't know how many trains can arrive at the station. Worst-case scenario - all of them, which is OK if there are 2-3 trains for this product and very inconvenient if there are 16 trains.

LTN has a special signal that limits the maximum number of trains that can be sent to a particular station, therefore you can design stackers much easier.

To my knowledge you can't really implement this functionality in Vanila (at least in a useable way) because you don't have enough information: you can't read which train station out of many with the same name is train has as it's destination, you don't know how many trains already have any particular station as a destination, etc.
User avatar
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ptx0 »

yep, as far as 'logistical challenges' go, trains already have plenty of them without adding in an arbitrary blindness to whatever is coming its way.

i.e. have a "Trains on the way" signal coming from the station if we check a box to output this signal.
Memesicle Kickflip
Burner Inserter
Burner Inserter
Posts: 6
Joined: Thu Feb 27, 2020 5:19 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by Memesicle Kickflip »

If you connect a train stop with a circuit wire, it can be set to

Code: Select all

send train ID (T)
enable/disable (T = 0)
hold my beacon
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

Memesicle Kickflip wrote: Thu Mar 19, 2020 4:35 am If you connect a train stop with a circuit wire, it can be set to

Code: Select all

send train ID (T)
enable/disable (T = 0)
That's true, and there are quite some more ways to smart this up (I got that you posted an easy-to-get-your-point-example). I once liked to use delayed self-deactivating stations with few exit-locked waiting bays (3 trains in = 1 in station + 2 on hold, 3rd+ will skip and reroute). But nowadays I number the stations and send the trains to very specific stations.

But the constant deactivation of target stations from trains en route causes massive rerouting and thus unnecessary traffic.


+1 for the OP
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ssilk »

If you want feature like LTN, why don’t you use LTN? 8-)
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
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ptx0 »

ssilk wrote: Sun Mar 22, 2020 8:36 am If you want feature like LTN, why don’t you use LTN? 8-)
can be done more efficiently without Lua scripting if implemented in C++.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ssilk »

I play now some years with LTN and CPU was never a problem with LTN.

More problems with just too much trains ... from my last world I found out that more than 600 trains slows Factorio down a bit. :)
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
ptx0
Smart Inserter
Smart Inserter
Posts: 1507
Joined: Wed Jan 01, 2020 7:16 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ptx0 »

ssilk wrote: Sun Mar 22, 2020 7:06 pm I play now some years with LTN and CPU was never a problem with LTN.

More problems with just too much trains ... from my last world I found out that more than 600 trains slows Factorio down a bit. :)
anecdotal evidence, though - you can see measurable CPU use from LTN's Lua scripting in the debug output.

enable debug logging and watch it write to disk - those are all the updates it's processing all the time.
gGeorg
Filter Inserter
Filter Inserter
Posts: 436
Joined: Wed Jun 19, 2019 8:06 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by gGeorg »

ptx0 wrote: Sun Mar 22, 2020 6:39 pm
ssilk wrote: Sun Mar 22, 2020 8:36 am If you want feature like LTN, why don’t you use LTN? 8-)
can be done more efficiently without Lua scripting if implemented in C++.
More over, LTN is too complex. Iinstall whole mode becouse of one critical feature calls for core game update.
netmand
Filter Inserter
Filter Inserter
Posts: 302
Joined: Wed Feb 22, 2017 1:20 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by netmand »

This will never happen. You're going to have to create a new paradigm to replace the, "lots of trains on the same schedule" methodology.
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by ssilk »

ptx0 wrote: Sun Mar 22, 2020 7:28 pm
ssilk wrote: Sun Mar 22, 2020 7:06 pm I play now some years with LTN and CPU was never a problem with LTN.

More problems with just too much trains ... from my last world I found out that more than 600 trains slows Factorio down a bit. :)
anecdotal evidence, though - you can see measurable CPU use from LTN's Lua scripting in the debug output
I never said it will not be measured, and at the same time with 600 trains that’s still the smallest impact. :)

@gGeorg: yes, LTN is too complex. :) One simple construction failure and you can produces kilometers of deadlocks , because a station requests too much trains. The original idea was a lot simpler than it is now. But you can reduce the complexity a lot if you just play with fixed length trains. LCC trains (1 loco, 2 cargo wagons) seem to be a nice compromise if you want to transport more than just ores and plates. But you need huge train stations.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

---

The "solution" shown in this post is not working. I did not choose the settings correctly: I got too few trains, and their timing was all the same. By adding more trains and ramdomising their programming, the system broke. But even without that mistakes, it did not work as proposed. The trains still do not repath when already stopped.

I reduced the original post at some extent.
---

Setup:
I increased the length of the waiting bays to add rail signals just before the chain signals at the exit of each lane. These additional rail signals
are connected by wire to be used as sensors to detect if the lane is occupied. Let's say there are 5 waiting bays lanes, so when every lane is occupied, RED with value of 5 is send.
Instead of the typical chain signal infront of the waiting bay, I used a rail signal That rail signal is set to Close Condition: RED = 5.

One would suggest, that when the rail signal at the entrance is red, trains would still head towards the waiting bay and wait on the tracks before it. In fact, they will do just this, when there is a -unwired- rail signal infront of the waiting bay.
But when this rail signal set to red by wire condition, incoming trains actually -do- repath and will no longer head towards that waiting bay.

The problem is, that often trains will be to fast to stop at the chain signal before the crossing, when the rail signal after the crossing is set to red. Then they stop will stop right on the crossing and clog it, before heading further into the waiting bay, clogging the entire waiting bay. From time to time you can see the "no path" info floating above it, proving the initial finding. On the positive side, this is not that bad: it just means another train in the waiting bay. Every train after the stuck one will repath.

Blueprint string for testing setup inlcuding trains and fuel.
Last edited by tamanous on Wed Apr 22, 2020 6:40 pm, edited 6 times in total.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3619
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by mmmPI »

there is this topic viewtopic.php?f=5&t=80501 started from a discussion in an FFF.

the title is : Request: Max number of trains for stations. similar suggestion, this one boskid took quite some time to test and answer.

In this topic are referenced other similar suggestions : 64162 70248 56375 67740

I would tend to think this won't get implemented.
Last edited by mmmPI on Tue Apr 21, 2020 8:26 pm, edited 1 time in total.
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

Nice, thank you.
User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by disentius »

Why would you close that signal with a wire? that is what chain signals are for.
If you replace the wired railsignal with a Chain signal, trains will not clog the intersection.
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

Let's say the waiting bay has the 5 lanes as shown in the screenshot. Let's further imagine that there are 20 trains going to that waiting bay. The problem is, when the 5 lanes at the waiting station are full, 14 trains (one is at the station behind the waiting bay) will wait on the railroad before the waiting bay and hinder all other trains that want to drive through.

You want to repath the 14 trains to go somwhere else. Forcing to repath could be done by deactivating the station they are heading towards, too.


I do not understand the logic of trains choosing a station, except that they prefer the closest one. What I can see while watching this setup for one or two minutes is,that instead of going to the free station that is further away, the trains wait until the waiting bay is empty to enqueue there.
User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by disentius »

Hm... I think I dont understand your point then. Was referring to your test setup.
I believe it is covered by this rule on the wiki:
2020-04-22 14_44_37-Railway - Factorio Wiki.png
2020-04-22 14_44_37-Railway - Factorio Wiki.png (17.16 KiB) Viewed 22958 times
https://wiki.factorio.com/Railway/Train_path_finding
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

Yeah, you're right. There's still something off.

But thanks again for pointing to the problem: one often needs to repath trains that are currently stopped.
tamanous
Fast Inserter
Fast Inserter
Posts: 138
Joined: Wed Aug 10, 2016 8:35 am
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by tamanous »

Disabling the station with Enable Red < [number of waiting bay lanes -1 ] works better, as it seems to force even stopped trains to repath.

This time I did some more testing and ran in the expected problem, but did not find any other problems: when the number of trains exceeds the number of waiting bay lanes, it is possible that all waiting bay lanes are occupied and thus all all trains get a No path.
Last edited by tamanous on Wed Apr 22, 2020 9:52 pm, edited 2 times in total.
User avatar
disentius
Filter Inserter
Filter Inserter
Posts: 694
Joined: Fri May 12, 2017 3:17 pm
Contact:

Re: Add functionality to limit the number of incoming trains per station.

Post by disentius »

tamanous wrote: Wed Apr 22, 2020 12:17 pm ...
I do not understand the logic of trains choosing a station, except that they prefer the closest one. What I can see while watching this setup for one or two minutes is,that instead of going to the free station that is further away, the trains wait until the waiting bay is empty to enqueue there.
It is a bit more complicated than that. again, here: https://wiki.factorio.com/Railway/Train_path_finding

Trains calculate their path based on lowest cost. That is not the same as shortest path. Complications are the penalties for various conditions. Also, the train calculates its path before it leaves its origin station. in a moderately busy train network that condition changes before it reaches its destination. that is why there are so many path recalculate rules lower down.
Post Reply

Return to “Implemented Suggestions”