Smart Train Deliveries with Combinator Magick [0.13/0.14]

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

Lezreth wrote:Getting this train controller to work has been quite the adventure.
For me, too :).
Now I have been trying to make the red network wireless with the assistance of the FLAN mod.
That's not going to work because FLAN does not update all the receivers every tick, which would be necessary for the polling to work. So, in short, forget about using FLAN for this...
Could someone please give me a list of the signals that are sent between the stations? Having wireless antennas would make network management a little easier.
You'd need a version of FLAN that updates every tick, but as far as I understand it would make the mod use way too much CPU time -- which is why it works like it does now, but unfortunately that makes FLAN not useful for any design that uses polling.

A short rundown of the protocol is this:

Phase 1: S=1 is on the wire, all outposts respond simultaneously with either their requests or provided resources.
Phase 2: Q=x will poll, the ouposts respond with their ID (R=n or P=n), and the resource information (simple flag for requester, amount for provider)
Phase 3: The depot will send requester and provider number for the selected schedule and the resource and amount of the selected resource. This is done twice, once with R negated and once with P negated.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Lezreth
Inserter
Inserter
Posts: 40
Joined: Thu Jun 30, 2016 12:57 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by Lezreth »

Damn, and I thought I had something there... If FLAN did support polling it would suit this use quite well I think. Maybe its time I dive into the code finally and come up with a solution, maybe something similar to FLAN but acts more like a radar dish (points in a specific direction) or maybe has channels, something along these lines to minimize the impact on UPS and make polling support practical.

That also explains why Q would just keep cycling and the light at the depot was constant yellow. It appears that it got to phase 2 and FLAN said nope! then got stuck.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

Lezreth wrote:That also explains why Q would just keep cycling and the light at the depot was constant yellow. It appears that it got to phase 2 and FLAN said nope! then got stuck.
Yes, exactly. Phase 1 is not an issue because it does not rely on polling (it will be a tad slower but should work fine in all cases with FLAN); unfortunately that's not really helpful because at some point you have to ask the outposts individually for their status.

FLAN does update ONE receiver each tick, not all of them. But the polling, which is a broadcast, requires all the receivers to be able to simultaneously listen to the signal and also immediately respond.

In order to use FLAN with such a polling protocol, you'd have to broadcast the polling signal, then wait for "x" ticks until all the receivers have updated so they receive the polling signal, then wait for "x" ticks again so you can be sure you get the response ("x" being the number of outposts). This would have to be repeated "x" times.

As you can see, the response time would be unacceptably slow, and the protocol would also become more complicated.

I can see possible designs that do not require polling, and they could work with FLAN. But it would be radically different from what we have now, and these designs are also a lot more complicated to set up in practice (e.g. if every outpost needs a unique signal and some encoding you will have have to keep lists outside of the game and the signals on the bus will also become illegible; in an actual game these are huge issues that kill the fun).

To be honest, the red wire that is required to connect all the outpost is the least of your problems if you want to run this setup (or a similar one). So far, nobody has complained about the necessity to run a red wire bus, and I've also not seen it as a problem at all in my actual games.

If you use FARL to lay your tracks, you can have it draw red (and green) wire automatically along the power poles that it will also plant for you automatically in between the tracks. So not really an issue if you ask me.

Obviously, having something wireless would be better, but it would have to work exactly like a circuit wire (no latency, tick-perfect). Maybe we'll get something along those lines in 0.15, at least it's on the devs' list of possible features.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by ssilk »

Moved to new subcategory. :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

I don't suppose there is a video tutorial out there somewhere to follow? Would love to try this but a little too advanced for my very old simple brain ;) Good work though!!
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

There is no video tutorial, I recommend you take the demo map and read through the part of the thread after that post (doxsroxs has provided quite a lot of documentation through his questions along the way :-).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
doxsroxs
Fast Inserter
Fast Inserter
Posts: 160
Joined: Mon Aug 01, 2016 4:19 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by doxsroxs »

I think the hardest part is getting everything to work when you dont know what errors to look for or what signals to expect. That takes time to learn, however the system is stable now and should not give you problems when starting up. Just make sure you use correct blueprints and a checklist that you go through when setting up each station.

On that note, I have found that building my requester station from a few posts above under power can cause it to contain barrel signals in the register depending on how the robots place the combinators and attach them.
The solution is to have an empty constant combinator box. Ill post a fixed blueprint tonight.
Send train to station ID using combinator signal is a long overdue feature!
viewtopic.php?f=6&t=74663
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

Cool Doxsroxs, many thanks.

I was into making a factory that would build certain items independently and then be railed across the map to be used in other items etc, so think this would be great to get working in my save. Have had a little play around in the demo trying to develop a basic understanding.....bearing in mind i have a very basic understanding..... ie getting mods to work took a tutorial ;)

I am currently running around upgrading my rail network with red wire.....a long process due to limited time to sit down and play a game. So whilst i do i thought i would ask some questions for problems i think i will run in to, and any help would be greatly appreciated.

1. I use a staging area for my ores..... ie 2-3 mines inload the ore staging area. the ores then move from there to places that need it. I dont think the dynamic train will work for this as it will take ore from the outgoing station and put it back in the ingoing station as well as deliver around the factory. So my understanding would be to run the mine to staging area trains independently and just wire the staging area outgoing station within dynamic trains?

2. once i have upgraded all rail to have red wires, before i install the depot, i will have to delete all current stations and rebuild them after depot station is installed?

3. I have to use the smart trains stations?

4. If i use the 3 station depot, i can still use more than 3 trains? They will just stack behind each other until the front one gets tasked?

5. I am a way off getting to it yet, but if you could simplify a little how to run oil/fluids around using barrels and the setup thats required i would most appreciate it.

Thanks again.
muglebust
Manual Inserter
Manual Inserter
Posts: 4
Joined: Tue Aug 02, 2016 2:49 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by muglebust »

turkish25 wrote:1. I use a staging area for my ores..... ie 2-3 mines inload the ore staging area. the ores then move from there to places that need it. I dont think the dynamic train will work for this as it will take ore from the outgoing station and put it back in the ingoing station as well as deliver around the factory. So my understanding would be to run the mine to staging area trains independently and just wire the staging area outgoing station within dynamic trains?
That would work, you want to avoid storage stops with the logistic trains, or use some of the workarounds in the thread to make sure the station do not end up just requesting from itself.
turkish25 wrote:2. once i have upgraded all rail to have red wires, before i install the depot, i will have to delete all current stations and rebuild them after depot station is installed?
3. I have to use the smart trains stations?
4. If i use the 3 station depot, i can still use more than 3 trains? They will just stack behind each other until the front one gets tasked?
Yes, to all
turkish25 wrote: 5. I am a way off getting to it yet, but if you could simplify a little how to run oil/fluids around using barrels and the setup thats required i would most appreciate it
There are several options,, depending on requirements, siggboy made a mini "depot" with mini stations for running crude in railtankers, it uses other signals on the same red wire, and requires your oil fields have a fixed tie to a refinery, works wonders for oilfields to refinery, but has issues handling multiple fluid types and several stops.

You can request empty barrels as any other good, so you can just provide them as normal, thats probably the easiest way, especially since there is now a multi provider station.
Other options are in the thread, but most are harder to setup.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

turkish25 wrote:I am currently running around upgrading my rail network with red wire.....a long process due to limited time to sit down and play a game.
That is the biggest barrier for a large map, if you actually have no red wire bus yet. I recommend you use the FARL mod to lay your tracks, so you will have power poles, rail signals and red wire laid out for you automatically. You can also use blueprints and robots, but FARL is a lot easier.

It might even be easier to just remove the old rails completely and just re-lay them with FARL, if you don't want to do the manual wiring.
1. I use a staging area for my ores..... ie 2-3 mines inload the ore staging area. the ores then move from there to places that need it. I dont think the dynamic train will work for this as it will take ore from the outgoing station and put it back in the ingoing station as well as deliver around the factory. So my understanding would be to run the mine to staging area trains independently and just wire the staging area outgoing station within dynamic trains?
I don't use hierarchical ore delivery myself, I don't think it's necessary.

There is a fundamental problem with the simple approach of having independent trains. That is, the provider stations (i.e. outgoing from ore staging to factory) will register any incoming trains from the depot. This is important because the destination (= requester station) will be stored by the provider. This storage is cleared as soon as ANY train leaves.

So in your proposed setup, the "staging trains" that take the ore from the mines to the provider stations will clear the register when they leave, and that will break the system.

Unless you have extreme demands for ore, and LOTS of DISTANT outposts, it's really a lot better to run the trains from the ore mines to the factory (smelting) directly, and not have a separate stage in between.
2. once i have upgraded all rail to have red wires, before i install the depot, i will have to delete all current stations and rebuild them after depot station is installed?
3. I have to use the smart trains stations?
Yes, you have to replace all the stations with smart ones. You can, however, leave most of the rest of the outposts in place. The chests and inserters are part of the setup, however. The provider stations needs the chests wired up so it will know how much is in them, and the requester station also needs the inserters wired up so it can count how much resources are loaded off the wagons.
4. If i use the 3 station depot, i can still use more than 3 trains? They will just stack behind each other until the front one gets tasked?
The amount of trains does not depend at all on how many depot lanes you have. Multiple depot lanes really just help with high-traffic setups and will give you a little more throughput. I recommend you use them because having only one lane doesn't really make it easier to setup and it only needs to be done once anyway.

When you make your train stacker, that actually parks the waiting trains, be careful to use the correct signaling.

What you have to do is to join all the tracks in the stacker to a single point, and then fan that out to the actual depot lanes. So you might have 10 parallel tracks in the stacker, that get combined to one, and then immediately fanned out to 3 again, which are your depot lanes.

The important bit is to put a CHAIN signal at the front of each of the stacker lanes, as close as possible to the "join point" of the rails. You can, of course, park more than one train on each stacker lane if they're long enough, but you separate the trains with regular signals, not chain signals. The chain signals are only used at the front of the stacker.
5. I am a way off getting to it yet, but if you could simplify a little how to run oil/fluids around using barrels and the setup thats required i would most appreciate it.
The easiest way is to use the simple depot setup that I've posted a while ago, which runs completely parallel to the "full blown" setup and will only be used to deliver oil. You can use it for barelled oil or Rail Tanker. If you use that you will have two separate depots, one for the oil trains (which will probably be at your refinery), and one for the rest. You will also have two separate train lines in SmartTrains. It's not necessary to have a second wire, it can all run over the red wire bus.

The setup is in this post: viewtopic.php?f=193&t=25311&start=260#p199077
but you use the blueprint from the post right after it (the updated version).
It includes instructions, so should be easy enough to setup. You can do it indepentently from the rest, maybe you even want to start with it.

It's also possible to deliver barelled oil with the full blown setup, like muglebust has pointed out, but it's not easy to set up so I don't recommend it in your case since you're only learning how the system works.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

Thanks for your advice guys, much appreciated.

Yeah, i used FARL in the first instance but hadn't connected Red Wire, So basically re-ran the whole rail network. :(

However done now, Depot, first provider and requester station in, and it seems to be working...... :D
HiddenWolf
Inserter
Inserter
Posts: 48
Joined: Thu Sep 24, 2015 1:37 pm

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by HiddenWolf »

I've been trying to get dynamic trains to work with my existing game, had no success, so I set up a creative mode map for myself where I've lightly adapted the demo designs to match the setups that I'm using.
I've moved the logic out of the way slightly, expanded the provider/requester to four trains, and added a balanced loading buffer to the provider. Functionality should be identical though, as I copy-pasted blueprints around.

I've followed along the instructions in post 'version 3', as far as I understood them.

Can someone check the attached save and point out why my train isn't running?

EDIT: In my third check I've found a few errors, fixed those, uploaded new save. Still no joy.
Attachments
CREATIVE_3.zip
(7.35 MiB) Downloaded 124 times
Last edited by HiddenWolf on Fri Sep 23, 2016 1:53 pm, edited 1 time in total.
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

turkish25 wrote:However done now, Depot, first provider and requester station in, and it seems to be working...... :D
And i spoke too soon, the coal provider requester i did first works fine. Set up an 2 Iron Providers and a requester, then the same for copper and they are not working???

Just cant figure out where i have gone wrong. So I

A. Use blueprint. no power no wires attatched
B. Connected all the output buffer chests to the circuit.
C. Conected inserters in pulse mode.
D. Set constant Combinator to iron (-10k)
E. Changed station name, added to smart trains, save as line, ticked signal# and saved.
F. Constant combinator shows station #
G. Connected power and red wire...........nothing.
H Walked whole line to check no red wire was missed, checked provider station, put a second train on line, nothing.
I. Took coal from working requester station, and depot sends train back there to refill so that one is still working.
J. Set up copper requester to see if that would work, but no?

There is bound to be something silly i have missed here? please put me out of my misery :(

Edit: if I change to request coal they work and get coal from coal provider. So not sure why the copper/iron providers are not "providing"?

Edit 2: If i go to the coal requester and request iron ore i get nothing :( re checked all red wire connections, rebuilt ore provider stations, from demo and from the coal provider blueprint - nothing.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

HiddenWolf wrote:Can someone check the attached save and point out why my train isn't running?
I've checked your save.

You made a mistake wiring up the train stations. The green wires were attached to the train station, but they need to be attached to the train station COMBINATOR. When I fixed that, it worked fine (I also had to reset the registers that contained bogus values).

Also, the inserters at the requester still had the "enable" condition set, so I set that to "none". The important bit is that they're in "pulse mode", but they should always work unconditionally, so no "enable condition".

I'm attaching the fixed save.
Attachments
CREATIVE_3.zip
(7.41 MiB) Downloaded 121 times
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

turkish25 wrote:Just cant figure out where i have gone wrong. So I
Please upload a save, and maybe also a zip of your mods folder, I'll see if I can spot the error. It's probably something simple.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

Cool, thx. Hope this has worked...

The Coal provider to the coal power station is the first one i rigged that works.
Attachments
mods.zip
(12.77 MiB) Downloaded 122 times
Pete train rebuild inloads grrr.zip
(30.7 MiB) Downloaded 133 times
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

turkish25 wrote:Cool, thx. Hope this has worked...
The Coal provider to the coal power station is the first one i rigged that works.
OK, it was a very simple fix.

First of all, let me say you did a fine job with setting it all up, it seems you know enough about the setup to actually run it without much problemerino. :D

In your depot, you need to have a value "G = n" in the set of combinators at the top. These are the combinators that enumerate all the possible resources ("Coal = 1, Iron = 2, ..."). The value "G" needs to be the largest value. In your case, the last item is "Full Barrel = 29", so you'd set "G = 30".

("G" is a shorthand for "guard", because this value guards the end of the array, and is the highest index in the array of resources.)

Because this value was not present, the depot actually never did a resource selection. The reason why it worked for Coal was, that Coal is the first resource in the array ("Coal = 1"), so it will be selected even if the counter doesn't run, since it starts with "I = 1" which will match Coal. None of the higher numbers could ever be reached.

I recommend you keep the value "G = x" simply as the last value in the constant combinator, so you won't forget to adjust it when you add more items. You can also set it in the combinator where "I=1" is set, it doesn't really matter because the constant combinators are all linked and treated as one big combinator.

You can also set it to a higher value, e.g. "G = 60", which will be higher than any index of resources that you might add. The only downside of this is that the resource selection will be a tiny bit slower (not really a problem in practice if you ask me).

Probably the last option is the best. Simply set "G=60" in the combinator where there is "I=1" and you're done.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
turkish25
Burner Inserter
Burner Inserter
Posts: 9
Joined: Sat Sep 17, 2016 2:00 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by turkish25 »

Siggboy, many thanks for taking the time to check it out. I had a feeling i was going to be something simple lol. Yep put in G=60 and boom, they burst into life.

Now the fun begins ;)
Malryn
Inserter
Inserter
Posts: 33
Joined: Fri Apr 22, 2016 7:33 pm
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by Malryn »

Dumb question. What would be the reason a the depot train stations from your demo would not show "trainlines" when I load the blueprints to my game? I get stuck here as I cant find the rules to edit in
"Save the train line in the SmartTrains UI. Set the rule "go to signal #" in SmartTrains and save the updated line."

Also, can you show an up to date screenshot of the depot's "computer?" I try to find things such as the number of wagons and I just start doing best guess when following viewtopic.php?f=8&t=25311&start=140#p191365.
User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: Smart dynamic train deliveries with combinator Magick [0.13]

Post by siggboy »

Malryn wrote:Dumb question. What would be the reason a the depot train stations from your demo would not show "trainlines" when I load the blueprints to my game? I get stuck here as I cant find the rules to edit in
"Save the train line in the SmartTrains UI. Set the rule "go to signal #" in SmartTrains and save the updated line."
The smart trains GUI is in a separate window which is covered up by the Factorio train UI window. If you move the Factorio window you can access the SmartTrains stuff.

You need to select a train (not a station) in order to change the main train line. If you click on a station you can still edit the rules ("go to signal #) but not add or remove stations.

If you want to edit the train line (in SmartTrains), what you do is click on any of the trains on the line, make the changes there, and then save it in the SmartTrains window. That will take the schedule from the train and copy/update it in SmartTrains.
Also, can you show an up to date screenshot of the depot's "computer?" I try to find things such as the number of wagons and I just start doing best guess when following viewtopic.php?f=8&t=25311&start=140#p191365.
If you look at this post
viewtopic.php?f=193&t=25311&start=260#p201443

you need to check the stuff marked in yellow. The number of wagons is in the group of combinators on the right (two combinators marked with a yellow outline). The combinator that multiplies holds the wagon count (as a negative number, e.g. "-2" for two wagons, "-4" for four wagons etc.). The other one subtracts a value, you can leave that.

The orange combinators also have configs, but at first you don't really have to touch them, it only becomes important later when your setup grows really quite large or when you need to add special resources that are not in the default configuration (or if you play with mods).

Also, you should definitely take the blueprint from that post (linked above), I'm not quite sure right now if I put that version into the demo map already.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Post Reply

Return to “Combinator Creations”