0.17 Train Station Behavior

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
marzolan
Burner Inserter
Burner Inserter
Posts: 13
Joined: Fri Aug 11, 2017 7:21 pm
Contact:

0.17 Train Station Behavior

Post by marzolan »

I feel like I'm going crazy. Did I miss something?

I used to have setups where multiple train stations had the same name and trains would go to the first available/unblocked station of the same name. In my first playthrough with 0.17 (currently 0.17.53), this behavior is not longer the same. Trains always attempt to go to the closest station whether it is blocked or not.

Is this different? Did something change? Was I just really lucky in the past that this worked how I wanted it to, or has it always been this way and I'm remembering what I dreamed it could be?

Any thoughts appreciated.
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: 0.17 Train Station Behavior

Post by slippycheeze »

marzolan wrote: ↑Sun Jul 07, 2019 4:59 pm I feel like I'm going crazy. Did I miss something?

I used to have setups where multiple train stations had the same name and trains would go to the first available/unblocked station of the same name. In my first playthrough with 0.17 (currently 0.17.53), this behavior is not longer the same. Trains always attempt to go to the closest station whether it is blocked or not.

Is this different? Did something change? Was I just really lucky in the past that this worked how I wanted it to, or has it always been this way and I'm remembering what I dreamed it could be?
I don't know why you are seeing what you are seeing, but I can tell you that multiple stations with the same name will (a) path a train to any station, and (b) select an unoccupied station, in 0.17

So ... whatever is going wrong, it isn't that the behaviour is impossible. Perhaps something about enabling/disabling stations or something has changed?
marzolan
Burner Inserter
Burner Inserter
Posts: 13
Joined: Fri Aug 11, 2017 7:21 pm
Contact:

Re: 0.17 Train Station Behavior

Post by marzolan »

Yeah, that's not what I'm seeing at all. I have 2 stations with the same name. They have circuit wire connections, but only for "Send to train" function - no enable/disable. But any train pointed at that station name insists on going to only one of the two locations from my main base (the closest one) and they just stack up behind each other. If I manually move the train closer to the other station, it goes just fine, but on return to base it will resume this "nearest only" behavior. if I change the names of the stations to be unique, there are no problems.

So I don't know. I can just live with dedicated trains and stops, but I'm not sure what's happening here.
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: 0.17 Train Station Behavior

Post by slippycheeze »

marzolan wrote: ↑Sun Jul 07, 2019 11:04 pm Yeah, that's not what I'm seeing at all. I have 2 stations with the same name. They have circuit wire connections, but only for "Send to train" function - no enable/disable. But any train pointed at that station name insists on going to only one of the two locations from my main base (the closest one) and they just stack up behind each other. If I manually move the train closer to the other station, it goes just fine, but on return to base it will resume this "nearest only" behavior. if I change the names of the stations to be unique, there are no problems.
If you post the save, someone enthusiastic might load it and see if they spot the problem.

That said, trains pick a path based on "least worst at the time I make the decision", and won't reevaluate that unless they pass, eg, a signal or something.

One of the contributors to badness is "a station on the line", another is "someone is using the station", and a third relevant one here is "distance."

If your first station has a short queue, and your second is very far away, it could be that waiting seems less worse to the train than travelling all that way.

I'd suggest you check out the wiki for details on the full range of penalties, make sure you have signals near the final decision point for using each station, and perhaps turn on the various path debugging options in the F4 debug menu to see if that sheds light on what is going on.
mrvn
Smart Inserter
Smart Inserter
Posts: 5877
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 0.17 Train Station Behavior

Post by mrvn »

The way stations are picked is by doing an A* search until the cheapest station is found. The wiki has the full list of costs but one factor is distance and the other if the station is occupied. Trains will only pick another station if the cost of the occupation of the nearest station outweighs the extra distance to the second station. Place the station too far away and trains won't go there.

The only way to force trains to go to other far aways stations is to disable the near one. You can do that with circuit logic so the station gets disabled when it has enough trains in the stacker or when the buffer chests become full. That's another puzzle to solve.
Zavian
Smart Inserter
Smart Inserter
Posts: 1649
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: 0.17 Train Station Behavior

Post by Zavian »

mrvn wrote: ↑Tue Jul 09, 2019 10:21 am Trains will only pick another station if the cost of the occupation of the nearest station outweighs the extra distance to the second station. Place the station too far away and trains won't go there.

The only way to force trains to go to other far aways stations is to disable the near one.
You can also use circuit controlled signals (and even dummy train stations) to add extra penalty to a station so that a more distant station becomes cheaper than the closer station.
mrvn
Smart Inserter
Smart Inserter
Posts: 5877
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 0.17 Train Station Behavior

Post by mrvn »

Zavian wrote: ↑Tue Jul 09, 2019 12:07 pm
mrvn wrote: ↑Tue Jul 09, 2019 10:21 am Trains will only pick another station if the cost of the occupation of the nearest station outweighs the extra distance to the second station. Place the station too far away and trains won't go there.

The only way to force trains to go to other far aways stations is to disable the near one.
You can also use circuit controlled signals (and even dummy train stations) to add extra penalty to a station so that a more distant station becomes cheaper than the closer station.
By "force" I mend get them to go there no matter what. Adding costs to the closest station to get it nearer to the further station works too, if you get the costs right and don't forget to update that with every station with the same name you add.
Zavian
Smart Inserter
Smart Inserter
Posts: 1649
Joined: Thu Mar 02, 2017 2:57 am
Contact:

Re: 0.17 Train Station Behavior

Post by Zavian »

mrvn wrote: ↑Tue Jul 09, 2019 12:17 pm By "force" I mend get them to go there no matter what.
Yeah I understood that. I just felt compelled to point out that Marzolan could also encourage them to pick the further station without forcing the issue by disabling stations.
mrvn wrote: ↑Tue Jul 09, 2019 12:17 pm Adding costs to the closest station to get it nearer to the further station works too, if you get the costs right and don't forget to update that with every station with the same name you add.
You can also do something dynamic. Eg build some circuit controlled signals on the approach to the stacker. Then for every train in the stacker set an approach signal to red.
mrvn
Smart Inserter
Smart Inserter
Posts: 5877
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 0.17 Train Station Behavior

Post by mrvn »

Zavian wrote: ↑Tue Jul 09, 2019 1:09 pm
mrvn wrote: ↑Tue Jul 09, 2019 12:17 pm By "force" I mend get them to go there no matter what.
Yeah I understood that. I just felt compelled to point out that Marzolan could also encourage them to pick the further station without forcing the issue by disabling stations.
mrvn wrote: ↑Tue Jul 09, 2019 12:17 pm Adding costs to the closest station to get it nearer to the further station works too, if you get the costs right and don't forget to update that with every station with the same name you add.
You can also do something dynamic. Eg build some circuit controlled signals on the approach to the stacker. Then for every train in the stacker set an approach signal to red.
Sounds easy. But it's not that easy. You have to set the signal to red to increase the cost of the station. But when a train approaches anyway you then have to let it pass. So you have to use a pair of signals. First one just reads the signal. The second you program to close when first signal == green and stacker-lane-1 filled. Repeat for lane-2, lane-3, lane-4. But what I tried so say was that if the other station is more than 1000m further than a single red signal won't suffice. You then have to double down and use 2 red signals per lane for the same effect.

That actually might be interesting to do even if the stations are near each other. Divert trains to the station with the least filled stacker.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3643
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: 0.17 Train Station Behavior

Post by mmmPI »

mrvn wrote: ↑Tue Jul 09, 2019 1:44 pm That actually might be interesting to do even if the stations are near each other. Divert trains to the station with the least filled stacker.
That is interestingly problematic as train repathing requires some adapted track designs, decent amounts of loop, quite unfriendly with 2 headed trains.

I have tried a complicated way to make a similar thing happen on a map by enabling the fullest station only, just to find out the fullest I had to wire up everything and compare the value with combinators, also stopping all inserter during the loop trough all outposts quantities not to mess up with the compare thing that was runnig in 15 or 20 ticks every 3 minutes or so. ( wasn't the wisest approach probably ).

I had many small coal outpost, and wanted to use them equally, and not the closest full first always.

My problem there was that if I wanted to refresh the quantity of the outpost more frequently, that would mean more train repathing, if a train was sent to a station and it needed like 3 minutes to reach it, I couldn't update the quantity faster than every 3 minutes. Else some station far away might never be reached since train would reroute to a closer opened full station before. It also mean that a station could disable when a train was close to it, because my comparator would find out just at this moment than another station deserved more priority due to being almost full. And this lead to a lot of problems of trains getting stuck as I didn't plan my network accordingly.

This is a bit different than what is explained in this post, buthas some similarities at the time I thought a bit about that.

It really depends on what is needed here. If the problem is between 2 stations, i would recommend linking them with wire and make it as easy as open one for X amount of time while the other is closed. Or open one, count X many trains going throught, then open the other one and force repath. ( simple but not too efficient/smart).

You will just need to create a rail layout that allow trains to reroute if a station close right before a train gets in. ( no double headed train terminus unless you add a loop at the end ).

If the problem is like me with many different station and a number that can scale, I would try to do differently. I would try to make a parking that has 10 train slots for example near the base. If one stations open on the map, let 1 train from the 10 at the parking to go get there. If another station open, let another train leave. And close first station after first train ( and park the 1rst train in parking and close its slot). so that second train repath to 2nd station.

Still pretty ok if station 2 is much closer than station 1 and opens just after it. In this case train 1 will arrive to station 2, and train 2 will repath to station 1. Not the correct order but less risk to have all your trains repathing at once like if you were to just enable/disable stations since the unused are parked in a depot instead of in the stacker of a station that will disable.

It would probably become a mess quite fast but it wouldn't require manual intervention to solve the request enventually. And would quiet itself when not needed.

It makes train do longer (unecessary) road, but i'm pretty sure this mess would end up spreading trains on average near the stations that opens more frequently.

The "divert trains to the least filled stacker" is probably more subtle since it doesn't enable/disable station, but require "tricky" calculation on the cost of segment for the pathfinding algorithm which you wouldn't need to worry at all with the messy approach.

Now if you can live with dedicated station, well that's the easiest by far :D
mrvn
Smart Inserter
Smart Inserter
Posts: 5877
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 0.17 Train Station Behavior

Post by mrvn »

I don't see any value in using stations evenly. Actually the opposite. If the coal mine has a train full of coal then enable the station. If that means the nearest coal mine is used more often so let it be. It will run out of coal and then the other mines will take up the slack. This way one mine will run dry fast while the others still have plenty of coal and you have time to build a new mine. On the other hand if you use mines evenly then you risk all of them running out at the same time. Suddenly you have no coal and have to build 10 new mines at the same time.

As for the risk of repathing I agree. That is a problem with enabling/disabling stations. But afaik changing signals won't cause a repath unless the train gets stopped at a red signal. So changing the signals based on the stacker fill shouldn't alter trains on the way often (unless your network is congested). Should influence mostly just new trains.
mmmPI
Smart Inserter
Smart Inserter
Posts: 3643
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: 0.17 Train Station Behavior

Post by mmmPI »

mrvn wrote: ↑Tue Jul 09, 2019 3:21 pm On the other hand if you use mines evenly then you risk all of them running out at the same time. Suddenly you have no coal and have to build 10 new mines at the same time.
I did prefer that option in that particular game, going for 1 trip , adding a dozens of 1.5/ 2 millions coal patch to garanty an roughly equal time travel for train and throuput of coal for the next 24 hours, rather than having to add a new mine every 2 hour for example. Or have the train time travel average increase a little by little as the closest mines gets depleted.

While my iron and copper patch at the same distance of the spawn were 40 millions. but i had very few :).

I had the average time travel per train roughly equal for the first 24 hours since it was switching station on/off.

Then the next day i don't want to be bothered about building mines, so I build 12 of them at once, and never go to that far far region again for the day. I add a few train to make up for the new average travel time. I was also building the miners as far as you can from each other while still covering every spot. spreading out pollution too.

(really idk the time, the quantities are the actual value i can tell but you get the idea)
mrvn wrote: ↑Tue Jul 09, 2019 3:21 pm But afaik changing signals won't cause a repath unless the train gets stopped at a red signal.
Same here, hence why I called it a more subtle approach, maybe the word is smarter, lighter, less brute force, more flexible, also a bit more fragile, or precise, sensible to more parameters, like distances and congestion.

Works better in the ideal case, but could require manual intervention in case one train is too stubborn to get rerouted because of distance or congestion, and end up trying to go in a full stacker ( unless you do the same kind of loop with rail that you would do with the enabling disabling station).
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: 0.17 Train Station Behavior

Post by slippycheeze »

mrvn wrote: ↑Tue Jul 09, 2019 3:21 pm I don't see any value in using stations evenly. Actually the opposite.
Me either, but people want what they want. :)

Seriously, though, OP, so much of this sounds like you really want the LTN or TSM mods to manage your trains, but you don't realise that yet.
User avatar
Ranger_Aurelien
Fast Inserter
Fast Inserter
Posts: 170
Joined: Thu Apr 25, 2019 1:53 pm
Contact:

Re: 0.17 Train Station Behavior

Post by Ranger_Aurelien »

mrvn wrote: ↑Tue Jul 09, 2019 3:21 pm As for the risk of repathing I agree. That is a problem with enabling/disabling stations. But afaik changing signals won't cause a repath unless the train gets stopped at a red signal. So changing the signals based on the stacker fill shouldn't alter trains on the way often (unless your network is congested). Should influence mostly just new trains.
From what I understand a more clear way to make sure trains get to a receiver station successfully is to route them through a checkpoint/waypoint (empty command) station before the final. That way they only choose a final station at the last moment.

Say train program station list (and you have say, six "Unload Coal" stations you can turn any off if full):
"Load Coal" (Wait 30 seconds)
"Unload Coal Waypoint" (no commandS) -- just before the "Unload Coal" stations themselves -- the train will not even slow down.
"Unload Coal" (Wait 30 seconds)

Then if you turn off one or more "Unload Coal" stations it won't check which one to target until it passes "Unload Coal Waypoint".
-
Ranger Aurelien
"Knowledge Brings Fear" -- Motto of Mars University, Futurama
mmmPI
Smart Inserter
Smart Inserter
Posts: 3643
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: 0.17 Train Station Behavior

Post by mmmPI »

Ranger_Aurelien wrote: ↑Tue Jul 09, 2019 5:28 pm
mrvn wrote: ↑Tue Jul 09, 2019 3:21 pm As for the risk of repathing I agree. That is a problem with enabling/disabling stations. But afaik changing signals won't cause a repath unless the train gets stopped at a red signal. So changing the signals based on the stacker fill shouldn't alter trains on the way often (unless your network is congested). Should influence mostly just new trains.
From what I understand a more clear way to make sure trains get to a receiver station successfully is to route them through a checkpoint/waypoint (empty command) station before the final. That way they only choose a final station at the last moment.

Say train program station list (and you have say, six "Unload Coal" stations you can turn any off if full):
"Load Coal" (Wait 30 seconds)
"Unload Coal Waypoint" (no commandS) -- just before the "Unload Coal" stations themselves -- the train will not even slow down.
"Unload Coal" (Wait 30 seconds)

Then if you turn off one or more "Unload Coal" stations it won't check which one to target until it passes "Unload Coal Waypoint".
In this case you would need to enable/disable both the actual station and the waypoint, if not the train will always use the shortest "waypoint" even if the station behind is closed.

What you could do is only close/open the waypoint, you gave me the idea, if you do that, the trains past the waypoint won't reroute, the train before the waypoint will look for the other closest, and then the station will be the one just after. That seems a simpler way to have the same train behavior as if you divert them in the least occupied stacker, except you don't need to worry about counting the distance and penalty for the path finder.
mrvn
Smart Inserter
Smart Inserter
Posts: 5877
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: 0.17 Train Station Behavior

Post by mrvn »

What works even better is to build depots around your base at equal distances. E.g. one each in the north, south, east and west. Then have all the mines in the north of the map ship their ore to the depot in the north. They unload their ore there into buffer chests and trains from the main factory go to each depot to load ore. Same for the other directions.

This also allows you to e.g. use LCCC trains to ship ore from mines to the depot but then use LCCCLCCCLCCCLCCC trains to ship ore from the depot to the main factory. The smaller trains for the mines mean they will supply some ore at closer intervals giving a smoother stream. And the larger trains going between the depot and main factory reduce traffic.

The next evolution for this is to put the smelter at the depot. Ship iron ore from the mines in, smelt and ship out iron plates. Doing this for electronic circuit boards is even more effective.
marzolan
Burner Inserter
Burner Inserter
Posts: 13
Joined: Fri Aug 11, 2017 7:21 pm
Contact:

Re: 0.17 Train Station Behavior

Post by marzolan »

slippycheeze wrote: ↑Tue Jul 09, 2019 5:03 pm Seriously, though, OP, so much of this sounds like you really want the LTN or TSM mods to manage your trains, but you don't realise that yet.
It was more that the last time I attempted this approach I didn't have to do too much to it. It just worked. Going back to my original question, it seem then the correct option is that I just got lucky. That particular layout worked, this one does not - or rather it works the same way but the outputs are different because the inputs have changed.

Thanks everyone for making what was, for me, the blackbox of train pathing less black.

As for the map in question, the dedicated rail station works just fine for now. As the map grows I may revisit the suggestions here.
slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: 0.17 Train Station Behavior

Post by slippycheeze »

marzolan wrote: ↑Thu Jul 11, 2019 3:04 pm As for the map in question, the dedicated rail station works just fine for now. As the map grows I may revisit the suggestions here.
That is 100 percent of my advice on how everyone should "do trains" - at least, until they know why it isn't the right advice for them. :)

IIRC, the wiki was a very useful guide to me when I started to think more about this, especially the numbers on how much everything cost. Once I had the basic model (eg: calculate costs, at the decision point, and pick the least worst) the numbers started to help me make better choices with it. For what that is worth.
Post Reply

Return to β€œGameplay Help”