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.
LoveJoyDK
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun May 22, 2016 8:04 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by LoveJoyDK »

Well I am back at the beginning again, rethinking it all.
Because I have just noticed the signal line # in smart trains. It is in upper left corner in the lines rules menu. And the train will tell the smart station what line it is from.

So now I am trying to figure out how this can be used to handle several depots.

This is a short post because I have just now noticed it, and this is how far I have gotten so far. :)

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

Post by siggboy »

Oh wow. I was actually thinking at one point what that might be for... and then never thought about it again. But you are right, this might open new possibilities.

The problem is that it's not really documented -- and the default line number is "0", so by default the station does not output any line number at all, making the feature quite invisible until you start using it :).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

LoveJoyDK
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sun May 22, 2016 8:04 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by LoveJoyDK »

After a workday with a colleague who kept talking, I still think I have an idea.

I think the most simple will be to add a green line to the bus. Move the trigger out of the depot, and just let it constantly send out 1-100 on the bus. One trigger to rule them all. :)

Translate signal line # into the symbol numbers, part of the hex system. Then just place the translated line number = -1 on the green wire. Then make stations only listen on red wire when a signal on green = signal in there constant combinater box.
And almost leave the rest as usual on red wire. We might even drop the locomotive signal, as the break in line signal symbol could be used instead of locomotive signal at the station. The line signal symbol should switch to station number to tell witch station it picked to send train to, and make others fitting the line symbol stop listening.

Or the green wire could be used to transmit a sequence of numbers from the outpost after the line symbol switch to only one stations number ;)

The station could send out ore amount it expect to send of as one tick on green wire, witch the unload station will use for controlling the load on it's way in.


--
Having so much fun with this game, and I do not even have it running.
Shame though, no time or energy to do some actually testing of this until weekend. :(

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

Post by siggboy »

Alright boys, we're getting fairly close to handing in the main quest!

I've extended the setup and now the unload stations (= Requesters) can request items, and the trains will deliver them. This is very close to a Logistic Network (with trains), the only thing that's missing is resource counting.

The depot circuit has grown (a little) to ~20 combinators, the outpost circuit is still the same size. The unload stations only require a small circuit of 5 combinators. Everything runs on a red wire bus, as before, so there is no need to lay green wire.

I have also made a completely new demo map, that shows off all the new functionality in a toy factory. The factory produces Red Circuits, and the entire production chain (excluding oil) is shipped around with trains.

Please check it out, it's really neat (if I may say so). I consider this a beta version; there might still be bugs, keep that in mind if you use the blueprints in your game.

If you have a map you want to upgrade, you need to replace the depot circuit and all outposts (= Providers) with the new versions.

I will provide a complete documentation for everything, like in the original post, but this will take a while because all the diagrams need to be redone and I'm currently lacking the energy.

Required mods (for the demo map) are SmartTrains and Test Mode, you should use the mod pack that is attached to the original post.

Update: Please use the latest pre-release of SmartTrains (it contains a fix for a bug that affects the setup): https://github.com/Choumiko/SmartTrains ... ag/v0.3.93

Blueprints:
Depot V2
Provider V2
Requester V2
The rail network on the demo map is not exactly efficient. Also, the trains (deliberately) only ship very small amounts, in a real game this will be different. If you want to stress test the system, you should create artificial demand by taking items from chests, etc. Just play around with everything.
Attachments
Smart Train Demo V2.zip
(1.97 MiB) Downloaded 243 times
Last edited by siggboy on Sun Jun 05, 2016 6:27 am, edited 1 time in total.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

jhyatt
Burner Inserter
Burner Inserter
Posts: 19
Joined: Thu Oct 09, 2014 8:06 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by jhyatt »

Looking good i am going to play around with this in my map. I would like to see a second depot that runs a green buss. i have this set up in my map specifically for oil since i need empty barrels delivered to each depot.

Great job.
Thank You

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

Post by siggboy »

If you have both a green and red bus it's of course no problem to run two of the setups in parallel. I don't think it's worth it only for oil.

It's not possible to have a station that is both a provider and a requester at the same time, but something like it is required for smooth handling of oil barrels (empty and filled).

In my current game I have a simple setup for the oil (I could have used Rail Tanker but I wanted to play around with barrels in this game). There is one line for the train(s) that collect the full barrels and another line for the train(s) that distribute empty barrels to the outpost. There's a separate loading/unloading station for both lines, to keep things simple. SmartTrains tells you what logical line a train is on, so at the outposts I can distinguish between trains that bring empty barrels and trains that pickup oil. I made a small circuit for the outposts that will maintain a total count of 100 barrels (full and empty).

Then I just have a train (or more) running the full tour on each line.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

NoriSilverrage
Fast Inserter
Fast Inserter
Posts: 159
Joined: Mon Mar 21, 2016 1:19 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by NoriSilverrage »

Looked at the demo. Pretty nice stuff.
One thing I was wondering though is in the smelting area, if I take all of the iron ore the setup ends up needing 3 trains to get it back up to 300 despite the trains taking 200+. I'm not sure if that was/is just a simple setting though.

Also if the smelting area gets to below 300 it seems to normally send 2 trains as well. I didn't get too much time to play with it though so I may be missing something.

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

Post by siggboy »

You're not missing anything.

One thing that the system does not do, is resource counting. So when a requester station signals demand, then the depot will send a train to fill the order. Now a train is on the way, but the order "remains open", so to speak. The demand does not suddenly disappear. That's why the depot will usually "overfill" the orders, usually by one train, then usually the demand will be met and the requester won't ask for more items.

What does not happen is that more than one train goes to a provider simultaneously. However, as soon as the first train has finished loading, and left the outpost, another one can be sent (if the outpost still has material).

Now, on the demo map, the trains only ferry 200 units -- I've set it up this way on purpose, so the network will be under stress and it's easier to observe the behaviour of the setup.

If the smelting area has 0 iron ore, and then asks for 300, this already requires 2 trains (if they only pick up 200 units each time). However, the bots immediately take some of the ore to the smelters, and we already drop below 300 again. More trains are sent. That's why it looked to you as if they do not really fill the order.

You can set the limits (what the trains will pick up, and what the requesters will order) to more realistic values, for example "1500" for the pickup (one wagon load), and then the entire system becomes a lot more stable and efficient.

The problem with that is that not a lot will happen for stretches of time, and that makes for a bad demo.
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

Post by siggboy »

By the way, I think there is a problem with the trains sometimes getting stuck at providers. The signal is erased before the train actually left the outpost, and then it will stay there forever (because it doesn't know where to go).

This seems to be a problem with SmartTrains sometimes signalling that the train has left when it doesn't. Pretty nasty, maybe we'll get a fix for SmartTrains, otherwise I'll have to devise a workaround for this.

I've changed the train-has-left detection slightly, maybe it has to do with that, too. The circuit itself is correct, though, or it would not work at all.

Choumiko has also said that he might give us a feature that allows for much easier detection of a train leaving the station. Then this problem would surely go away.
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

Post by siggboy »

siggboy wrote:This seems to be a problem with SmartTrains sometimes signalling that the train has left when it doesn't. Pretty nasty, maybe we'll get a fix for SmartTrains, otherwise I'll have to devise a workaround for this.
I just confirmed it is indeed a problem with SmartTrains. It sometimes appears as if the train arrives very quickly twice in succession (so to the circuit it looks like the train has left, then it does go into an incorrect state and trains start piling up, and don't know where to go).

The SmartTrains signal goes No Train> Train > No Train > Train for a single arrival of the train (when it should simply be No Train > Train).

This can be fixed by changing the circuit that detects when a train leaves, but I'll file a bug and maybe Choumiko can fix this issue. It does not seem to be due to the new version (old version was affected, too).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

kann_
Inserter
Inserter
Posts: 44
Joined: Fri Apr 15, 2016 4:36 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by kann_ »

siggboy wrote:The SmartTrains signal goes No Train> Train > No Train > Train for a single arrival of the train (when it should simply be No Train > Train).
This didn't happen with my version of SmartTrains, but I didn't update for a while. Are you sure it is not due to a signal right next to the station?
Btw. my outposts keep track of the trains that are send to them. Feel free to copy that part. Although I am not sure if the blueprints still work. I really should have made a test map like you, but I was too exhausted from the building at the time.

I thought about using barrels for oil, but it seemed a waste to one train to bring barrels and leave empty and a second train to come empty and leave with oil.
Basically I have two main stations now. One for oil trains and one for normal trains. I use oil tankers, but a train with empty barrels is the same thing.

I thought about combining both stations and adding a detection mechanism for the type of train, but than they block each other. There is really no way around separated systems for the train types. Unless you accept that there will be two trains moving for every load of oil.

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

Post by siggboy »

Yo, kann_, first of all let me say I still owe you a longer reply to your initial post here regarding your train scheduler that you posted about on Reddit. The short version is that I like it a lot and I don't think it's using too many combinators for what it actually does. You should make more detailed documentation about it, maybe with diagrams. Not only for others to read but also for yourself, in a few months you will need it if you want to continue working on your system.
kann_ wrote:This didn't happen with my version of SmartTrains, but I didn't update for a while. Are you sure it is not due to a signal right next to the station?
I do have signals right next to my stations but that can't be the reason, because the problem only sometimes occurs; it's kind of random. It also happens even if the stations are completely isolated, with no other train passing the signal behind that station, so I really don't think it has anything to do with the signal.

In any case, even if there is a signal right behind the station, the train should always stop exactly ONCE, then wait for a signal AT THE STATION (not the rail signal, the station signal), then leave. Currently what happens is that the train actually stops TWICE (or more often, can't really say, I assume it's twice).

The problem with that is, if you use any kind of simple edge detection that waits for the "Train-at-Station" signal to go from "1" to "0", then your edge detection will also trigger twice -- and that fools the circuit into believing that the train has left the station, when in fact it is still sitting there waiting for a signal.
Btw. my outposts keep track of the trains that are send to them. Feel free to copy that part.
I have a few more ideas for how to extend my system, but this is the one thing which is absolutely last on my list. Keeping track of trains is only useful in the most extreme cases (when you have cleared a 5000x5000 grid on the map and your ore fields are massive). In 99% of scenarios (even megabases), if your trains are long enough (4 wagons or more), then it does not really improve performance to have "train pipelining" (as I like to call it).

This is NOT to say that the depot won't be bottleneck in megabases, it probably will when you have a lot of trains -- but train pipelining will not help at all in that case.

Train pipelining also complicates a few others matters quite a lot, so I'll probably never add it to my system.
I thought about using barrels for oil, but it seemed a waste to one train to bring barrels and leave empty and a second train to come empty and leave with oil.
Basically I have two main stations now. One for oil trains and one for normal trains. I use oil tankers, but a train with empty barrels is the same thing.
I'm not managing barelled oil at all with the logistic train network. It would require stations that can be requesters and providers at the same time (or modify all your trains to have an extra Rail Tanker wagon, which is really ugly).
I thought about combining both stations and adding a detection mechanism for the type of train, but than they block each other. There is really no way around separated systems for the train types. Unless you accept that there will be two trains moving for every load of oil.
What I want to add after 0.13, because it will be completely awesome, is that the providers can provide more than one type of resource.

For example, an Oil Refinery could provide Plastic Bars and Sulfur.
Or your mining outposts could provide multiple ores (that's useful with certain mod packs).

The problem to solve is that when a train arrives it is not supposed to pick up everything at the provider, but only the resource that was ordered for that particular roundtrip (unless you allow mixed wagons, but that is completely nuts). So the provider needs to be told what type of resource the incoming train wants to load (that's really easy because the information is already on the wire, we only have to use it). Then we also need to program the inserters at the provider to only load that particular resource on the train.

With 0.13 we get those high performance inserters that are also programmable, so it will be perfect to implement this.

The other thing I want to add is resource bookkeeping for the requesters (I think you already have that in your system), so that the requester will discount the resources it's about to receive. This will make the scheduling a bit more "tight", but it's not really super important. It makes it pretty but does not really improve performance by that much.

Many of these "advanced" featured that make the system look awesome (like train counting, resource flow prediction, etc.) really do nothing for the performance of the system; I want to add the stuff first that makes the scheduler more useful and more powerful.
Last edited by siggboy on Fri Jun 03, 2016 11:20 pm, edited 1 time in total.
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

Post by siggboy »

The problem with the SmartTrains "Train" signal is fixed in the latest pre-release of SmartTrains.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

NoriSilverrage
Fast Inserter
Fast Inserter
Posts: 159
Joined: Mon Mar 21, 2016 1:19 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by NoriSilverrage »

So some probably dumb questions. Was fooling around with this last night and was wondering if it is possible to have more than 1 depot? I'm guessing if the yellow signal was change to say red then it could work right?
Is there a limit to the number of stations usable?

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

Post by siggboy »

NoriSilverrage wrote:So some probably dumb questions. Was fooling around with this last night and was wondering if it is possible to have more than 1 depot? I'm guessing if the yellow signal was change to say red then it could work right?
The short answer to that is "no".

The slightly longer answer is, that it's not enough to simply change the polling signal from "Yellow" to something else. This is because the new depot will still see the responses that are sent to the old depot. So one depot will be polling with "Yellow" and the other one with, say, "Red", but both depots will see ALL the responses and this will not work at all.

The easiest fix if you need a second depot is to use a green wire bus, which will be completely separate (but you will have to change the circuits so they will work with a green bus, it's not done by simply switching the wire color. A quick solution is to put drivers in front of the circuits that will recolor red->green for you (I haven't tested it but it should work, it might break due to the tick delay but it shouldn't).

I guess you want a second depot so you can handle Oil. If it's only for throughput reasons (have more trains being sent simultaneously), let me assure you you won't need that until your base is really, really big.

Having multiple depots that are all part of the same line, so you can send more trains at once, is possible but I haven't thought about it yet -- there might be complications that are not obvious.
Is there a limit to the number of stations usable?
No, there is no practical limit. There is a limit to the counter at the depot that you can simply increase. It is only there to make the polling slighly more responsive (it hardly matter). I think I have it set to "30" in the blueprint of version 2, it can be much higher if you need it (in version one the default was "100").

In my current game I'm approaching 30 stations so I will have to increase that value.

You could have 100 outposts if you wanted (in that case the polling with take about 50 ticks on average for requester and provider, so 100 ticks on average total, that's about 1.7 seconds).
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by sparr »

How would the demand signaling work for intermediate products that are demanded by multiple stations? If I have two stations that want to demand green circuits, what would I have to do to get the train leaving the green circuit outpost to deliver to the right one?

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

Post by siggboy »

sparr wrote:How would the demand signaling work for intermediate products that are demanded by multiple stations? If I have two stations that want to demand green circuits, what would I have to do to get the train leaving the green circuit outpost to deliver to the right one?
In version 1 (the version attached to the OP) there is no clean solution for this -- which is why I've made the new version.

You have to use the new version of the setup (version 2), there you have two types of stations: "requesters" and "providers". In your example you set up the stations that demand green circuits as "requesters", and you input a signal "Green Circuit = 1" to the requester station when you want that station to request green circuits.

For example, in my current game I need coal in various places (smelting area, power plant, main base, refineries), so in each of these places I have a "requester" station that requests coal.

I also have a requester station in my main base that requests several products (green and red circuits, plastic bars, ...); this is possible, too. The requester can "flag" demand for as many products as you want. Obviously in this case the unloading has to include a sorting facility (usually robots), because the trains come with the various goods and simply dump them into the station.

When 0.13 is released I will make a multi-product provider as well; but this requires the new programmable inserter, so the trains are loaded with the correct product.

You should download the demo map for the new version and there you can try this out. But please use the most recent pre-release of SmartTrains, not the one that is included in the mod pack.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

NoriSilverrage
Fast Inserter
Fast Inserter
Posts: 159
Joined: Mon Mar 21, 2016 1:19 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by NoriSilverrage »

siggboy wrote:
NoriSilverrage wrote:So some probably dumb questions. Was fooling around with this last night and was wondering if it is possible to have more than 1 depot? I'm guessing if the yellow signal was change to say red then it could work right?
The short answer to that is "no".

The slightly longer answer is, that it's not enough to simply change the polling signal from "Yellow" to something else. This is because the new depot will still see the responses that are sent to the old depot. So one depot will be polling with "Yellow" and the other one with, say, "Red", but both depots will see ALL the responses and this will not work at all.

The easiest fix if you need a second depot is to use a green wire bus, which will be completely separate (but you will have to change the circuits so they will work with a green bus, it's not done by simply switching the wire color. A quick solution is to put drivers in front of the circuits that will recolor red->green for you (I haven't tested it but it should work, it might break due to the tick delay but it shouldn't).

I guess you want a second depot so you can handle Oil. If it's only for throughput reasons (have more trains being sent simultaneously), let me assure you you won't need that until your base is really, really big.

Having multiple depots that are all part of the same line, so you can send more trains at once, is possible but I haven't thought about it yet -- there might be complications that are not obvious.
Is there a limit to the number of stations usable?
No, there is no practical limit. There is a limit to the counter at the depot that you can simply increase. It is only there to make the polling slighly more responsive (it hardly matter). I think I have it set to "30" in the blueprint of version 2, it can be much higher if you need it (in version one the default was "100").

In my current game I'm approaching 30 stations so I will have to increase that value.

You could have 100 outposts if you wanted (in that case the polling with take about 50 ticks on average for requester and provider, so 100 ticks on average total, that's about 1.7 seconds).
Hmm, bummer. I wanted to separate out my coal/oil. I have 4 coal dropoff points that get decent traffic and my oil dropoff has 4 locations as well. All of these are on the opposite side of my, rather large, base from the depot location.

I was also thinking it would just be nice to split up iron/copper production as at have 16 dropoff locations for the two of them. So yeah, the train line for that will be huge already without putting coal/oil on it.
Well I'll probably just end up running a green wire then.

Thanks

kann_
Inserter
Inserter
Posts: 44
Joined: Fri Apr 15, 2016 4:36 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by kann_ »

I was thinking about the problem of supplying several depots in my setup as well.

A neat solution would be to have all with the stations with the same name and use the "signal" function or the "leave when empty" of the SmartTrains station to block the depot stations that are "full". So one train would be blocking each station that does not request more resources. Hopefully the trains find their way to the station that was requesting the resources.

I never tested it and probably it will not work, but depending on the train network it could.
The main reason why I never tested it was that I don't want trains getting stuck in the network.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by sparr »

Could multiple depots work with something like a bitmask? Give stations a number then logical-AND that number with some bits that represent the depot(s) that should service the station, and have the depots filter the requests and availables they listen to based on that bitmask.

Post Reply

Return to “Combinator Creations”