Train Count without leaving train

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Kalistos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Jun 01, 2019 10:11 am
Contact:

Train Count without leaving train

Post by Kalistos »

TL;DR
Community needs possibility to exclude leaving train from Train Count in train stop, but default behaviour includes leaving train. It breaks a lot of ideas for smart train systems. So need to exclude leaving train from Train Count or support both variants via "Include leaving" or "Exclude leaving" checkbox for example.
What?
There are 2 ways:
1. Low priority: add new checkbox in "Read train count" section which allows to have both possibilities to count trains with leaving train and without leaving train. Check image in first comment.

2. High priority: remove leaving train from "Train count" in default behaviour. I think including leaving train is useless. Explanation of my opinion is below in "Why" section.

UPD: IMPORTANT MOMENT, for both realizations, leaving train should not be counted accurate at the same moment, when Train ID disappear from "Read stopped train". In other words, first frame: you have Train ID - 1234 and leading Train count - 4 on first station and leading Train count - 0 on second station, second frame: you have empty Train ID and leading Train Count - 3 on first station and leading Train Count - 1 on second station, where this leaving train leads.
Why?
This idea was already discussed in this bug topic: viewtopic.php?t=123091
But it was created as bug and was closed by Moderator with result "Works as intended, you can make suggestion".
This is suggestion.

Me and other players (from bug topic) wants to create smart train system based on "Train count" feature.

Below is description of my smart train system:
What we have:
- My base is planned as city blocks
- All train stops in city blocks are connected to one global circuit network based on radars
- All trains have only 1 permanent station (Depot) in there schedule and have 2 interraptions: 1 interraption for fuel and 2 interraption for cargo delivering (or fluid delivering for another train group).
- Cargo interration works next way: it adds 2 temporary stations to schedule, first for loading and second for unloading
- This system allows to not link trains directly to 2 stations. You can have only 2 train groups: first for cargo, second for fluid. So one cargo train can transfer different goods, according requests in global network.

How my smart train system works:
1 step - Start:
- There is iron ore mine, in the text will be "Mine"
- There is iron plate foundry, in the text will be "Foundry"
- Foundry block is just connected to network and requests 4 trains with iron ore. Also this requests set train limit for train stop.
- So we have 4 requests for iron ore in global circuit network. It's OK.

2 step - Getting request and leading to mine:
- Train in Depot see this requests and interraption is triggering and train gets 2 temporary station: loading on mine, unloading on foundry
- Train leading to mine
- Leading train affects on circuit logic on mine, which decrease global requests for iron ore by "Train count" feature in mine train stop.
- It becomes 3 requests in global network, because we have 4 (from foundry) minus 1 (trains leading to mine from "Train count")
- Train loading iron ore. It's still 3 requests = 4 - 1. It's OK.

3 step - Leaving mine and leading to foundry:
- Leading train affects on circuit logic on foundry, which decrease global requests for iron ore by "Train count" feature in iron plate train stop.
- And there is a big critical problem related to "Train count" behaviour.
- While train leaving mine train stop it is STILL counted on mine train stop and it is ALREADY counted on foundry train stop.
- It should be 3 requests in global network = 3 (foundry requires 4 trains minus 1 leading train to foundry from "Train count").
- Leaving train should not affect global requests for iron ore because it's already counted as leading train on iron plate station. BUT IT AFFECTS! We have extra decreased request.
- We have absurd situation, when single train counted 2 times!
- In fact we have 2 requests in global network = 3 (foundry (4 requests - 1 leading to foundry)) - 1 (leaving from mine). It's not OK!

4 step - Leaved mine and leading to foundry:
- Leading train affects on circuit logic on foundry, which decrease global requests for iron ore by "Train count" feature in iron plate train stop.
- We have 3 requests (foundry (4 requests - 1 leading to foundry)).
- Train unloading iron ore. It still 3 requests = 4 - 1. It's OK.
- Now foundry requres and requests only 3 trains with iron ore.

5 step - Leaving foundry and leading to mine:
- Leading train affects on circuit logic on mine, which decrease global requests for iron ore by "Train count" feature in mine train stop.
- And there we have the same critical problem!
- While train leaving foundry train stop it is STILL counted on foundry train stop and it is ALREADY counted on mine train stop.
- It should be 2 requests in global network = 3 (foundry requires 3) - 1 (trains leading to mine)
- But in fact we have only 1 request as the same single train counted 2 times! It's not OK!

In general I think it's clear how my system works.
And if you have only 1 request from foundry you can get -1 (negative) request during leaving train station. Which can lead to train system bugs.
In general my system works, but sometimes I catch some bugs. But smart train system of other players may be more sensitive to this issue.

So for correct system work I just need to have possibility for exlcusion leaving train from "Train count".


Let check discussion from original bug topic:

1. bountygiver wrote:
- What did you expect to happen instead? It might be obvious to you, but do it anyway!
The train count should drop to 0 when the train leaves the station, as per the description it says it outputs the number of train that is coming to the station including stopped trains, which should not include trains leaving the station.
I totaly agree with him. It's obvious behaviour!

2. Reimerboi wrote:
I agree with bountygiver.
This seems like a bug.

I'm trying to use the feature to automate the balance of requesting and supplying train stations.
Subtracting one from the requesting train stations whenever a train is en-route to supplying train station.
Then removing the request from the requesting train station when a train is en-route to that station.
Exactly what I described in my system! It's base of smart train system. So, if you want to make something similar you will think the same way!

3. Reimerboi wrote:
With the feature working as it currently is it's impossible to do this as the train count sums to two, even though only one train is on the tracks.
It's impossible to distinguish a train en-route versus a train blocking the station as the train ID also resets to 0 when the train is leaving.
In general my system works, but it works with bugs. Sometimes I catch trains which are stuck on loading train stop, because unloading train stop is closed, because it has 0 requests and it closed by "Train limit" feature.
So, sometime I unstuck in manual mode. Someone can decide that it's impossigle to play this way.

4. Muche provided blueprint where he trying to help with detecting train phases, like leading, entering, loading, departing, leaving, leaved.

I checked this blueprint, using train signals can help to decrease train leaving window from 2 seconds to 0.2 seconds and significantly complicates schema of combinators for each train station and doesn't remove leaving window at all.
So it's not the solution of this problem.

5. Next Nivertius checked Muche's blueprint also and wrote a lot of text with details.

And he found the same result. Using train signals it's not the solution. It has a lot of problems and bugs.

6. Next boskid (moderator) provided screen with example of railway schema as approve that leaving train should be counted.

In my humble opinion, this type of railway planning on screen shows very little experience in Factorio. In fact it's schema of Factorio beginner. Pro and advanced players can make correct railway system with avoiding such trains stucking without included leaving train in "Train Count".
And also, such beginners don't use circuit network yet, they learn base of game and maybe some arithmetic and decider combinators. But not "Train count" logic.
So, my opinion is including leaving train feature is useless for beginner, as they don't use it yet.
And including leaving train feature is also useless for pro players, as it doesn't work as expected for big smart train systems.
As result
I think removing leaving train from "Train count" will be usefull update for big train systems in Factorio.
Beginners have possibilities to solve train stucking by updates their railways and more smart base planning without using "Train count" logic at all.
But pro players can't solve their problem with their train system, while leaving train add count to "Train count".

But if you want to keep current behaviour in game, there is option to add additional checkbox like "Include leaving" or "Exclude leaving", where players can switch behaviour what they need.

Thanks a lot for your game!
Last edited by Kalistos on Wed Dec 17, 2025 6:26 am, edited 11 times in total.
Kalistos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Jun 01, 2019 10:11 am
Contact:

Re: Train Count without leaving train

Post by Kalistos »

12-16-2025, 16-48-06.png
12-16-2025, 16-48-06.png (178.94 KiB) Viewed 278 times
User avatar
nivertius
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Oct 17, 2015 9:35 am
Contact:

Re: Train Count without leaving train

Post by nivertius »

Yes, exactly, thank you for bringing this again.

I still stand by my opinion that trains that are stopped at the station with their condition met, but having all destinations full, should be counted as stopped at the station (counting towards train limit, being able to read its contents and signals, and having Train ID available). This is my preferred resolution as this would make the 'train limit' counting consistent with station circuits.

Also, I wouldn't try to insult mods here saying that their factorio experience, but the screenshot boskid provided didn't really convince me, as it really looks like a signaling problem (incorrect placement of a rail signal instead of chain signal on the right side of the red incoming train), and not a station configuration problem.

(edit) Also trains that are actively leaving the stations should not be counted towards the train count from the previous station that might not even be on their schedule anymore (as it could be temporary stop).
Kalistos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Jun 01, 2019 10:11 am
Contact:

Re: Train Count without leaving train

Post by Kalistos »

I wouldn't try to insult mods here saying that their factorio experience, but the screenshot boskid provided didn't really convince me, as it really looks like a signaling problem
It wasn't insulting mods) No, no, no, please))) English is not my native language) Sorry if I was misunderstood)
I'm pretty sure, that this screen was fast in-game implementation of idea, which boskid wanted to show for us. And this idea could be used by another beginner players, but not the real way boskid builds his bases.
Tertius
Smart Inserter
Smart Inserter
Posts: 1497
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Train Count without leaving train

Post by Tertius »

The image in the other thread is a perfect example for the reason why stations should release a reservation only after the current train left the area.

It contains a station with a train limit of 3. The area provides exactly 3 places for a train: one the station itself, 2nd the train at the top and 3rd the train at the right.
Under normal circumstances this works perfectly. There are always up to 3 trains on their way to the station or waiting in front of it. If the limit is full and 3 trains are there or waiting, the main line is free because all trains fit the station and the loop area.

Now it can happen the main line gets congested. In the image, look at the tracks with the green arrows. Imagine a train is halting here because there is a congestion to the right. Imagine there are also 3 trains in the station area: one is being loaded, 2 are waiting. All fine so far. Congestion but no deadlock.
Now imagine the train is full and it starts to leave. In the original implementation the reservation is freed in this moment and there is one free slot again. Imagine a train is dispatched immediately because of this and driving to the station. The train that just got empty starts to leave but isn't able to leave because of the congestion I described. It will halt and wait at the position we see the blue train in the image until the congestion is gone.

Meanwhile the new train arrives. It will try to enter the loop but will come to a halt where the red train in the image is seen. Now the congestion resolves, however the blue train cannot leave, because the red train is blocking. The situation cannot resolve itself, it's a deadlock.

The loop area is correctly signaled. The station has limit 3, and there is space for 3 trains. Not for 4. But it would temporarily need 4 if there is congestion on the main line. The new implementation in 2.0 is resolving this by only freeing the reservation if the train leaving the station actually left the station area, so there is one space again for the new train that's coming due to the new free slot.

You can change the signal next to the 1st wagon of the red train to a chain signal and the deadlock will not happen because the red train would completely wait outside on the main track. However, this situation can happen with different track layouts on a larger scale involving more trains and it wouldn't be feasible to resolve with a chain signal. Putting a chain signal here is a workaround, not a solution to the problem.
Kalistos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Jun 01, 2019 10:11 am
Contact:

Re: Train Count without leaving train

Post by Kalistos »

Tertius wrote: Tue Dec 16, 2025 9:38 pm The image in the other thread is a perfect example for the reason why stations should release a reservation only after the current train left the area.

It contains a station with a train limit of 3. The area provides exactly 3 places for a train: one the station itself, 2nd the train at the top and 3rd the train at the right.
Under normal circumstances this works perfectly. There are always up to 3 trains on their way to the station or waiting in front of it. If the limit is full and 3 trains are there or waiting, the main line is free because all trains fit the station and the loop area.

Now it can happen the main line gets congested. In the image, look at the tracks with the green arrows. Imagine a train is halting here because there is a congestion to the right. Imagine there are also 3 trains in the station area: one is being loaded, 2 are waiting. All fine so far. Congestion but no deadlock.
Now imagine the train is full and it starts to leave. In the original implementation the reservation is freed in this moment and there is one free slot again. Imagine a train is dispatched immediately because of this and driving to the station. The train that just got empty starts to leave but isn't able to leave because of the congestion I described. It will halt and wait at the position we see the blue train in the image until the congestion is gone.

Meanwhile the new train arrives. It will try to enter the loop but will come to a halt where the red train in the image is seen. Now the congestion resolves, however the blue train cannot leave, because the red train is blocking. The situation cannot resolve itself, it's a deadlock.

The loop area is correctly signaled. The station has limit 3, and there is space for 3 trains. Not for 4. But it would temporarily need 4 if there is congestion on the main line. The new implementation in 2.0 is resolving this by only freeing the reservation if the train leaving the station actually left the station area, so there is one space again for the new train that's coming due to the new free slot.

You can change the signal next to the 1st wagon of the red train to a chain signal and the deadlock will not happen because the red train would completely wait outside on the main track. However, this situation can happen with different track layouts on a larger scale involving more trains and it wouldn't be feasible to resolve with a chain signal. Putting a chain signal here is a workaround, not a solution to the problem.
Yes, I understand what you mean.
But it should be noted that the railway station on the image is not even connected to circuit network.

Please, take on account.
Players who builds railways this way don't use circuit networks yet, because they are beginners. And they will get trains stuck anyway.
And again, these players have possibility to just improve their railway for fixing their problem, they can increase lenght of railway before station, they can add some section with parallel railways for keeping leading trains, and also about this current image, they just can replace only one rail signal to rail chain signal for fixing this issue.
But players who want to build smart train system don't have such possibilities to fix their problems.

And I provided the option to keep the current behavior with checkbox. Which will be enaugh for beginners, and for advanced players.

Why are you worried about beginners who will never face this situation (because they don't use "Train count" yet), but not worried at all about advanced players who have encountered this problem and can't solve it?
Last edited by Kalistos on Tue Dec 16, 2025 10:17 pm, edited 5 times in total.
Kalistos
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sat Jun 01, 2019 10:11 am
Contact:

Re: Train Count without leaving train

Post by Kalistos »

BTW

Image we are talking about
12-17-2025, 01-02-31.png
12-17-2025, 01-02-31.png (2.63 MiB) Viewed 146 times
User avatar
EvilPLa
Long Handed Inserter
Long Handed Inserter
Posts: 56
Joined: Sat Nov 14, 2020 7:26 am
Contact:

Re: Train Count without leaving train

Post by EvilPLa »

Without reading ALL the text, +1 from me for excluding the leaving train from traincount as soon as the train id ("T") is cleared.
Wise men speak because they have something to say Fools because they have to say something. (Plato)
Post Reply

Return to “Ideas and Suggestions”