Train pathing through station

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Train pathing through station

Post by Mimos »

Hi,

as far as I understand https://wiki.factorio.com/Railway/Train_path_finding trains should not path through unused stations if nothing extraordinary happens. But still I have this issue quite often. As you can see below, the light blue has a train station but still the trains like to path through it. Even adding a 2nd station to increase the penalty doesn't help.
Stupid route.jpg
Stupid route.jpg (317.87 KiB) Viewed 8080 times
This happens to me quite often in a complicated station which causes many congestions. Maybe this issue is somehow caused by my long train paths (several thousand tiles)?
Does anyone have a solution, or is this maybe a bug that I should report?

Thanks for your help.

Jap2.0
Smart Inserter
Smart Inserter
Posts: 2339
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Train pathing through station

Post by Jap2.0 »

There are no circuits on the main rail and both stations are enabled?
There are 10 types of people: those who get this joke and those who don't.

sillyfly
Smart Inserter
Smart Inserter
Posts: 1099
Joined: Sun May 04, 2014 11:29 am
Contact:

Re: Train pathing through station

Post by sillyfly »

Could there be a signalling issue with the part of the track aside the station?
What happens if you completely break the station part off? Do you get any "No Path" errors?
It may help to upload your save file, as it is hard to see all the details just form the screenshot.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

Jap2.0 wrote:There are no circuits on the main rail and both stations are enabled?
I got no circuits controlling signals at all. Both stations are enabled.
sillyfly wrote:Could there be a signalling issue with the part of the track aside the station?
What happens if you completely break the station part off? Do you get any "No Path" errors?
I don't think there is a signalling issue, most trains just drive straight and skip the station.
Also no "No Path" errors.

Savegame:
Station issue small.7z
(18.49 MiB) Downloaded 105 times
You need to extract it and then repack is as a .zip, this saves some file size for up/downloading. I also used the ups-up-mod to reduce the size even further.

If you want to find the station, just take a train to: "Iron Ore 15 Bhf"
So you may take a look at the station. The error is pretty rare in this place though, not a lot of trains driving there.

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Train pathing through station

Post by Zavian »

If there is a train on the straight section, then the path-finder might consider the longer route through the station as better. Typically though I would only expect that to happen if the 'loop' was otherwise empty, which means it shouldn't cause delays for a train that wants to use the station.

This post viewtopic.php?f=194&t=52544 has a setup that is designed to solve your porblem. (I haven't used it myself, but Aaargha generally knows what he is talking about with the train network).

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

As far as I understand the penalty for another train, especially if it is a long distance away, should not be higher than the penalty for a station.

Also, even if the loop/station is empty at the time of the pathfinding, another train may still arrive before the train taking the detour. This happens sometimes in my tightly packed main station with one train that stops for a long time, the "wrong" train blocks the main track, a long queue builds up end everything comes to a standstill.


Thanks for your link, I'll give it a try. although I don't think it will help, considered a station should give 2k penalty, a signal, that is red by circuit, only 1k. At least it's a pretty nice Idea, though.
Update: I overlooked the chain signal at the station entrance, it should probably work. Although queues requires a dummy station.
Last edited by Mimos on Mon Nov 13, 2017 12:33 am, edited 2 times in total.

Zavian
Smart Inserter
Smart Inserter
Posts: 1641
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: Train pathing through station

Post by Zavian »

Well mrvn also described his approach to solving the same problem in that thread I linked.

Jap2.0
Smart Inserter
Smart Inserter
Posts: 2339
Joined: Tue Jun 20, 2017 12:02 am
Contact:

Re: Train pathing through station

Post by Jap2.0 »

Yeah - the penalty for a full block is 2*length, which shouldn't be a penalty of more than a few hundred here. Each station adds a penalty to 1000.
There are 10 types of people: those who get this joke and those who don't.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

I think the penalty of a station is even 2k. A signal red by circuit is 1k according to https://wiki.factorio.com/Railway/Train_path_finding.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

Zavian wrote:This post viewtopic.php?f=194&t=52544 has a setup that is designed to solve your porblem.
Well, in my post before I overlooked the chain signal at the entrance to the train station track. After some test it looks like this still does not prevent bad pathing but it might prevent the train to enter if it actually arrives. Although designing queues requires one dummy station for each entry path.

I also have a savegame where a bad path is planned less than 1min after loading. It still is changed again a few seconds later. I can provide it in case the devs are interested.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Train pathing through station

Post by eradicator »

You say that your problem is that trains "path through" the sation instead of going around it. But i'm guessing your problem is actually trains blocking the whole track when a train attempts to path through the station in a situation where the station is already occupied. Because if the station wasn't occupied a train driving through it at full speed would not pose any problems. So ...based on that assumption of your problem, i think you can simply solve it by encasing the whole parralel tracks section into a singular chain signal block (compressed example below). That way any train attempting to pass the block will wait before the block and then use whichever side of the track is free. Hopefully resulting in trains more often using the shorter track that doesn't get the 2K Station penalty. (Btw, yea. it's 2K not 1K as some ppl say)
chain-station.jpg
chain-station.jpg (175.2 KiB) Viewed 8028 times
If you have similar problems on larger setups you might want to consider reading more about the magic of signals (or call me an idiot for being completly wrong :P).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

eradicator wrote:You say that your problem is that trains "path through" the sation instead of going around it. But i'm guessing your problem is actually trains blocking the whole track when a train attempts to path through the station in a situation where the station is already occupied.
Yes, you are right. So a train passing through an empty station is still ugly, but I can live with it.

Thanks for your solution. I like it, because it is quite simple. Although stations using a queue or even a stacker require more complicated solutions (as suggested in the previous posts).

Xeorm
Fast Inserter
Fast Inserter
Posts: 206
Joined: Wed May 28, 2014 7:11 pm
Contact:

Re: Train pathing through station

Post by Xeorm »

I know it's also the equivalent of asking if the computer is plugged in, but you are playing with the latest version right? Non-experimental builds shouldn't have the station pathfinding increase.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

Xeorm wrote:I know it's also the equivalent of asking if the computer is plugged in, but you are playing with the latest version right? Non-experimental builds shouldn't have the station pathfinding increase.
I'm using 0.15.37 which is the newest stable version as of now. Starting with 0.15 the station penalty should be applied according to https://wiki.factorio.com/Railway/Train_path_finding.

User avatar
impetus maximus
Smart Inserter
Smart Inserter
Posts: 1299
Joined: Sat Aug 20, 2016 10:07 pm
Contact:

Re: Train pathing through station

Post by impetus maximus »

Mimos, aside from the chain signal, did you try the entire solution Zavian linked to?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Train pathing through station

Post by eradicator »

impetus maximus wrote:Mimos, aside from the chain signal, did you try the entire solution Zavian linked to?
I missed that post at first. But that really is a nice solution. I experiemented before with that kind of block-detection but didn't have a good usecase for it :). Aesthetically it's not very pleasing though, sadly.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

impetus maximus wrote:Mimos, aside from the chain signal, did you try the entire solution Zavian linked to?
Yes, I did. At least if I didn't overlooked something. I made some screenshots, right before the train plans the worong path and right after it. Sadly it's pretty zoomed out and thus a little hard to see. You cannot see the circuits, but you can see that the controlled signal is red both times. You can also see a train passing by which is probably causing this mess.
Before after.png
Before after.png (549.82 KiB) Viewed 7918 times

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: Train pathing through station

Post by aaargha »

I think I've figured out what is happening. The reason that the path through the station becomes cheaper is that the train on the main path is in the arrive_station state. From what I can tell from some testing the major part of the "train is waiting at station" penalty, which is huge for most wait conditions (I got bored with testing at about 200k), is also applied for that state and not only for wait_station.

What happens is that as a train is calculating its path another train is on the main line outside the loop station and is braking for entering a nearby station (they start really far away). As the penalty for the braking train is gigantic the path through the station is shorter. As far as I can tell from trying your save, if the train is only passing by it does not cause this behaviour.

Unfortunately it's hard to get around this problem in a nice way, though placing this contraption at the split before the stations might help. Some uglier alternatives include moving the stations far away from the main line so the trains are off the main line when they change to arrive_station. Another ugly solution would be to add an additional train stop before the final stop that trains would wait at for 0 seconds, this would remove the excessive penalty.

There are already changes planned to how trains work for 0.16 but I'll do some testing to try to confirm this behaviour and then perhaps file a bug report. (EDIT: Bug report here for those interested)

Mimos
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Mon Nov 07, 2016 5:15 pm
Contact:

Re: Train pathing through station

Post by Mimos »

Thanks for your explaination! You are right, the coal train just starts braking when it's on this intersection.

But how can you see the exact state of a train? I looked at the color of its "show-train-stop-point" indicator, but the names you use suggest you know another way.

aaargha
Filter Inserter
Filter Inserter
Posts: 330
Joined: Wed Dec 07, 2016 8:35 am
Contact:

Re: Train pathing through station

Post by aaargha »

I'm using

Code: Select all

/c game.player.print(game.player.selected.train.state)
to see which entry from the list here it is (0 based) while hovering over a train. 6 is arrive_station and 7 is wait_station.

The Lua API holds a lot of goodies once you know where to look :)

I'm thinking of making a mod that would change the colours of trains depending on which state they're in so that it's easier to debug these kinds of issues. It shouldn't be that hard, but we'll see.

Post Reply

Return to “Gameplay Help”