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