Page 1 of 1

Train path finding logic (0.15)

Posted: Tue May 02, 2017 12:01 am
by jonatkins
The changes in 0.15, with a penalty being added to routes that include a station, is a good idea.

However, for my train networks, it can create more problems than it solves.

For me, at least, the only real issue (before 0.15) with trains pathing through stations that were bulk unloading ores with a queue of traffic - holding up the misdirected train for some time. The occasional routing via a remote mining station was never a huge issue.

Additionally, I've had issues where trains are routed via a long single-line, two way route when there's a similar distance double-track route that would be preferable.

So, how about the following:
  1. A small penalty (perhaps 50?) for routes via a station, to give a slight preference to similar routes that avoid the station.
  2. A larger penalty added for each train scheduled to stop at the station (e.g. 200 for the first train, 500 for the second onwards?)
  3. If cheap to look up, a further penalty for each train currently heading for that station. And even more penalty if the train is stopped at a signal?
  4. For tracks signalled in two directions, double (tripple?) the cost.
This should give a slight penalty to avoid stations with no or one train, but a huge penalty to those that have a queue of trains. Also, will help avoid long single-line two way tracks when there's a similar double-track option.

Re: Train path finding logic (0.15)

Posted: Tue May 02, 2017 6:36 pm
by ssilk
Added to viewtopic.php?f=80&t=21899 Control Train Pathfinder (Passthru stations, Add Penalty)

And so much to say: That numbers might work better for your setup, but it's quite questionable if that improves it for everybody. :)
I still think a kind of signal that can be placed to generate routing penalty (or increase) would be THE solution. Imagine how useful it could work, if that could be controlled by circuits: Red circuit signal from a train-signal can be used to add ... hmmm ... 100000 penalty to the train-routing through this segment. For example and why not? :) Or add -50 to increase the chance for routing through this path, cause it is a "main-route".

What's needed is then just something, which decides, when trains are recalculated, when such a "penalty-device" changes. I would say just something like "if a penalty has changed and is now constant for more than 2 seconds, then the trains will be recalculated", just to avoid recalculation, if the penalty changes every tick.

Re: Train path finding logic (0.15)

Posted: Tue May 02, 2017 9:10 pm
by jonatkins
Well I've tried to consider common scenarios, but yes, there's no simple option that fixes every single situation without complex manual control.

One example where the current high penalty for stations causes an issue - bad enough for me that I've now posted a bug report for it: viewtopic.php?f=7&t=46110

Also, I found a case where an iron ore train was trying to bypass the main line via the central base coal unloading station. Despite the station and three coal trains waiting, the current fixed station penalty wasn't enough to prevent it taking that route.

So that's why this suggestion - lower penalty for stations with one train, higher penaly for stations with many trains.