Minimalist Vanilla Programmable Train

Smart setups of railway stations, intelligent routing, solutions to complex train-routing problems.
Please provide - only if it makes sense of course - a blueprint of your creation.
Post Reply
mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Minimalist Vanilla Programmable Train

Post by mmmPI »

Minimalist Vanilla Programmable Train
Goto.gif
Goto.gif (10.39 MiB) Viewed 7235 times
1) Goals / Philosophy
Why
2) Usage
What
3)Schedule
Pic
4)Technical
Grid of cell used
Station. The centerpoint
5) End notes
blabla
Minimalist Vanilla Programmable Train.zip
(4.23 MiB) Downloaded 344 times
Last edited by mmmPI on Mon Nov 15, 2021 11:00 am, edited 3 times in total.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

Now extend it to more than one train.

Note: Use the train limit instead of disabling stations.

farcast
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Fri Jul 06, 2018 8:25 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by farcast »

mrvn wrote:
Sun Nov 14, 2021 6:55 pm
Now extend it to more than one train.

Note: Use the train limit instead of disabling stations.
The trouble with using train limits for programmable train routes with multiple trains is the one tick when the station opens up. Can you guarantee that the train assigned to that station will be first in line in the update order to get a new path? If some other train happens to re-path mid-route in the same tick, then that train can route to the station instead of the intended train. You could use different station names for different resources, but at that point the circuits aren't needed.
Efficient inefficient design.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

1 train => 1 group of station ( 0-1)
2 train => 2 group of station ( 0-1 and 2-3 )
3 train => 3 group of station ( 0-1 and 2-3 and 4-5)

You program 1 train at a time.

The destination is a signal that is transmitted in the whole network, [12 copper plate], you can't output 2 destination at the same time it would sum up.

On top of that the signal to reset the memory for the previous destination is a signal T that is also sent to the whole network.

This means for several train using the same method in the same map at the same location you'd need also either 2 signal per train. or isolated wire network to transmit the datas.
farcast wrote:
Sun Nov 14, 2021 7:44 pm
If some other train happens to re-path mid-route in the same tick, then that train can route to the station instead of the intended train.
Yes this will happen if you use several trains using the same station name, because the train WILL repath due to the limit increasing in a station named the same as its destination. And if it happens that this train is closer to the newly open destination than the other train for which the limit was increased then they will swap destination. That's what i tried to explained with :
You can't output 2 destination at the same time for 1 train, it would sum up the number of copper plate and give a wrong destination.

I don't think you can use 2 or more trains without big adaptation/totally different approach, the main obstacle in vanilla factorio being that two trains could potentially swap their destination if the train stations are named the same and both station are closer to the other train than the one who has the station has original planned destination.
but you explained it well too, except i think it is more frequent than just "if a train happens to repath the same tick". I think the repath is guarantee. The swap of destination occuring only if the train are in relative proximity of the undesired station. but i haven't tested it so far.

You can use this system to have a train dedicated to supply your nuclear plant that would be its base ["station 0" associated with N=1 to make it cell 1], that train could go in a ["station 0" associated with N=2 to make it cell 2] to get new fuel cell. And there if new fuel cell arent available, this train could go get iron plate in ["station 0" associated with N=3 to make it cell 3] OR go to get uranium in station ["station 0" associated with N=4 to make it cell 4]

Code: Select all

Cell 1 goto Cell 2 if fuel cell low
Cell 2 goto Cell 3 if iron plate low
       goto Cell 4 if uranium low
       goto Cell 1 if everything fine
Cell 3 goto Cell 2
Cell 4 goto Cell 2
That require logic on the cell 2 to be implemented so that the number of copper plate is 3 when iron is low, 4 when uranium is low, Not 7 when both are low.
that's not that hard to do :).

Then you can have another train, that you use for the module factory, that would grab either green circuit red circuit or blue circuit.

You can have a train for science that would grab the different pack according to what's missing

You can have all those at the same time if you use (0-1) for the target station of the uranium train, then (2-3) for the train dedicated to modules , then (4-5) for the train that grab science. Provided the wires transmitting the datas are isolated or that the signals choosen are not the same.

The better thing to do i think is a juke box train, where you put one coin in a train, select a number, then the train goes to a music contraption and the coin is used as the signal that triggers the musical contraption.
Then you could go "next song" "previous" "repeat" "turn off". :)

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

farcast wrote:
Sun Nov 14, 2021 7:44 pm
mrvn wrote:
Sun Nov 14, 2021 6:55 pm
Now extend it to more than one train.

Note: Use the train limit instead of disabling stations.
The trouble with using train limits for programmable train routes with multiple trains is the one tick when the station opens up. Can you guarantee that the train assigned to that station will be first in line in the update order to get a new path? If some other train happens to re-path mid-route in the same tick, then that train can route to the station instead of the intended train. You could use different station names for different resources, but at that point the circuits aren't needed.
There are a few cases where trains repath. You do have to avoid those. So don't add/remove rails in the path of trains and don't have grid locks. After that you should be fine. It's not 100% foolproof but generally trains stick to the stations they have targeted.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

No this is wrong for at least 3 reasons :

1)the conditions that makes a train repath are not just removing rail and gridlock;


https://wiki.factorio.com/Railway/Train_path_finding
Repaths that happen as part of normal train operation

A train fails a revalidation.
The train stop a train is heading to is renamed or destroyed.
The train is preparing to stop at a signal (chain or regular) that changes so that the train can now continue.
The train is braking for a signal (chain or regular) it cant reserve.
The train enters a new rail block and can't reserve the next needed signal (chain or regular).
The train has waited at a chain signal for a multiple of 5 seconds and there are multiple train stops with the same name as the destination.
The train has waited at a chain signal for a multiple of 30 seconds and there is only a single train stop with the same name as the destination.
The train wants to depart from a signal (chain or regular) that it stopped at.
The train wants to depart from a train stop.
The train is pathing to a train stop that gets disabled.

Destination full / No path trains

A rail gets created.
A train stop that is part of the train's schedule gets enabled, renamed or created.
The train limit of a train stop that is part of the train's schedule becomes not full.
The train stop that it currently cannot reach gets disabled or destroyed.



2) Then if a train if getting a wrong destinatin just once it means manual intervention is required, something like having empty barrel unloaded in your furnace array. So saying it's not "100% foolproof" is not a correct way to understand the problem. IT NEED TO BE 100% foolproof otherwise it makes no sense.



3) Furthermore it makes no sense trying to automate several train sharing the same station with that method. You can think of it as a finite state machine https://en.wikipedia.org/wiki/Finite-state_machine The machine change state, the machine has only 1 state at a time and a train changing cell is like a transition from one state to another state.

You can implement train-based calculator with vanilla factorio thanks to the finite state machine, look :https://mitadmissions.org/blogs/entry/d ... sm-logic1/

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

The part you extra highlighted only applies to trains with " Destination full / No path". That would be the train you are currently programming. You can't program 2 trains in the same tick so you have to make them leave stations on a circuit signal and make sure you only ever signal one train to leave.

For the rest the wiki is unclear where a repath means finding a better way to the targeted station and where it means finding a better station. Not every repath will pick a new station and any that don't is harmless.

@
mmmPI wrote:
Wed Nov 17, 2021 12:41 pm
3) Furthermore it makes no sense trying to automate several train sharing the same station with that method. You can think of it as a finite state machine https://en.wikipedia.org/wiki/Finite-state_machine The machine change state, the machine has only 1 state at a time and a train changing cell is like a transition from one state to another state.
Look up parallel state machines.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

mmmPI wrote:
Sun Nov 14, 2021 4:35 pm

I don't think you can use 2 or more trains without big adaptation/totally different approach, the main obstacle in vanilla factorio being that two trains could potentially swap their destination if the train stations are named the same and both station are closer to the other train than the one who has the station has original planned destination.

I see you have plentyful of very smart ideas for that different build, you should go on and implement one to show me what you mean because i can't find information on parallel state machine.

you talk about using several train, then the train limit, then timing train departure, it seems like you are throwing off random ideas that are barely related to the orginal post maybe an example would help me to understand what you mean, maybe this way when you build it you can make what's written in the wiki less unclear in your mind maybe you would find some things you thought were true to not be true, it happens sometimes even to the best which you clearly are part of, you could also post it in another thread otherwise my poor lonely train attempt would cast shadow on it :)

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

https://letmegooglethat.com/?q=parallel ... te+machine

The term is used in more than one way and all of them would map to a programmable train network. I'm not sure how practical simulating a finite state machine (sequential or parallel) is in factorio but that was your idea.

My example of having multiple programmable trains would be a simple factory with some ore mines, some smelter, some green electronic circuit factory, ... and programming the trains to ship items from sub factory output to another sub factory input. This goes directory to what you wrote:
makes a train go fetch the needed ressources
Doing this with one train and by having only 2 stations and using enable/disable to program the train is an old idea. So the next logical step
would be to make multiple trains go fetch the needed resources. I think it would be fun to try but I'm not going to fight you over it.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

mrvn wrote:
Wed Nov 17, 2021 6:48 pm
The term is used in more than one way and all of them would map to a programmable train network. I'm not sure how practical simulating a finite state machine (sequential or parallel) is in factorio but that was your idea.
Just send 1 link where it is remotely related to " minimalist vanilla programmable train".

You decided on your own due to tunnel vision i guess that it was about network. In the link i showed you it explained a calculator based on FSM can be done using 6 or 7 different states. This means you have 6 or 7 different cells and each of them is a state of the machine. You only have 1 train because when you use a calculator you do your operation linearly, you type input 1 then operator then input 2 then equal. You do not press simultaneously numbers to type in the input 1 and 2 that's not how it works.

Like for a coin machine, you don't order 2 things at the same time, it's one and then another, and then you can ask for change, if you press all numbers at once it doesn't work.

i don't know why you say what it is my idea, i have presented a desgin there's nothing to infer about my ideas, don't just say as argument "that was your idea" it's nonsense and wrong. You are the only one who started talking about several train because you didn't understand it was a mean to show you there didn't need any add-on on vanilla factorio to make train based calculator as you said you were trying to finish but still no signs of anything just yet that's why i'm asking you to post your own idea on your own post:).

I did a thing that is simulting a finite state machine, and it is enough to implement a train based calculator, or to have a train go fetch different ressources based on conditions those are example of use of what is existing and presented in the post already please discuss about that and not your imaginary ideas that doesn't work and you would have realised if you just had even tried a little such as this one :
mrvn wrote:
Wed Nov 17, 2021 6:48 pm
My example of having multiple programmable trains would be a simple factory with some ore mines, some smelter, some green electronic circuit factory, ... and programming the trains to ship items from sub factory output to another sub factory input. This goes directory to what you wrote:
this is not an example of nothing this is theory of your idea that has nothing to do with what is in the post at the moment, you tend to do that a lot, it is just vague description of a system that should according to your words just be magically enabled using the train limit; even if it was true which is not, it would have nothing to do with the post in which you persist posting about it;

mrvn wrote:
Wed Nov 17, 2021 6:48 pm
Doing this with one train and by having only 2 stations and using enable/disable to program the train is an old idea. So the next logical step
would be to make multiple trains go fetch the needed resources. I think it would be fun to try but I'm not going to fight you over it.
you are such a troll, there is more than 2 station there are 16 cell, so that makes it 16 station but you can use as many as there are numbers possible in the circuit network and even more !

The next logical step is not to use more trains while you could using the mechanism i explained, nor is it using longer train, that's just you who think it's a good idea and i disagree, but also it has not much to do with the design shown. It's overall something totally different, and something that wouldn't work with what you barely suggested, but you are free to post your own design somewhere else than here and i'll learn from it.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

So all of this thread was an attempt to scoop me on a train based calculator I mentioned somewhere that I should continue to make and had nothing to do with being a programmable train. Thanks for linking it in your initial post.

And it was all my idea to
mmmPI wrote:
Wed Nov 17, 2021 12:41 pm
think of it as a finite state machine
Good to know. Why do I always get sucked back in to your upside down world? I'm rarely do this but I'm going to look for an ignore option on the forum. You are impossible to deal with.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

i don't understand what "scoop" means in this context.

I just made a programmable train because you gave me the idea when you said you were doing a train based calculator because you are a smart man obviously and i want to take example on smart person but i'm not quite there yet so instead i just made a single programmable train that has nothing to do with your future calculator as you said.

but it's not all about you i didn't mention you in the post because you are rude generally, and you prooved it by coming saying not nice and not related things, it's just a programmable train one single train, not a network not a fleet of something. Anyone can use this train to make a calculator, or to fetch ressources that's just some example of use case.

now if you don't want to discuss the Minimalist Vanilla Programmable Train maybe you shouldn't comment on the thread and wish an ignore button at the same time there was no obligation for you to post here asking me to extend it to several train, and keep insisting on it.

farcast
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Fri Jul 06, 2018 8:25 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by farcast »

mrvn wrote:
Wed Nov 17, 2021 10:30 am
There are a few cases where trains re-path. You do have to avoid those. So don't add/remove rails in the path of trains and don't have grid locks. After that you should be fine. It's not 100% foolproof but generally trains stick to the stations they have targeted.
Trains re-path whenever they slow down for a red light (such as at a junction), and again when that light turns green, plus periodically while waiting for the light to turn green. These happen all the time and are practically unavoidable for a busy network.
mrvn wrote:
Wed Nov 17, 2021 4:25 pm
the wiki is unclear where a re-path means finding a better way to the targeted station and where it means finding a better station. Not every re-path will pick a new station and any that don't is harmless.
In my experience, a train will always pick the closest destination according to distance calculation rules when it re-paths. Sometimes the closest is the destination it started with, other times... well, it's exactly these other times that are the problem. Dealing with this problem is the main challenge with using one schedule and one group of train stops for multiple universal cargo trains, and re-paths are definitely too frequent to be able to ignore the problem.
Efficient inefficient design.

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by Koub »

mrvn wrote:
Wed Nov 17, 2021 8:36 pm
[...]
mmmPI wrote:
Wed Nov 17, 2021 9:30 pm
[...]
[Koub] If you two can't refrain from fighting every time one of you posts somewhere, I suggest you :
1) Ignore each other (either by sheer willpower, or via "Add foe" feature in the other's profile)
2) Fight via PM
3) Have a duel of who can eat the spiciest food
4) Get a temporary ban if the urge to mess with each other on every thread one of you posts is too strong, so that the forum can have a few days without a fight of you two.

Your choice, but if you don't choose in the 3 first options, I'll choose the 4 for you.
Koub - Please consider English is not my native language.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

Thanks Koub, I've found the "foe" option and set it. Odd name for "ignore" but it fits. I'm as sick of it as you are.
farcast wrote:
Wed Nov 17, 2021 10:55 pm
In my experience, a train will always pick the closest destination according to distance calculation rules when it re-paths. Sometimes the closest is the destination it started with, other times... well, it's exactly these other times that are the problem. Dealing with this problem is the main challenge with using one schedule and one group of train stops for multiple universal cargo trains, and re-paths are definitely too frequent to be able to ignore the problem.
Replace distance with cost. And it's not so simple. There are more complex rules like trains being in a section with chain signals not being allowed to change paths until they leave said section because otherwise they can stall on a junction or hit themself.

In the above there where no signals so none of the re-path conditions would trigger I believe. The challenge would be more how to avoid collisions than worrying about re-pathing. If you add signals then it becomes an issue. I think you could monitor red signals and calculate ticks where re-paths happen and ticks that are free of re-paths. And then only send out new trains in safe ticks. Or only use chain signals.

If you want to explore this further please feel free to open a new thread about it as mmmPI has already said this thread isn't about that.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

i'm noting that at first it was just an injonction to use the train limit, to increase the number of train.

Then " it's not 100% foolproof but it should be fine with the train limit".

then "it's not so simple i think you could monitor red signals and calculate ticks where re-paths happens or only use chain signals" but let's discuss this in another thread where it would actually be appropriate.

I wonder why it took 3 or 4 days and a moderator for this result to happen.

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by Koub »

mmmPI wrote:
Thu Nov 18, 2021 5:45 am
I wonder why it took 3 or 4 days and a moderator for this result to happen.
Sorry for that. There are 3 reasons :
1) I moderate on my free time, which is limited. I do my best, but I have a full time job and a life of my own besides. This limits the time I can spend to moderate - and most of the time, it's enough.
2) The Show Your creations subforum is usually safe from a moderation standpoint, so I spend less time examining what's posted in it
3) I have immense difficulties to understand the subjects around trains and combinators. My brains are just not compatible with these subjects. So it takes more for me to detect I should be moderating (because I don't understand most of what I'm reading). I sincerely thought the discussion was productive before yesterday evening.
Koub - Please consider English is not my native language.

mrvn
Smart Inserter
Smart Inserter
Posts: 5703
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mrvn »

Koub wrote:
Thu Nov 18, 2021 3:31 pm
3) I have immense difficulties to understand the subjects around trains and combinators. My brains are just not compatible with these subjects. So it takes more for me to detect I should be moderating (because I don't understand most of what I'm reading). I sincerely thought the discussion was productive before yesterday evening.[/color]
Don't think twice about it. I thought the same and the exchange with farcast was productive. He seems to be on the same train if you excuse the pun. But then it all went sideways when mmmPI replied to my post turning the whole thing into personal attacks.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2728
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Minimalist Vanilla Programmable Train

Post by mmmPI »

very productive indeed, but probably more appropriate on the gameplay help area,
" how to replace LTN in vanilla with simple and easy to understand setup thanks to the train limit using the technique of monitoring the red signal to only send trains during the ticks that are repath free".
This thread despite the initial disingenuous misunderstanding and insistance of one user is about
an easy and expandable way to program 1 train to do more complex tasks than what is given as possibilities with the train schedule UI
Here is one example :
alltransition.jpg
alltransition.jpg (218.15 KiB) Viewed 6859 times
overview.jpg
overview.jpg (723.89 KiB) Viewed 6859 times
Cell99.jpg
Cell99.jpg (629.91 KiB) Viewed 6859 times
Cell 1K1.png
Cell 1K1.png (1.52 MiB) Viewed 6859 times
Programmable Train Example.zip
(5.22 MiB) Downloaded 239 times

Post Reply

Return to “Railway Setups”