Page 1 of 1

Train GOTO condition

Posted: Fri Aug 05, 2016 3:10 pm
by Maverick8717
currently all train conditions are WAIT conditions, it would be great to have a go to condition for many many reasons. it could greatly reduce the number of trains and stations necessary for smart grids.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 2:24 am
by OdinYggd
Yes please.

Conditional jump in train orders is something that I made regular use of in OpenTTD that is simply not available yet in Factorio.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 2:33 am
by Maverick8717
I want to be able to use circuit network to send a train to different places based on logistics conditions. Instead of having a fixed route.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 10:45 am
by jdround
+1

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 11:01 am
by siggboy
+1000

This feature would require that it's possible to save the train schedules as logical train lines, independent of individual trains (so the game could assign an "identity" to each station on the line that you could use in the "goto rules".

It's possible with the SmartTrains mod right now.

For an advanced scenario making use of this, check the thread in my signature.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 1:40 pm
by hitzu
Maverick8717 wrote:currently all train conditions are WAIT conditions, it would be great to have a go to condition for many many reasons. it could greatly reduce the number of trains and stations necessary for smart grids.
Please could you explain how should it look like? I don't get the "goto" condition.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 2:07 pm
by Maverick8717
yes, currently in train settings you set which stations to go to and how long to wait at each station, you can set it to be a time, until full, or a circuit condition ect. When the conditions are met the train is released from the station to go to the next in order. I am sure there are different ways of accomplishing what I want, one way would be to add another condition that says if the condition is met the train would go to a specific station. The other way would be to basically clone the list of stations with wait conditions and have another window below to have a list of stations with go to conditions. and under each station you can select the condition the same as you normally would do, for the train to go to the station.

An example use would be to have one train at base, and if your copper storage at your base is low you can send s circuit condition to the train to send it to the copper mine, and with the same train if something else is low you could send it there. this would greatly reduce the number of trains necessary to have a functioning base.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 2:25 pm
by siggboy
Maverick8717 wrote:The other way would be to basically clone the list of stations with wait conditions and have another window below to have a list of stations with go to conditions. and under each station you can select the condition the same as you normally would do, for the train to go to the station.
This would still be too limited.

Take the following scenario, based on your example: you have a train waiting, e.g. at your base, and you detect a copper shortage, so you send it to the copper mine. Where will it go after? To the furnaces of course. But where do you set the "go to" rule for the furnace? At the furnace station.

So the train at the copper mine will now have to trigger the "go to" rule for the furnace station, but that rule will then apply to all the trains. So they'd all go to the furnace station at this moment.

The problem is that the "go to" rules will trigger for all trains that are on this schedule, this makes it impractical.

On the other hand if you have setup a separate train schedule for every train, then it's very limited, too, because it's very error prone and difficult to add these schedules to all the trains, especially with many stations in your line.

Your suggestion will not work in practice. What you need is something like SmartTrains, where all the stations get a number, and you can use this number in a signal to instruct the train to go there -- from any station. The signal number is only checked when the train leaves, so it will not trigger a "global rule" that would affect all trains.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 3:07 pm
by Maverick8717
I need to download smart trains and experiment with that also. however maybe I am not properly explaining my idea, imagine now also if in the train settings you could set different loops, so right now a train only has one loop, you set the list of stations and that is it. What I think would solve most issues is if you could have multiple loops, you would still have the primary loop, and then if you could trigger one time loops. So you could have a go get copper mission that would return the train to where it was. But I will be getting smart trains and see what I can do with that.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 3:11 pm
by siggboy
Maverick8717 wrote:imagine now also if in the train settings you could set different loops
Yes.

You want precisely what SmartTrains offers. You should install it and try it out. It does exactly what you want.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 3:35 pm
by hitzu
What if the station would say a train to go to another specific station if the condition is met and this would be a priority command for the train? Stations also should be able to read the content of the train on that station.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 4:39 pm
by ssilk
I'm not happy with this. I already discussed around that (*), but it still pops up here and then :) .

I still believe, before we get this we need an implemented "routes/shared orders"-concept.

What do I mean with that? In OpenTTD this is known as "Shared Orders". See https://wiki.openttd.org/Orders#Shared_Orders
Shared orders allow you to share one set of orders between multiple vehicles so that when one vehicle's orders are updated, the other vehicles sharing the same orders are also updated. It doesn't matter which vehicle you update - all vehicles sharing those orders are changed.
Routes/Shared Orders in Factorio are exactly this. And maybe they are enhanced to be changed by some condition (what is wanted here). So if you change the route/shared order (no matter how) then you change the schedule for each assigned train.

And to find back to this subject: It makes sense to have routes/shared orders first, cause routes are global, but schedules are only by train.

>>> We don't need micro-management by train, we need a macro-management of resources. <<<

If this will be implemented it implements this kind of micro-management that I don't want.


(*)
viewtopic.php?f=6&t=26359&p=167133&hilit=routes#p167133 Trans numbers for circuit network in v0.13
viewtopic.php?f=6&t=25944 Train station skipping conditions
viewtopic.php?f=80&t=21899 Control Train Pathfinder (Passthru stations, Add Penalty)
viewtopic.php?f=66&t=10312&start=10&hilit=routes Connect train stops to circuit networks
viewtopic.php?f=6&t=7787&p=61515&hilit=routes#p61515 Train Lines and global filters
viewtopic.php?f=6&t=7346&p=60602&hilit=routes#p60602 Better train logic (smarter alternative route finding)
viewtopic.php?f=6&t=3072&p=22682&hilit=routes#p22682 Outpost logistics [sounds like I contradict myself, but it's now two years ago and in general I mean the same]

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 5:51 pm
by siggboy
hitzu wrote:What if the station would say a train to go to another specific station if the condition is met and this would be a priority command for the train? Stations also should be able to read the content of the train on that station.
ssilk wrote:Shared orders allow you to share one set of orders between multiple vehicles
Again, this is almost exactly what SmartTrains implements:

You can save a train schedule as a "line" (or "route", or "shared set of orders", if you will). Then any train can be assigned to this existing line.

The stations on the line are numbered (sequentially, but the numbers can also be manually assigned).

For each station on the line, you can set the next station in the sequence; for example, at station #5 you can set station #1 to be the next in the schedule. Then any train on this line, and only on this line, will go to station #1 from station #5.

The other possibility gives the most power: you can tell the train to evaluate a signal at the station that will tell it where to go next. This is what you need if you want to make an advanced, dynamic train scheduler.

Conditions for the train stop are still evaluated as in Vanilla; it's independent of the signals at the station. The signal only gives instructions where to go next after the "wait" condition is no longer true.

These things are not stored "per station" or "per train", but per line. The lines are a feature of SmartTrains and are not part of Vanilla Factorio. In the base game you can only assign schedules to individual trains, you cannot share them as a line.

So ssilk is correct, but there's no need to look at OpenTTD. The feature already exists for many months in the form of a mod, and several very complex setups have been created that use these features.

It only has to be integrated into Vanilla Factorio in one form or another.

(BTW SmartTrains also allows reading the cargo from the wagon, reading the fuel level, sending a train to refuel automatically, and gives a number of useful signals at the station; all of this is necessary if you want to make the really interesting stuff happen with trains.)

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 6:14 pm
by hitzu
siggboy wrote: Again, this is almost exactly what SmartTrains implements:
Yes, I know. This mod is great, but very complex to be the part of the vanilla game.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 6:18 pm
by siggboy
hitzu wrote:
siggboy wrote: Again, this is almost exactly what SmartTrains implements:
Yes, I know. This mod is great, but very complex to be the part of the vanilla game.
The mod is not complex at all.

80% of the features from SmartTrains for 0.12 were integrated into Vanilla in 0.13.

The only thing that's missing is the ability to store a schedule as a line and assign any train to that line (and the thing with the signals to go to a station).

I don't see how this would be too complex.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 6:31 pm
by hitzu
siggboy wrote:
hitzu wrote:
siggboy wrote: Again, this is almost exactly what SmartTrains implements:
Yes, I know. This mod is great, but very complex to be the part of the vanilla game.
The mod is not complex at all.

80% of the features from SmartTrains for 0.12 were integrated into Vanilla in 0.13.

The only thing that's missing is the ability to store a schedule as a line and assign any train to that line (and the thing with the signals to go to a station).

I don't see how this would be too complex.
Ok, maybe it looks complex since I haven't tried it yet :)

All I want really is just to change on the fly the schedule of a train by the circuit network. Assign them to the lines is probably a good feature too. This would go along very well with custom train colors so they would be line-dependent. Also sorting the "Trains" screen by lines would be handy too.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 7:43 pm
by golfmiketango
Smart trains mod, so it seems to me, is presently somewhat "complex," in practice, because it is forced to wedge some square pegs into some round holes:

First, if I'm not mistaken, there is no "train line" object in the game; instead this exists solely in the imagination of the mod, and the mod must find creative ways to approximate the behavior by adjusting individual train schedules to conform to changes to "line schedules" which are conceptually shared. There are all kinds of messy corner-cases that crop up unavoidably when modifying schedules and performing tasks like splitting one train-line into two lines. No doubt these corner cases are doubly painful for the mod since it already is using smoke-and-mirrors to support the "line" concept in the first place.

Second, the mod has a somewhat messy and idiosyncratic user-interface. Perhaps this is to some extent the mod author's fault, but I suspect more of the blame for this again falls on the modding API for not providing a sufficiently rich UI API. In particular, it seems very difficult to create multi-window user interfaces and literally impossible to control where mod interface elements appear on-screen with the kind of granularity that native game UI elements have. I suspect this is largely an historical accident where certain key-binding behaviors have become tied to assumptions that certain classes of user-interface elements will be modal or not shown at the same time, etc., and that there is no pain-free way to fix the problem incrementally.

That stated the basic idea is quite intuitive and obvious.

The "GOTO" feature of smart-trains, in particular, may be a bit undercooked. Also understandably so. A "goto here in schedule" ability -- and, even more so, an "assign to new line and then goto here" capability, which afaik is not yet available even in smart-trains -- has corner-cases that threaten to create surprising results and breakage if, for example the schedules are changed. I'm not criticising the mod here, which I think is awesome, just saying, it's not free of complexity nor can it be.

Once you have "GOTO" though, there is a bunch of amazing stuff you can do with transportation logistics that is otherwise simply not going to be possible.

Disclaimer: since 0.13 I haven't tried smart trains. Some things are probably better now.

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 8:38 pm
by ssilk
@golfmiketango: I think this is a useful analysis if the smart-trains mod.

@all: But this discussion goes off-topic. :)

Re: Train GOTO condition

Posted: Sat Aug 06, 2016 9:10 pm
by siggboy
I don't think it's that off-topic, actually.

SmartTrains, simply, is the best implementation that we have right now, of a feature that amounts to what is suggested in the OP of this thread.

And golfmiketango makes some very good points, especially about the UI and the reasons why it's messy. Factorio indeed needs a better way to create such mods that require a somewhat complex user interface. It should be possible to actually integrate your functions into the existing UI and not be force to create windows.

Regarding SmartTrains in 0.13: yes, a lot of things are better, not least due to the fact that so much of the functionality is now part of Vanilla.