Few improvements to ChooChoo#1
Conversation
SamuXarick
commented
Mar 23, 2023
- Improve the flow of trains on junctions if ever so slightly.
- Use One Way PBS near stations just in case some train tries to reverse.
- Build network tracks faster by using BuildTrack.FAST opposed to BuildTrack.FOLLOW which can be very slow at times.
- Use AIPriorityQueue from OpenTTD C++ instead of BinaryQueue from Squirrel VM to increase pathfinding speed.
- Busses transfer passengers to train stations and full load them from town. This improves profits in the long run.
- Trains always enter depots, not just when they require service. This may help reduce train jams slightly, but not entirely.
- Only cull trains, not busses, due to the use of transfer orders which might have busses with negative profits until a train route is in place.
- Fix culling counting of vehicles.
- Fix train distance calculation.
- Improve the flow of trains on junctions if ever so slightly. - Use One Way PBS near stations just in case some train tries to reverse. - Build network tracks faster by using BuildTrack.FAST opposed to BuildTrack.FOLLOW which can be very slow at times. - Use AIPriorityQueue from OpenTTD C++ instead of BinaryQueue from Squirrel VM to increase pathfinding speed. - Busses transfer passengers to train stations and full load them from town. This improves profits in the long run. - Trains always enter depots, not just when they require service. This may help reduce train jams slightly, but not entirely. - Only cull trains, not busses, due to the use of transfer orders which might have busses with negative profits until a train route is in place. - Fix culling counting of vehicles. - Fix train distance calculation.
c32e238 to
756ebcf
Compare
I I just implemented the same thing :) And a few other pathfinder performance improvements. I'll definitely take your fixes, but ChooChoo's focus is on building nice networks, not being maximally competitive, so aesthetics come first, performance second. If that means slower pathfinding, so be it :) |
| RemoveRail([0,1], [1,1], [2,3]); | ||
| RemoveRail([0,2], [1,2], [2,0]); | ||
| RemoveRail([1,3], [1,2], [3,1]); | ||
| RemoveRail([3,2], [2,2], [1,0]); |
There was a problem hiding this comment.
These definitely improve the flow, but they look a little too messy so that's why I took these bits out.
| local first = BuildTrack(this, | ||
| toCrossing.GetExit(toDirection), fromCrossing.GetEntrance(fromDirection), | ||
| reserved, SignalMode.FORWARD, network); | ||
| reserved, SignalMode.FORWARD, network, BuildTrack.FAST); |
There was a problem hiding this comment.
Nope, nice looking (double) track is more important :)
Maybe ChooChoo could have a "competitive" setting where it foregoes aesthetics in favor of performance, but that's not really its deal.
| BuildSignal([0, p+1], [0, p+2], AIRail.SIGNALTYPE_PBS); | ||
| BuildSignal([1, p+1], [1, p], AIRail.SIGNALTYPE_PBS); | ||
| BuildSignal([0, p+1], [0, p+2], AIRail.SIGNALTYPE_PBS_ONEWAY); | ||
| BuildSignal([1, p+1], [1, p], AIRail.SIGNALTYPE_PBS_ONEWAY); |
There was a problem hiding this comment.
I don't think trains should ever go the wrong way, because the tracks have one-way block signals, but it doesn't hurt and I like the look 👍
| AIOrder.AppendOrder(bus, trainStationTile, AIOrder.AIOF_NONE); | ||
| AIOrder.AppendOrder(bus, busStationTile, AIOrder.AIOF_NONE); | ||
| AIOrder.AppendOrder(bus, depot, AIOrder.AIOF_NONE); | ||
| AIOrder.AppendOrder(bus, trainStationTile, AIOrder.AIOF_TRANSFER | AIOrder.OF_NON_STOP_INTERMEDIATE | AIOrder.OF_NO_LOAD); |
There was a problem hiding this comment.
I did think of using TRANSFER orders, but just dropping them off does help station ratings so it's a tricky tradeoff.
| AIOrder.AppendOrder(bus, busStationTile, AIOrder.AIOF_NONE); | ||
| AIOrder.AppendOrder(bus, depot, AIOrder.AIOF_NONE); | ||
| AIOrder.AppendOrder(bus, trainStationTile, AIOrder.AIOF_TRANSFER | AIOrder.OF_NON_STOP_INTERMEDIATE | AIOrder.OF_NO_LOAD); | ||
| AIOrder.AppendOrder(bus, busStationTile, AIOrder.OF_FULL_LOAD_ANY | AIOrder.OF_NON_STOP_INTERMEDIATE); |
There was a problem hiding this comment.
The busses are mostly "for looks" so I think I'd rather just have them go back and forth without waiting for a full load.
|
|
||
| function FindPath(a, b) { | ||
| local pathfinder = Road(); | ||
| pathfinder._pathfinder._queue_class = AIPriorityQueue; |
There was a problem hiding this comment.
Nice one! I just happened to find out about that yesterday, but I still had it wrapped in a Squirrel class, this is even cleaner.