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.
Acarin
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Thu Sep 01, 2016 3:58 pm
Contact:

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

Post by Acarin »

Hi Siggboy!

I would just like to say congratulations and thanks for such superb work! That said, I also want to clarify a couple of things, as I was getting intensely frustrated with my inability to get this to work last night...

My plan for tonight is to completely rip out all of my existing train stations and, effectively, start with a 'clean' build, so what I need to do, as I understand it, is as follows:

Get all of my trains back to the stacker
Place the Depot (and maybe disable D=1 while I build), setting train size to 4
Add the stacker stations (non-smart?) and create a train line that simply runs Stacker - Depot
Add the Requester stations (all at the furnaces, all multi-item receipt, so no need to differentiate), wire them into my ore buffer and set appropriate requirement level(s). Add to the start of the train line (Requester - stacker - Depot)
Add the Provider stations, wiring them into the outpost buffer chests and making sure that "load size" is set to 8k, then adding each P staton in turn to the end of the SmartTrain line route
Adjust the rules on the line so that trains leave P when full, leave R when empty, and leave Depot on Signal #
Enable D=1 and cross my fingers

Each Smart station should be connected to the red bus with a wire from the Stop itself (not the combinator) to the power pole and out to the circuit network. The red wire already connected to the power pole in the blueprint is separate to this, isn't it?

Does that sound about right? And do I need to cross-wire the Smart Station combinator and lamp for your system (so that the light comes on when the station is actively broadcasting for pickup or delivery)?
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 »

Acarin wrote:Place the Depot (and maybe disable D=1 while I build), setting train size to 4
The value "D=1" is in a constant combinator and you can have that enabled while you build things. It makes no sense to ever disable it, because it holds the station number of the Depot, which is usually "1" and never changes.

Because "D=1" is always on the red wire bus, it's a good way to check if a point is connected to the red wire bus or not (if it doesn't have the "D=1" value it's not connected).
Add the stacker stations (non-smart?) and create a train line that simply runs Stacker - Depot
The "stacker stations" are the depot stations (= outgoing lanes). They are all named "Depot", and there is no line from stacker to depot. The depot lanes need to be smart stations and they have to be connected to the depot circuit. Refer to the demo map for this.

The "stacker" is what is in front of the outgoing lanes and keeps more trains than you have lanes. It has no stations. Do not confuse the stacker with the depot lanes.
Add the Requester stations (all at the furnaces, all multi-item receipt, so no need to differentiate), wire them into my ore buffer and set appropriate requirement level(s). Add to the start of the train line (Requester - stacker - Depot)
You do NOT add stations to the start of the train line. You always add them to the END of the train line. The first station in the train line is "Depot", and it is ALWAYS the first station in the sequence. There is no reason to ever change this, but you could.
Add the Provider stations, wiring them into the outpost buffer chests and making sure that "load size" is set to 8k, then adding each P staton in turn to the end of the SmartTrain line route
Adjust the rules on the line so that trains leave P when full, leave R when empty, and leave Depot on Signal #
The "use signal #" checkbox must be active for ALL stations (depot, provider and requester). On the depot the condition needs to be "D>0", on your providers/requesters you can make your own conditions, but "full/empty" is usually correct as you've pointed out.
Enable D=1 and cross my fingers
You do not "enable D=1", it is always there. In order to suspend/resume the depot (main circuit), you can disable the combinator that emits "S=1", then the light will turn red and the depot will not send any trains. It is a good idea to do this (and wait for your trains to return) if you make major changes to the setup. Just adding a station (to the END of the line) does not require this, but it always helps to not have any trains leave when you make changes.
Each Smart station should be connected to the red bus with a wire from the Stop itself (not the combinator) to the power pole and out to the circuit network. The red wire already connected to the power pole in the blueprint is separate to this, isn't it?
The train station itself does not need to be connected to the red wire bus. The red wire bus connects all the providers, requesters and the depot. The stacker stations are NOT connected to the red wire bus, they are connected with red and green wire to the depot itself but it is separate from the red wire bus.
Does that sound about right? And do I need to cross-wire the Smart Station combinator and lamp for your system (so that the light comes on when the station is actively broadcasting for pickup or delivery)?
No you do not need to cross-wire lamp and combinator. Wire it up as it is done in the demo map and blueprints.

Try to follow the instructions in viewtopic.php?f=8&t=25311&start=140#p191133
They are very detailed.

If in doubt, look at the demo map and do it as it's done there.

The depot you should use is this: viewtopic.php?f=193&t=25311&start=260#p201443

The provider you should use is this: viewtopic.php?f=193&t=25311&start=280#p205102
(It's a multiprovider which you might not need, but it also does fix a few other things so it's recommended.)

You should start with a simple setup (one provider, one requester), and then go from there. Don't install a lot of stations at once before you have figured things out.

Here's a blueprint book with all the recent versions:
Blueprints
Use these as they are in the book, of course you can make them larger for more wagons, and you can change the multiprovider to a simple provider just by changing the inserter type (and removing the part of the circuit that is connected to the inserter array).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Acarin
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Thu Sep 01, 2016 3:58 pm
Contact:

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

Post by Acarin »

You are a gentleman, sir! Thank you for the clarifications (no wonder I wasn't getting anywhere with the number of things I either got confused or completely wrong). Then again, I started a new map tonight which looks very promising in terms of geography for being able to wall off a decent-sized base area, so I may try this rail network from scratch anyway :-)


Cheers!
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 »

Well i hoped to avoid doing this but I am out of ideas... Would you mind checking out my basic set up and see what is causing my trains to just stop working after three cycles?
Attachments
game save.zip
(53.88 MiB) Downloaded 181 times
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 »

Malryn wrote:Well i hoped to avoid doing this but I am out of ideas... Would you mind checking out my basic set up and see what is causing my trains to just stop working after three cycles?
Without looking, have you checkd that the requester station is correctly connected to the inserters unloading the train?
They need to count unloading resources and reduce the registry in the requester station keeping count of resources it was promised delivery for.

Hover your mouse over the combinators in the station. One combinator with a green wire connected to itself is likely containing a large positive value for your resource, this prevents the station from requesting more resources.
Send train to station ID using combinator signal is a long overdue feature!
viewtopic.php?f=6&t=74663
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 »

doxsroxs wrote:Hover your mouse over the combinators in the station. One combinator with a green wire connected to itself is likely containing a large positive value for your resource, this prevents the station from requesting more resources.
That's a very good guess. I, too, recommend you check this.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
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 »

Ah! you guys pointed me in a the right direction! It was all do to a mod (LateUpgrades) that allowed to increase the item count a inserter can grab. I was at 16 items at a time and that gradually unbalanced the count at the requester station till it past the -500 item mark I had set for requesting items :). I adjusted the -144 accordingly and now things are working right again.


Not to worry, I shall break it again when i do something else...
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:Ah! you guys pointed me in a the right direction! It was all do to a mod (LateUpgrades) that allowed to increase the item count a inserter can grab. I was at 16 items at a time and that gradually unbalanced the count at the requester station till it past the -500 item mark I had set for requesting items :). I adjusted the -144 accordingly and now things are working right again.
The "-144" is only relevant for the multi-provider. If you have a mod that does increase the maximum stack size, then you have to change this value (if you want multi-providers to work). The value should be "number of inserters per wagon" (usually 12) times "stack size" (usually 12 without inserter mods).

If your provider station does not use the value from the register (which indicates the amount to be delivered), then the "-144" value has no effect, other than the requester expecting less than the actual amount that will be delivered.

Here's another way to explain it, so you will understand the significance of the various values and limits:
  1. The provider always announces the total amount of items it can deliver. This value is only announced if it's above a certain threshold that you can set.
    Example: the threshold is set to "anything > 8,000"; the provider is providing "Coal"; if there is less than 8,001 coal in the buffer, the provider will announce "zero"; if there is more than 8,000 coal in the buffer, the provider will announce the actual amount in the buffer (could be any number up to the total buffer capacity in the outpost)
  2. When a delivery from a provider (P) to a requester (R) is made, then the actual amount A at P is promised to R, and a register at R will be increased by this amount. However, if A is greater than the total train capacity T, then the amount is set to T. In other words, the promised amount is never greater than T (the train capacity), which makes a lot of sense because no train can deliver more than fits into it...
  3. The automatic capping of the amount to the train capacity is the reason why you have to set the number of wagons as well as the wagon capacity (depending on resource) in the depot. This makes the provider configuration very simple, because the provider does not have to know which resource(s) it is providing, it can simply announce the actual amount which is in the buffer chests, and that requires no logic at the provider circuit at all.
  4. Also, we subtract a fixed amount from A, per wagon, but only if A is greater than wagon capacity. In other words, if we would cap the amount A to the train capacity T, then we actually cap to below the value T by subtracting a set amount per wagon ("144" by default).
    Let's call the result value "D".
  5. The requester R will add the value D to its register, which means that it expects a delivery of that amount in the near future. A train being unloaded will subtract the actually unloaded amounts from the register again. The register does not store negative values, so if more goods are delivered than have been promised in the past, the register will simply store "zero", i.e. nothing. So it is not a problem if the provider promises LESS than it actually delivers.
    The requester R treats any amounts in the register as if they are actually in the buffers at the requester. This means that if the register, for any reason, accumulates values without eliminating them on delivery, then the requester might stop requesting further resources (because the "virtual amounts" in the register persist forever in that case).
  6. The provider P will also hold the expected amount to be delivered in its register. A simple provider will completely ignore this. It will simply fill the train to capacity. In general this means the train will carry a little more than the promised amount.
    In a multi-provider, the expected amount will be taken into account in order to disable the loading inserters when the promised amount has been loaded. Since we subtract ("144") from the wagon capacity, the inserters will be disabled before they actually fill the wagon to the limit. This is important so that no residual items will remain in the inserters. If you load several types of items in a single station, you have to guarantee that the inserter hands are empty, or else you end up with wagons containing multiple types of goods -- almost never what you want, or even catastrophic depending on your setup.
If you understand the above you pretty much understand the delivery mechanics.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
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 »

Hi again.

After the last time I asked for help, and Siggyboy kindly fixed my trial map, I was swamped with work.

I've now got the trial map up and running, and am trying to translate it to my large main base.
For starters, I've hooked up the depot, the logic, a requester station and my iron offload.

I am seeing D=1, S=1, Green=11 on the red bus.

I sometimes see the amount of iron at the requester on the bus, but then green is an enormous number (200m+).

I'm guessing I need to 'reset' the registers.
In which order should I do that?
is there an easy way to add a signal light to each requester/provider to show that the station is OK and functioning?
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 »

You can reset the registers in any order. I recommend to disconnect the outpost from the red wire bus before you do it.

There is no straightforward way to add a "green light" to the outposts, because there are many ways in which the status might be "not OK", so it's not something you can check with a simple condition.

You should check:
  • Does the train station combinator output a station number?
    If not, then it's not yet part of the train line. I recommend you add the station to the train line before you even add power to the outpost. Always do that first.
  • Does the register contain any large values?
    If yes, it should be reset. A large "green signal" value should be OK though, it doesn't do anything in the register and it will be cleared eventually. I might be wrong about that, however, just be safe and always clear the register if they happened to accumulate bogus values.
  • Is the train station circuit connected to the depot (via the red wire)?
    The easiest way to check this is to see if some of the combinators do have "D=1" as their input.
There's really not much more that will go wrong in an actual game, provided that your blueprints are OK and that you do not accidentally change the circuits.

In my last game, after I had fixed all the bugs, anything that went wrong was ultimately due to some error on my part, when I tried "clever" things or simply forgot something.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
SootStack
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Aug 12, 2016 3:46 pm
Contact:

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

Post by SootStack »

How much of the circuitry could be rolled up into the smart trains mod? is there a real need for the combinators to exist?
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 »

SootStack wrote:How much of the circuitry could be rolled up into the smart trains mod? is there a real need for the combinators to exist?
Everything could be rolled into a mod, or SmartTrains, easily.

But that's not the point, because then you could write mods for all sorts of complicated things, that would basically play the game for you.

SmartTrains is deliberately limited in functionality, so that there's something left for the player to do, and problems to solve. This entire project (which was very interesting to build and to discuss with others) would not exist, and I would have stopped playing Factorio long ago, if SmartTrains actually solved this problem for me.

I hope that answers your question :). (And no, I'm not against mods, at all, I use lots of them, but there should still be a game.)
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
SootStack
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri Aug 12, 2016 3:46 pm
Contact:

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

Post by SootStack »

SmartTrains is deliberately limited in functionality, so that there's something left for the player to do, and problems to solve. This entire project (which was very interesting to build and to discuss with others) would not exist, and I would have stopped playing Factorio long ago, if SmartTrains actually solved this problem for me.
Totally understand that. Largely the reason I ask is because the solution is also given in the post, which kind of takes that same joy away from me. If I take the blue print and slap it down, to me there is little difference between the train stop being more intelligent and not =/.
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 »

SootStack wrote:If I take the blue print and slap it down, to me there is little difference between the train stop being more intelligent and not =/.
Yeah, but that's not a problem for ME, because I built it from scratch, and that was fun and proof that I can do it. :D

However, there are endless possibilities to extend, optimize and improve the system, or even build your own just taking my existing implementation as an inspiration.

Now, of course you could do all this in the form of a mod, but that would not be Factorio, it would be LUA coding. Which is fine, if you want to learn that.

The lines are really blurred in an extensible sandbox game like Factorio. In a way, a lot of this, even the LUA programming, could be considered "playing" the game or simply being involved with it. You need to decide yourself what is fun for you. There have been quite a few people who didn't seem to mind at all that they just used my blueprints in their own game, without really understanding the circuits in full. It should also be said that it's not quite that simple, you still have to put quite some work into getting to grips with it and learning to handle the installation (just ask doxsroxs).

The fact that the combinators are really limited in isolation, but still allow you to build everything digital (in theory, cf. Turing Completeness), gives rise to a lot of projects that are not easy to do, even if you have the right idea -- because the implementation itself is tricky. Those kinds of problems are everywhere in Factorio, and it's what keeps the game interesting for a long while. Take "megabases" for example: in theory they are "easy" (just build a large base), but when you actually attempt it you'll find there are lots of implementation problems that you still need to solve to make the end result satisfactory.

In this particular case (train scheduler), the accomplishment is to take a rather simple addition from the mod (being able to send a train directly to a station, which might as well be a part of the Vanilla game, and it's not unlikely it will be at some point), and use this simple mechanic in addition with a complex combinator setup to solve a real problem in the game.

In other words, taking the very primitive components (the not-so-smart-train-station and the rather-dumb-combinators) and combining them to make something clever, that's what has made this interesting. In addition, when I started this project it was way less complex, and I just wanted to see if I can do it. I was very proud of even my first version, and thought it's the limit of what's feasible, but then I've learned you can take it much further. So the fun was in the process and in the learning.

Another great example is the superb smart furnace that XKnight has built a few weeks ago. It's completely combinator-based, and he does pull a lot of strings to make it happen. It's hands down a lot more clever than my train scheduler (XKnight is a lot better with combinators than I am). If you look at it, it really leaves you in awe, but if somebody made that with a mod it would be kind of "meh".
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

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

Post by steinio »

I would also prefer a mod with this features because i want to play factorio casually and not fiddle endless hours with combinators which can break easy by deleting a wire accidently.

So the task would be to undertstand the blueprint and transfer it into lua code :geek:

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts
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 »

steinio wrote:So the task would be to undertstand the blueprint and transfer it into lua code :geek:
An extension/fork of SmartTrains would be the easiest way I guess. The train station needs some additional way of taking input from the outpost, because the amount of material in the buffer is relevant. You also need to be able to specify a list of requested material in the requester station.

Probably another modded combinator or two at the smart train station would be necessary (to provide with a separate input port). The red wire bus would become redundant with such a mod because the mod would coordinate the train distribution.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick
Acarin
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Thu Sep 01, 2016 3:58 pm
Contact:

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

Post by Acarin »

Ok, I am now officially uber-frustrated! I have spent somewhere in the region of 20 hours over the last week _just_ trying to get this to work on 3 different maps. I have ripped apart my entire network several times, and the same thing keeps (not) happening: the Depot doesn't release a train (or give a yellow indicator light).

I followed the instructions (I think), set up Depot + Lanes, I have 3 Requesters (stone, iron, copper) which are stations 2, 3 & 4, and I have added my iron Provider (station 5). All of the circuit signals seem to me to be what I would expect, but it ain't despatching a train.

Any ideas?

https://steamcommunity.com/sharedfiles/ ... =782834977

(Try it that way, lol)
Last edited by Acarin on Mon Oct 17, 2016 9:33 pm, edited 1 time in total.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

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

Post by steinio »

Oh hello.
Are you from Australia or why is your screen upside down?

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts
Acarin
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Thu Sep 01, 2016 3:58 pm
Contact:

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

Post by Acarin »

LMAO -that's what I get for posting with my iPad *sigh*. Lemme try again...
KudoBear
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Sep 27, 2016 6:19 pm
Contact:

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

Post by KudoBear »

Acarin wrote:Ok, I am now officially uber-frustrated! I have spent somewhere in the region of 20 hours over the last week _just_ trying to get this to work on 3 different maps. I have ripped apart my entire network several times, and the same thing keeps (not) happening: the Depot doesn't release a train (or give a yellow indicator light).

I followed the instructions (I think), set up Depot + Lanes, I have 3 Requesters (stone, iron, copper) which are stations 2, 3 & 4, and I have added my iron Provider (station 5). All of the circuit signals seem to me to be what I would expect, but it ain't despatching a train.

Any ideas?

https://steamcommunity.com/sharedfiles/ ... =782834977

(Try it that way, lol)
The lane dispatch signals run on their own dedicated red/green circuit network. You connected the green, but not the red. In your picture, see the big electric pole in the bottom right corner of the concrete platform? From it, run the red to the big pole to the right of your lane 1 (don't cross it with the main red bus!) and the dispatch should work if everything else is set up correctly, which at a glance looks like it is.
Post Reply

Return to “Combinator Creations”