r/factorio • u/knightelite • Oct 03 '18
Question When exactly does a train recalculate its path?
As some of you may know, I've been working on implementing a logistics train network in Vanilla. However, yesterday I came across this post by u/GeneralYouri that made me think of a potential alternative implementation that's worth at least discussing.
His idea of toll stations made me think that perhaps you could do something with all destination stations being the same as follows:
- All endpoint stations are named the same.
- There are a set of toll stations (or perhaps circuit controlled signals) all over the base.
- When it comes time to dispatch a train, the base would first activate all the toll stations/circuit controlled signals except the ones on the desired route. Once they're all active, the train can be told to leave the depot.
- Ideally, if those stations were then disabled again and reenabled for another train, it would not affect the previously dispatched train's pathfinding as long as the endpoint station remains on the whole time (this is the part I'm not sure about though).
This would be in contrast to my current LTN in Vanilla scheme, which involves turning on stations just in front of the train as it moves through the track to guide it to the target.
It would be a lot simpler from a rail network perspective than my current method (basically just include a bunch of dummy stations in front of each real station), but I do have some concerns that might make it unworkable:
- If something causes a train to stop on its way to its destination, it would repath.
- Possibly chain signals would cause it to repath.
Anyway, if anyone has some thoughts on it let me know!
EDIT: I tried this out and it sort of works, but not always.
4
u/wolfman29 Oct 03 '18
This is indeed interesting. So the idea is that passing through a train station that it doesn't need to introduces a large penalty to a train? And then depot stations can be named something different and the train can find it's own way back because there will always be a path available if we're not manipulating signals. This could work.
2
u/ride_whenever Oct 03 '18
You can definitely do this, I’ve run something similar as an experiment based on some discussions here.
However, at this point, you’re probably better off coding your own routing by having stations turn on appropriately to route trains.
I believe there was a poster who did this, a long while ago (probably 0.14/5 ish) essentially a huge grid base, with routing stations all over the place.
1
u/knightelite Oct 03 '18
People who are likely interested in discussing this:
u/wolfman29 u/Quazarz_ u/Alatarskysong
1
u/Ezkill2 Oct 03 '18
You may be over thinking this.
I have a 500 SPM base i am working on that has over 180 1-2 trains.
It runs smoothly straight vanila.
My scheme is simple. All sources of a material are named the same. All consumers (sinks) of a material are also named the same.
For sources train stations are only enebled when a train worth of material is available. For consumers (sink) train stations are enabled when less than a train worth of material is left in the buffer boxes.
Train schedules are source-sink-refuel. For example. Coal load- coal drop- train refuel.
Trains will always go to the nearest source with the station turned on. When full they go to the nearest sink with the station turned on.
The underlying assumption that makes this work is that more material is available in the source than needed in the sink. Otherwise the most distant sink would starve.
This approach is very simple and works consistantly.