Multiple same name train station control

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
MagicKyrano
Inserter
Inserter
Posts: 23
Joined: Sun Jul 23, 2017 3:13 pm
Contact:

Multiple same name train station control

Post by MagicKyrano »

Summary

When trains want to go to train stations with the same name, let them reserve the station, so not all trains go to the same station at once.

Additional resource links

Train pathfinder in-depth: viewtopic.php?f=5&t=52635&p=308300 (How train pathfinding works).

Explanation

When you have multiple train stations with the same name, the trains go (roughly) to the closest train station with that name. As stated in the link above to Train pathfinder in-depth, trains in that route or train stations in the way can make the train pathfinder redirect a train to another station with that same name. What this generally means, is that when a train wants to go to stations with the same name, he chooses the most nearby station that does not have a train waiting on it.

While this normally works, there are a few problems with it. The first is, that multiple trains still all try to go to the closest station first, and when it piles up at that station, then they may reroute to one of the other same name stations. It will probably still work, but it is inefficient.

Another problem is that using same name stations means some same name stations will not be visited. For patch-stations (for retrieving coal/iron/copper/etc from the ore patches), this is normally not a problem, since the trains will still visit patch stations and get the resources, and when those stations are empty, then they will visit the next ones. Plus, you can always put more trains on those same name stations, to have more same name stations used at once. But, when the same name stations all require the same resource to be dropped off, some of those stations will generally not get resources, or sporadically.

For example, say you have 6 stations named Iron Plate Request, that all require Iron Plates to be dropped off there, and you have 3 trains that deliver to stations named Iron Plate Request. Now suppose that 3 of those stations are nearby, and 3 are further away in your network. In the current setup, the outermost 3 stations will probably not be visited, or only sporadically, since the train pathfinding prefers closest-by stations first. It is possible to put more trains on those same name stations, but when those trains can't be filled quickly enough with the resource they need to drop off, it will not always work. Also, those trains will still all try to go to the 3 innermost stations first, and only when they are fully stocked up, will they try to go to the outermost stations.

Request / Proposal

Make trains reserve station they go to.

When trains are pathfinding, and they have found a (free) station, make them reserve that station. Now, any train after that tries to not go to stations that are already reserved, and prefers unreserved or empty stations. In code, as seen in the link to Train pathfinder in-depth, this could be very easily done by something like: If StationReserved, then add penalty of 300 tiles.

The idea is that trains that want to go to a station, see in advance that a station is going to be visited already, and prefer other stations that are unreserved. Also, if implemented correctly, it could help deliver resources to same name stations, like in the "6 station Iron Plate Request" example above.

As far as I can see, it should have no impact on non-same name stations setups, since even if the only available station is reserved, they can still go to that station. (they only got a penalty, not a ban for that station).

Also, given correct penalty values, closeby reserved stations could still be favoured over far away same name stations, to prevent trains going to far far away stations, while a closeby station that's currently reserved would still be quicker for them. (after waiting for that reserved train to finish and move away).

And performance wise it should also not be a big impact, since this check will only be done once per pathfinding request.

Advantages

What this will theoretically do, is make sure same name stations get visited more uniformly, without impacting performance or non-same name networks.

Addendum

When writing this, I came up with an additional idea that it is also possible to let stations remember how many times they have been visited, and take that number in account for detemining where trains to same name stations should go. I do see possibilities for spreading out trains over same name stations, so they get more uniformly visited, but since I haven't thought this number idea through enough, I leave it here as a note.

Post Reply

Return to “Ideas and Suggestions”