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.
terror_gnom
Fast Inserter
Fast Inserter
Posts: 117
Joined: Wed Apr 06, 2016 4:01 am
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by terror_gnom »

siggboy wrote: Or else you'll solve problems that don't exist and you'll end up with 50-combinator circuits that are impossible to debug.
yay :D Thats what I´m going to build :P

A real "logistic network" with trains, that can handle every Item, multiple train-types (like Oil-train, 1-2-1, 1-4-1, FARL etc) and multiple trains running to the same unloading/loading (I call them requester/provider) station.

My "controller" does have ~20 combinators per train station (probably a lot that are unnecessary) only for the memory of all relevant amounts...

Poorly I do nearly 0 progress the last few weeks because I´m pretty busy at the moment and in those 3-6h per week I have time to build I rip up lots of the circuits to improve things or make stuff possible I like to include (before anything is running at all) :P

If you´re going to work/play on a MP-map, please post/pm the address ;) Probably I´ll join when I have time. If you need a TS3 server, PM me (I dont like to post the address public, because I had bad experience doing so)

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 »

terror_gnom wrote:A real "logistic network" with trains, that can handle every Item, multiple train-types (like Oil-train, 1-2-1, 1-4-1, FARL etc) and multiple trains running to the same unloading/loading (I call them requester/provider) station.
I'll be excited to see how you handle multiple train types on the same logical line, because I think that's not possible (maybe with a new version of SmartTrains it will be possible, but certainly not right now).
Poorly I do nearly 0 progress the last few weeks because I´m pretty busy at the moment and in those 3-6h per week I have time to build I rip up lots of the circuits to improve things or make stuff possible I like to include (before anything is running at all) :P
In my experience it's very time consuming to get it "right", it's more difficult than it first looks, especially if you try to solve "impossible problems" :).
If you´re going to work/play on a MP-map, please post/pm the address ;) Probably I´ll join when I have time. If you need a TS3 server, PM me (I dont like to post the address public, because I had bad experience doing so)
I'm all for a co-op map, kann_ wants one too. TS3 is not needed anymore, use Discord. Also there are lots and lots of free public TS3 servers, no need to give your private one to anybody if you don't want to.

I've never played multiplayer Factorio, but we can have a nice playground and compare our different solution on the same map. I doubt a truly cooperative effort of designing a circuit will be fruitful, it's too difficult and it's not possible to point out circuit related things inside the actual game.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

mikegrb
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu May 19, 2016 2:33 am
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by mikegrb »

Great work! You forced me to finally register for a forum account. I set this up in my factory and it worked beautifully until I hit 13 stations. When I hit 13 stations I started getting issues where if station 6 & 9 were both available (they have the same resource), the depot would send a train to nonexistent station number 16. Since this ends up sending the train to the next station in the normal station list I ended up making that a station on the waiting line to return to the depot.

I went through a lot of debugging, visited every single outpost to make sure the number was correct, disconnected all of the stations and reconnected them to the network one at a time, etc. It seems that somehow some stations are responding together causing the counts to get added. It happens most often when all resource demands are met for a bit and trains have gone idol. Once it starts firing trains off rapid-fire numbers get added. If I manually redirect the trains coming out of the depot to different stations, the train assignments start working again as most of the outposts are busy so fewer are responding. Any pointers for debugging? Trying to debug single tick signals is a real pain it seems.

Here's a shot of my circuit network, it's mostly a straight line with a line coming off for each outpost.
Image

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 »

mikegrb wrote:Great work! You forced me to finally register for a forum account. I set this up in my factory and it worked beautifully until I hit 13 stations. When I hit 13 stations I started getting issues where if station 6 & 9 were both available (they have the same resource), the depot would send a train to nonexistent station number 16. Since this ends up sending the train to the next station in the normal station list I ended up making that a station on the waiting line to return to the depot.
This must be a timing problem. I'm not happy at all right now, because I was sure this couldn't happen in the current version of the circuit.
It seems that somehow some stations are responding together causing the counts to get added.
Yes, indeed, but that should not be possible because the outposts are polled in sequential order. It's a multiplexing bus protocol; I do not have an actual demultiplexer, but the outpost responds with its own station number, so I get that information along with the resource flag. There's no possibility for mismatch.

It looks to me as if station 6 is already in the buffer register and it doesn't lock down the register properly and also adds station 9. That would result in a station "15" but you get station "16". Maybe the register write protection is not working properly.

I would have to debug this on the actual map, or make a test map myself.

Can you send me the save game, and maybe an archive with all the mods that you are using?
It happens most often when all resource demands are met for a bit and trains have gone idol. Once it starts firing trains off rapid-fire numbers get added.
There's not really a "rapid-fire" of trains because there's always a few seconds space between one train and the next, even if they are already lined up in waiting. That wouldn't play a role.

I assume you only have a single depot station, not several? (The circuit won't work with several depots sending trains off in parallel.)
Any pointers for debugging? Trying to debug single tick signals is a real pain it seems.
Yes, single tick is hard to debug; well, circuits are hard to debug in general, because there are no debugging tools available. Somebody needs to make a mod that can record values on the bus over several ticks. The closest thing to a "debugger" is setting the game speed to really low (1/8th, I don't know if lower is possible), that makes it a bit easier to observe single ticks.

As for pointers for debugging: look at the circuit diagram and try to understand everything. I think this is timing related or a bug with the register that I made (on the depot end). You could also change the station numbers (by inserting some dummy stations) and look what happens, i.e. if the same two stations still get added, resulting in the expected value.

Unfortunately this is very inconvenient to do on a real map with distance between the outposts, so I don't recommend it, really.

I'll run some tests on my demo map. Thanks for the feedback.
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:Maybe the register write protection is not working properly.
This is indeed NOT working correctly in the current design and needs to be fixed (I've worked it out on paper and not run any tests yet).

If stations "7" and "9" are ready, the register write protection will not prevent the "9" from being written to the register that already has a "7" in it. In this case the "9" won't overwrite the register but the values get added together, resulting in a "16" which would then be taken as the destination. That's completely wrong. If such a station exists the train will happily go there and pick up any resources available, so nothing will break, but of course it's not the intended behavior at all.

It still doesn't make sense, though, that you get a "16" from a "6" and a "9". Are you 100% sure about those numbers?

In any case, a change has to be made to the current version.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

mikegrb
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu May 19, 2016 2:33 am
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by mikegrb »

siggboy wrote:If stations "7" and "9" are ready, the....
Sorry, rapid fire wasn't quite the right term. This is what I was trying to get at, when most stations were ready because no trains had been sent in a while.

Edit: This is why it was once I hit 13 outposts I started seeing it. That's the point resource demands were being met and outposts started to get periods of idle time allowing multiple to become ready at the same time.
siggboy wrote:It still doesn't make sense, though, that you get a "16" from a "6" and a "9". Are you 100% sure about those numbers?
Sorry, I was tired, yes 7 & 9.

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 »

mikegrb wrote:Sorry, I was tired, yes 7 & 9.
No worries, thanks for reporting the problem.
I think it can be fixed by connecting the inputs of combinators #5 and #6 in the depot circuit with red wire (or connect the red output of #4 to the input of #6, which amounts to the same). I have not tested it yet, but you can try the fix on your map, it's only one wire connection and only in the depot, therefore easily applied.
Edit: does not seem to work :(. I need to keep looking

Edit 2: OK, I've found a fix. Another combinator (dummy comparator) needs to be added in addition to adding the red wire connection between #5 and #6. This will fix the write protection in the register for the station number.

The comparator needs to output identity (e.g. "Each > 0 ==> Each"), it's only to keep the Yellow signal on the input for one tick longer.
Screenshot.png
Screenshot.png (178.78 KiB) Viewed 7351 times
I'm not entirely happy about this, but it's the best I can do for now.

Updated blueprint for the depot:

Code: Select all

H4sIAAAAAAAA/8VY226kOBD9lYjHHRhhoG+aZZ72L0arlgNOtyWwkTFJWoh/XwM9HdrYYLuT2aeoQ1XZPlWnTtk5fSpoBounY9oiwjHHqE7blsASpV5GSc0h
4UFGy2dMIKfM8ytaCytK0vY9DZLvG/+SBvH3Tee/4IIj1nvX+ERgkbb8Uokor5jxBhaePwYdPwYXVBT0zev8jDaEp0l0SA7bbXTY+pjk6D0FnW8U559bCHD1
jLpO+I5Gz/gUoAJlnOEsqGiBpP3H/e6TPgIhwkr8W+z/lwe8f9OWoVycZQDlcsR5GoGum4QuUY6bcil6/AHOzavmDOLTmQfiTyFtZttbR52fYzbuRRzFxC9x
9Ivc/EI3N8fVlg63Xp+bMQVhX58mOQaRn2GWNZgPv4Z86+oac1T+LkbMKAkoQ4pilMt46pbRqkJM6RhPSi1HGc6FnfaYfRkPZ/xAaWtc0/6JIUQWYBgI9cuL
lAHCOWBi4Rxf171uPW1fMKv50YTRkFz4GZPTAMmYYFEBINkl+3ib7MU/ywqyHoXUSz2fNrxqzCKjV8QmsavLccD8+MJoecREhEk9zhqRjA/sIcP8XCIuGL4I
fyDhH5nVWzjBVpEHsIzux+ZsAEYwO0/BvWG786koRzjs3/vLDtoh5gS3dW6GttxMzLlppDnAUmqeiwZJgrWLDhuF7KwRNnTlK4jFGhP2xRJPVVxO7m30/mCJ
55pGocjJg/S/oXytzvAPE74uIeNBL0gkqDmt5ioWakRMcgwqRt8vkvtKzc8RjvbLCF8/qhGeak0vrcH4WQ/vzyUkxgMFGWQnen8sYH8sC6FV53bYxhs8iXX0
pAST40wBUM1pMiGtJSByUYCZgCpYdm+zKMfbrxAMsYqAuEZ9JOMKM5ASrbPt7AOctBfoGyM46BqjogfObC16oDVD7RrgmDlN53uBRX3X+tavNMHI9MhYs6UB
xjcVpvtfe7n+reaz0JmbBwN53d1vdWesqLJ2fwpVx24NuWjYA/ke4u03q1obhdtyCjJirsncoYNZtvS1IjRPgcP0Mhkxr/QFoSyx9qAaM3i1W44PNpoXD4Xy
bD5LeRywlO8pj+B4i2U0AxqJTuLUUmSYVHIvt50F8YmWyvuRlDiMjjb5mPDkkyq7T0nsNAccFnRoswBvsq4OFvx5ZIow7kV3Gfv7y+9SJgqQuNyDY3kiVmEf
6XMXz56ttHlZuX855MVUo5dHOtc82o2EhuNV7PT4uDMYr7Yrk6Dlg4WcTn+x79pNZPqWaZ1ey8tTjlGNiqCgIkeU41e7OWxonZvH1UxDQ62azaLJbwKr0YB5
s55fIdy0UAH1//dWZdJfNybUVABtfpGZWX5Fh9Ro2FdchzsfZ8PO2+sj0u8g8sugMP3BEG8YeTr+QCT/D3odvc9NHQAA
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

mikegrb
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu May 19, 2016 2:33 am
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by mikegrb »

siggboy wrote: I'm not entirely happy about this, but it's the best I can do for now.
It works, that's the most important part.

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 »

mikegrb wrote:
siggboy wrote: I'm not entirely happy about this, but it's the best I can do for now.
It works, that's the most important part.
I'm sorry that you went through the frustration of trying to debug your train network because of that blunder. Thanks for actually using this on a real map and demonstrating that it works in "real life".
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 »

siggboy,

i can confirm the error i have implemented it in a real map here: https://www.dropbox.com/s/8iw1fi7duqx1j ... a.zip?dl=0
my mods here: https://www.dropbox.com/s/jk13bqwzeyjkz36/mods.zip?dl=0
here is the save with the fix not tested yet. https://www.dropbox.com/s/wtxynvxyyk1fs ... b.zip?dl=0

hope this helps.

Great job Thanks

Edit 1:

i don't the trains going all the way to the outposts yet i have them going just south to the smelter. so its not that far to check thing s out.

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 »

@jhyatt Thanks for posting the map. I could reproduce the wrong behavior on my demo/sandbox map, so I'm almost certain that the fix solves the issue.

If you want confirmation if the fix works for you, you can do this (it sounds more complicated than it really is, and you don't have to do it since I've already run the same kind of test on the sandbox map):

1. Force all trains back to the depot by connecting the "reset constants" to the red wire bus (the reset constants are "D 1" and "Yellow -1000"). The negative Yellow signal will ground the multiplexing, and so the outposts won't be able to send data to the depot. The "D 1" signal will reset the outposts so they'll accept trains again, even if they were previously "locked" by an incoming train.
2. Now you need to wait for all trains to deliver their resources to the unload and return to the depot.
3. When all trains have returned you should wait for a minute or two until all outposts have build a buffer of resources. At this point, all your outposts would report "ready" if they were triggered by the depot.
4. Now you need to create a "gap" in the list of outposts. For example, if you have outposts 4, 5 and 6, all of which are "ready" now, then disable outpost "5" (disconnect it from the bus) so the list will become "4" and "6". This is the condition that caused a problem.
5. Disconnect the "reset constants" from step 1 so the trains will resume normal operation.
6. The first train should now run to outpost "4", assuming that is the first available outpost, and not outpost "10", as it would have before the fix. Here I suppose you actually have outposts numbered 4, 5 and 6, and did disable outpost "5" as suggested in step 4.
7. Fix confirmed, reconnect outpost 5.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

lychee
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun May 22, 2016 12:46 am
Contact:

Re: Smart, dynamic train deliveries with combinator Magick

Post by lychee »

Hey siggboy, I made my own version of smart trains, if you are interested in taking a look. It works slightly differently, but I took ideas from everyone's implementations, hopefully someone might find parts of it useful.

Here the trains wait at the outpost for the base to signal that it needs a certain resource. When that happens, check if train is full, if it is, send the train off and send the station number back to the depot. The depot stores this in a memory acting as a queue.

After the unloading at the depot, the trains are sent to a dispatcher that sends trains to the first station number in the memory, and erases it from memory.

With the way it works now, you basically have to send a certain number of trains at each station, and the system will maintain that number, so it seems kind of a huge roundabout way to just have dedicated lines for each outpost, with the only difference being that trains might switch between outposts. However it should be possible to add logic to the outposts to change this number as necessary.
Attachments
ST1.1-demo.zip
(5.75 MiB) Downloaded 124 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

Post by siggboy »

Hi lychee, I'm personally always interested in others' designs, and if this thread becomes a dumping ground for smart train designs and an area for where to discuss them, that's splendid.

As far as your system goes (if I understand you correctly): it's a mixture of "dedicated lines for each outpost" and the "one train line" philosophy. As far as I can see your solution is not easier to implement, than, say, mine, but you are missing some of the benefits. For example you have a lot of idle trains at all the outposts, so you need to put more trains on the line than needed -- and there will always be idle time for some of these trains, unless your outposts produce faster than the trains can carry, but that normally means your trains are too small.

At the end of the day, there are several design philosophies you can follow in order to solve the train management problem.

What is the best approach also depends on the size of your base: very large bases with long distances to the outposts need to allow for "train pipelining", i.e. sending two or more trains to an outpost in succession, because the travel time is so long that the outpost would overflow if you limited it to one train.

Anything smaller than a megabase does not require this, unless you force the issue by deliberately running trains that are too small.

Then there are examples of over-engineering, where you solve the problem in a "perfect" way but in reality there is no difference to the less-than-perfect solution. One example (I think) is trying to visit all outposts equally often by randomizing the selection process, or some other scheme. So you might not visit the first outpost that has a resource, but instead you visit the outpost with the most of that resource, or you pick a random one, or you pick the one that you haven't visited for the longest time.
All these approaches would make the system "more balanced", but not really make a difference as far as solving the actual problem goes (which is "meet the factory demand", and not more).
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 »

Hi guys.

I like this system and wants to implement it on a running map. So far I figured out how it works, and do not work.

I have the traditionally ore mine outposts, with L-CCCC loading and I have L-CCCC ore offloading. I can even make it pick where to unload, just by replacing the unload station with a decider smart station, to pick where the full train should go. ;)
All in theory, still not got to actually implementing it yet.
Because, and here is the problem, I have L-CC trains with empty barrels for oil and I have L-C with landmines and ammo, and those can not be in the same depot lineup as L-CCCC trains.

So my plan was to make a new line for each category of trains. With each line having each own depot. But after using a test circle on my own map, I find that trains on one depot will mess up other depots handling of own business.

So how to make different lines and more depot on the same network?

If I replace the symbols: yellow trigger, station number, rail signal and locomotive with new unused symbols would I be able to make a new line running on it's own signals? Have I found all the unique identifier?
or will a "full oil barrel 1" signal still send of a train from other depots?

Could I replace the everything * (very large number) with an item * (very large number) for each item type the depot should react on to prevent it to react on full oil barrels 1?

Should a different set of symbols not make a new depot posible?

LJ

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 »

LoveJoyDK wrote:I like this system and wants to implement it on a running map. So far I figured out how it works, and do not work.
What you're trying to do is not easy, but possible and I think you're going in the right direction.

I think it's important for you that you read ALL of the documentation in the original post in this thread and try to understand what is going on, or else you will not be able to debug your changes if you make a mistake.
So my plan was to make a new line for each category of trains. With each line having each own depot. But after using a test circle on my own map, I find that trains on one depot will mess up other depots handling of own business.
We run a multiplexing protocol on the red wire bus, and if you make additional depots this means you run the same multiplexing protocol several times, and that's not possible. That's like trying to have several separate conversations on the same phone line.
So how to make different lines and more depot on the same network?
Well, one possibility is, of course, to run another, completely separate network with a GREEN wire bus instead of a red one (if you have green wire between the stations...). You would still need to change the blueprints for the depot and the outposts that need to be on green wire, but it will work, and it will be completely separate from the existing network.

That's probably not enough for you, since you want to create an additional two networks, so not enough wire colors in the game :).
If I replace the symbols: yellow trigger, station number, rail signal and locomotive with new unused symbols would I be able to make a new line running on it's own signals? Have I found all the unique identifier?
or will a "full oil barrel 1" signal still send of a train from other depots?
  • Yellow = polling signal for the multiplexing protocol (will count through all the station numbers)
  • "Rail Signal" = outpost sends this back, it's the number of the outpost (= station number in SmartTrains)
  • "Locomotive" = it's what the depot sends to say to an outpost "a train is coming"; it's the same number as the "Rail Signal" just in the other direction
  • Any resource that is announced will have a signal as well, "Iron", "Coal", ... everything that is not already in use is possible.
  • The "D" and "Green" signals go over the wire, but can be ignored ("D" is for resetting the outposts, and "Green" is not used). You should not use either of these (Green might be OK but I haven't checked).
  • The "train station" symbol is not sent over the wire, so it does not need to be changed (but you cannot use it on the red bus).
The "Red" signal is not allowed on the red bus, it would mess with the logic that remembers the station number in the depot (a fix for this could be made, and in version 0.13 is will be a very easy fix).

OK, so if you want to establish another multiplexing protocol you have to change these (Yellow, "Rail Signal", "Locomotive") and not use "Red", "Green", "D" and "Train Station". That should work.

(For example, you can use any of the "Number" symbols, like "0", "1", "2". They are guaranteed to be free.
Could I replace the everything * (very large number) with an item * (very large number) for each item type the depot should react on to prevent it to react on full oil barrels 1?
Yes, that's already how it's supposed to work anyway. You put "Item = 1" for every item that your depot is interested in. It's no change from my version. But you do not change the arithmetic combinator that does "EACH * 2^31-1", what you change is the INPUT to that combinator (in my blueprint it's a constant combinator with "Iron 1; Coal 1; Copper 1", but in a real game these values will come from the unload or the factory).
Should a different set of symbols not make a new depot posible?
Absolutely, if you make no mistakes this is possible.

Please tell us how it goes, it's an interesting extension to the existing system.
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 »

Damm. I was in my bed when I just had to check the forum on my tap. :)
Yes, that's already how it's supposed to work anyway. You put "Item = 1" for every item that your depot is interested in. It's no change from my version. But you do not change the arithmetic combinator that does "EACH * 2^31-1", what you change is the INPUT to that combinator (in my blueprint it's a constant combinator with "Iron 1; Coal 1; Copper 1", but in a real game these values will come from the unload or the factory).
Not sure I understand it right yet then.
What makes the depot only accept ore signals? I can see the constant combinator with "Iron 1; Coal 1; Copper 1" but that one is to be removed and its signals to be replaced with signals coming in from the factories right?
Or is the factory signals going to need it's own green cables to bring it's signal to the arithmetic combinator that does "EACH * 2^31-1"? I thought it was supposed to pick up the signal from the red network.

Also if I have two depots both reacting to my oil offload station sending out full oil barrel=1 signal, and I have two depots both doing "EACH * 2^31-1" because they both have a train waiting at the station.

This is from your first post:
"Ore = -2^31", which we ignore; we already know that we want this resource or the combinator would not output anything
What makes the depot only accept ore signals? I can see the constant combinator with "Iron 1; Coal 1; Copper 1" but that one is to be removed and it signals to be replaced with signals coming in from the factories right?
Is it sure that it is not going to make a false output of anything at the wrong station?


--

Oh, and another thing , When my oil offload station sends out full oil barrel = 1, I guess it would still be sending that signal until a train arrives to unload. Meaning, it would send off other trains to other stations with oil ready until the first train turns off the signal by offloading. Or what did I misunderstand there?

Or maybe I should had stayed in bed. :)

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 »

Just an idea. Could we just make each line use a different serie of yellow triggers?
One line/Depot use 0-99 and another 100-199 and so on. Then a stationnumber woul be like 5 and 105.

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 »

LoveJoyDK wrote:What makes the depot only accept ore signals? I can see the constant combinator with "Iron 1; Coal 1; Copper 1" but that one is to be removed and its signals to be replaced with signals coming in from the factories right?
Or is the factory signals going to need it's own green cables to bring it's signal to the arithmetic combinator that does "EACH * 2^31-1"? I thought it was supposed to pick up the signal from the red network.
This is explained in the OP, but I'll try again, it's not easy to understand. Please read the original explanation again if you still do not follow.

Look at the "outpost data filter" in the upper left of the depot diagram (with circuit numbers #1 and #2).

The important one is the circuit #2, it does the following: "IF anything = -2^31 THEN output everything".
This circuit gets two inputs: (1) everything from the red bus and (2) the value "2^31-1" for EVERY resource that we are interested in

Now, an example, to make it easier to understand:

Assume that the only resource we are interested in is COAL. So one input to the combinator #2 needs to be "COAL = 2^31-1".
Now we poll the outposts by counting Yellow on the red bus, and all the outposts will reply, one after the other.
Let's assume outpost number 7 is a coal outpost and it does have coal for delivery. So it will reply with "COAL = 1; RAIL SIGNAL = 7". This is the information for the depot that says "Outpost number 7 does have COAL".
This signal also gets input to the combinator #2.

So now the combinator has the following inputs: COAL = 2^31-1 ; COAL = 1 ; RAIL SIGNAL = 7
The two COAL signals will be added together inside the combinator. 2^31-1 + 1 = 2^31 = -2^31 (because all numbers >= 2^31 are negative numbers!)

So our resulting signals (inputs to combinator #2) are: COAL = -2^31 ; RAIL SIGNAL = 7 (and any other signals that might be on the red bus during this tick)

Now look again at the condition of combinator #2: "IF anything = -2^31 THEN output everything". The condition is now true, because COAL ("anything") is -2^31, so the combinator will let all signals pass, including the RAIL SIGNAL, which is what we are interested in. We store the RAIL SIGNAL in the next step.

So, why did we get "-2^31" as a result? Because we set COAL = 2^31-1 and added COAL = 1 from the outpost. If COAL is not 2^31-1 then we can not get the result, and then the station is ignored.

Therefore, you need to send a signal of RESOURCE = 2^31-1 to the depot for all the resources that you are interested in. IT DOES NOT MATTER how, and where you generate this input. It does not matter what wire you use to transmit it. The only thing that is important is that the input goes into the combinator #2 from the diagram.

To make it a little easier, the combinator #1 does the multiplication with 2^31-1, so you can simply input "RESOURCE = 1", which is easier to remember and I wanted to make the depot circuit easy to use.

Read this, and the original documentation as often as you need until you understand, because it's really all I got for now...
Oh, and another thing , When my oil offload station sends out full oil barrel = 1, I guess it would still be sending that signal until a train arrives to unload. Meaning, it would send off other trains to other stations with oil ready until the first train turns off the signal by offloading. Or what did I misunderstand there?
This is exactly correct. You did not misunderstand.

The current system does not keep a record of goods that are currently being transported. So the unload station does not "know" that soon a train will come with the oil, and it will continue to request the oil until the train has unloaded.

I'm planning to make a better design that does some accounting with the resources to limit this effect. But it's making the system more complex and I want to keep a balance of complexity and functionality.
LoveJoyDK wrote:Just an idea. Could we just make each line use a different serie of yellow triggers?
One line/Depot use 0-99 and another 100-199 and so on. Then a stationnumber woul be like 5 and 105.
Yes, this could work, but currently it's not possible to set the station numbers directly in SmartTrains. So you cannot set a "100" for a station, you would need to add 99 stations to the list so you will have a "station 100". There will be a future version of SmartTrains when you can set numbers, then it will be possible what you have in mind.

(It's possible with the current version but you need to make ugly workarounds for SmartTrains, I don't recommend 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 »

Yes I should have stayed in bed. :)

I realized the error in the series idea short after light was out. The triggers will be added together when 2 depots are working at the same time. Doh!. Though I was planing to do some -0/+0, -100/+100, -200/+200 internally in the stations.

Anyway, you are never obligated to explain anything in length. I just took up the idea from an earlier post to make this a place to share and discus. That does not mean I will not appriziate any effort in that regard. :)
I am just starting to dig into the combinators in factorio, so it is more assumptions than knowledge on my part so far, sorry.

I have been reading all the post here more than once. But one thing I somehow picked up on early is this one.
Flexible: the system is not limited to ore, it can be used to ferry intermediate products, too, even on the same logical line with the ore trains.
I think that sendt me to fantasy lala land, fantasying about sending green circuits everywhere. :)

Anyway, I am here as much to put my ideas in words, as much as to get them commented. I hope that is okay.

And about ideas, I did a lot of thinking at work today. Do not tell my boss. He do not pay me for thinking.! ;)

I think I could use the locomotive signal to stop sending request for more ore, by subtracting the expected load of the outgoing train at the offloading station. Thereby make the calculation for ore need take into consideration the load in the train sendt out. But still have to figure out how to link it with the right ore type.

I have also considered making a green bus, instead of a red bus. And then make a coder/decoder circuit to put between the green bus and the depots/stations. By doing that I would leave your work intact. (Read: I know that work, and I have no mistakes to fix there.) :), But I am unsure how to make sure everything stays on the same right tick of the counter. The signal one tick wide thingy.
But I would make the coder/decoder circuit with a constant combinator for each signal that needs to be unique to it's own train line. and then let it translate the signals recording to the input used in the combinators. Making a one way circuit should be easy, not sure same goes for a both way translation. But I might be thinking about that at work tomorrow. :)



Until thinking at work I thought the fictive need in the demo / blueprint is just the constant combinator. But actually it is also the "each * 2147483647 output each" combinator.
The "each * 2147483647 output each" combinator. should actually be part of the circuit at the unloading station, asking for the ore. Putting the signal ore=2147483647 on the red wire bus, so it will be added to a responding ore=1 on the same tick, triggering the"IF anything = -2^31 THEN output everything".

But putting it into words here, I do believe I got it right this time.

On another note:
I do actually have an abandoned headless server running. Would just be a question about map, mods and a restart. Never used test mode mod. I just cheat myself to complete all research from the beginning. :)
And I use a mod named foreman for blueprint strings, but it does not work on MP.

What mods would be recommended for a semi test server.

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 »

LoveJoyDK wrote:
Flexible: the system is not limited to ore, it can be used to ferry intermediate products, too, even on the same logical line with the ore trains.
I think that sendt me to fantasy lala land, fantasying about sending green circuits everywhere. :)
That's not fantasy land, that's possible. You can make a loader for circuits (at the circuit factory) and an unloader (at another factory that makes stuff with circuits), it's not different from ore and smelting of ore.

The major restriction right now is that you need to make the connection between load (provider) and unload (requester) in the setup of SmartTrains. So when you have multiple unloaders for the same product then there's no clean solution anymore (some hacks are possible, but nothing pretty and balanced).

Since you've already started thinking about the problem you see that it's not easy to solve (well at least not by adding, like, 3 combinators and be done).
Anyway, I am here as much to put my ideas in words, as much as to get them commented. I hope that is okay.
Yes. Half of what I write I actually write to myself, so I can understand the problem better and maybe read it 6 months from now when I will have forgotten what I did there...
I think I could use the locomotive signal to stop sending request for more ore, by subtracting the expected load of the outgoing train at the offloading station. Thereby make the calculation for ore need take into consideration the load in the train sendt out. But still have to figure out how to link it with the right ore type.
This is what I have in mind as well. The ore type should not be a problem because the unloading station knows what the ore type is. You don't need the information, only the amount.

Unless you have mixed goods unload, but that's a different ball game (I currently assume each unload can only request one type of item).

But you cannot use any of these signal (Locomotive, Rail Signal, ...) on the red bus in that way, because if you're unlucky you send it during the same tick as another outpost, and then the signals get added on the wire and it breaks. This is impossible to debug, because it will happen randomly.

If you run multiple protocols like this on the same wire they all need to use entirely different "alphabets", because otherwise collisions are always possible. It does not matter how rare they are, unless they are astronomically unlikely you have to avoid them. (By "astronomically" I mean: so unlikely that you'd have to play for 1000 years to observe the event once or something like that.)
I have also considered making a green bus, instead of a red bus. And then make a coder/decoder circuit to put between the green bus and the depots/stations. By doing that I would leave your work intact. (Read: I know that work, and I have no mistakes to fix there.) :),
Currently I do not want to extend my system to require green wire as well, but if that opens a way to make it more powerful while keeping the simplicity I will do it. If you use FARL it makes no difference if you draw red wire or both red and green, it's automatic.

(Thinking about it, it's probably dumb not to always draw red and green wire along all railways, because it costs practically nothing and it might be useful some day; replacing the wire after the rail network has become big is a lot of work.)
But I am unsure how to make sure everything stays on the same right tick of the counter. The signal one tick wide thingy.
If you look in this thread you will find a link that user kann_ has posted to his own creation on reddit. He's using a multiplexing protocol that involves a receiver (decoder), and he does have a link for that, too.
Putting the signal ore=2147483647 on the red wire bus, so it will be added to a responding ore=1 on the same tick, triggering the"IF anything = -2^31 THEN output everything".
Yes, that works, you can put it on the red bus like you described. However, if there are several unloads for the same ore, you cannot add the values together. For example, if you have 2x iron unload, and they both request iron ore, then the value still needs to be 2^31-1 in total, not 2x 2^31-1. So you need to combine the two signals with a circuit before putting them on the red bus.
What mods would be recommended for a semi test server.
I don't play on servers, but the mods are used are exactly those in the OP. In fact I use the demo map from this thread and the mods for all my experiments in Factorio right now.

There are some mods that I've skipped that are useful: JasonC has made a great mod for picking up items (like test mode but with much better UI), AutoFill is good too, maybe even some Bob's Mod stuff with faster belts and inserters and OP robots, large trains etc -- so you can test all the possibilities.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

Post Reply

Return to “Combinator Creations”