Durr wrote: Fri Jan 21, 2022 5:50 pm
tldr: Can someone help me figure out how the combinators in this setup works, and if there's a way to optimize them?
I was tinkering with some combinators yesterday for a few hours and eventually stumbled upon a configuration that did what I wanted it to do. But looking at it now, I'm not entirely sure how it actually works.
I'm not entirely sure what each combinator do and why it was used this way, i recognize in your sentence what i do when trying out things. Sometimes it works after you changed that little thing here and this other thing there and also this, and now you have something that you wouldn't have come up with from scratch which makes it difficult to read since it's something [thing] with [patch 1] [patch 2] and [patch 3] applied on top of it and one doesn't know what the patches were trying to fix, or if [thing] was done differently [patch 3] wouldn't be needed but you didn't noticed earlier because it only became aparent after [patch2] and now you're left wondering why things are this way and not sure if you could change things ( at least that happens to me

)
From the way the whole system function i recognize it because i have done something similar though not starting from the same goal (
viewtopic.php?f=194&t=100617&p=556666). One can simplify it considering each station is a "cell" with a unique number. Then a train goes to visit every cell from the same group before cycling again. This is done by "soft" disabling a station that has been visited by a train until receiving a reset signal. In your example you have 3 "main" station at the top side sending a different reset signal to their dedicated column of 3 receiving stations.
This means if you call your upper most station A and then the other 3 under it station1 station2 station3, that a train should do A=>1=>A=>2=>A=>3=>A=>1.... Which is what you described.
On a circuit logic the 4 chests and the 4 inserters act as memory, it allows each station to have a different state, wether it has already been visited by a train and is waiting the reset signal, or if it hasn't been visited and is therefore set with a limit>0 depending on which chest is containing the blueprint.
The tricky part is the implementation of this logic. How do you make the reset signal work properly. Which you further complicated by using only 1 wire to transmit all data onto the same network. Which you explain yourself :
Durr wrote: Fri Jan 21, 2022 5:50 pm
The concept is that I have all my receiving stations for a particular product named the same ([Iron] Receiving), but I want to make sure all of them are serviced once before any station is serviced for a second time. This was easy enough to do by outputting a value of 1 on the signal for that item if the station needs service, and then canceling that signal with a value of -1 when the station is serviced, and then resetting all of them with the signal reaches 0.
To make it more complicated, I wanted to have 3 signals on the same signal, so I could have [Iron] Receiving P1, [Iron] Receiving P2, and [Iron] Receiving P3, and have them serviced independently of each other. My solution was to have the P1 stations use values from 1-99; P2 stations using values 100, 200, 300, 400, through 9900; and P3 stations using values 10000, 20000, 30000, 40000, through 990000. Combined, the full signal could look something like 120305, meaning 12 P3 stations need service, 3 P2 stations need service, and 5 P1 stations need service.
From what i see in your blueprint the use of value 10000 20000 30000 40000 and so on are for now used to choose a target for a train. 4 different numbers meaning 3 intervals ( from 10K to 20K is 1 train, from 20K to 30K is another train and so on). And inside of those range you have used 1 2 3 to name the different stations 1 train could visit. So this would mean 10001 10002 and 10003 can only be visited by 1 train and once all stations belonging to the range [10000 20000] have been visited once , it reset and they are all open again. I'm not sure it is exactly 100% what your wording describe. But also i'm not sure i have 100% understood well your blueprint
I understand this is the tricky part

On the link at the top of the post my example uses a minimalist setup for the memory and signal filtering which i think is very similar to what your blueprint is doing. Except in your system with your goal you reset the state of stations once the trains goes back to the main station after each of the 3 similar have been visited whereas in my system the reset occurs after each arrival to a station ( but you can easily configure it to do 1=>2=>1=>3=>1=>4=>1=>2=>1=>3=>1=>4 ..... like yours ). I think my exemple is easier to understand it because there is very few signal isolating required which makes the memory/reset part quite optimized in number of combinators/wire/inserter/chest.
Now there is also a different approach instead of looking at it from far away to get the big picture, if one focuses on the last sentence and the problem of isolating numbers on a network which i learned on this forum through this thread :
viewtopic.php?f=193&t=100784
It may not be straightforward how it relate at first, but if one continue to analyze your blueprint as a system that transmit adress store them in memory, and sometimes reset them and all that to guide trains. Then this discussion especially the latest post where it comes down to the binary operation can be seen as powerful tool to help organize all this information on the network and it's the purpose of the different filters of the discussion to isolate numbers on a network

. [making sure the reset signal don't add up which in your case is particular because it would seem that the reset signal is "no value on green"].
One thing that come to mind especially with the use of the binary form of the number is that it allows you to send numbers in a form that would look like this 101220, and it would be 10-12-20. You can pack 3 small numbers in 1 larger number with easier method than when you use the decimal form of the number like when you do 10001 10002 and it should be read as 10000-1 and 10000-2.
In short each number in the network can be considered as a block of 32 character 0 or 1 which is the binary notation of the number we read as player when hovering over a power pole. This is pretty advanced so this resume of the other thread would probably make sense only if you are already familiar with the notions , if you are interested i could try to explain more in detail though

. In binary form if you write a number using the 16 first character, and another number using the 16 following it is easier to recover the 2 number with combinators than if you use decimal numbers. This is because you can use "bit shifting operation" " >>" and "<<" which allows you to read only the 16 first bit, or only the 16 last bit when used this way. And you can use number like 2^16 or 2^5, which correspond to a 1 at the position 16 or at the position 5 in the 32 characters.
So for example A= 2^5 + 2^6 + 2^7 . This means you write a "1" in position 5 6 and 7. Then if you do A>>4, You have the "1" in position 1 2 and 3 instead. the operation ^and >> are possible to use on arithmetic combinator. While on decimal it correspond to A= 32 + 64 + 128 so A= 224 and after the operation that only makes sense in binary the result would be A=14. because 2^1 + 2^2 + 2^3 = 2+4+8 = 14.
Now hopefully it make sense when you consider 224 is also 0000 0000 0000 0000 0000 0000 0111 0000 and 14 is also 0000 0000 0000 0000 0000 0000 0000 0111 in binary if you write the whole 32 character. In this example you can consider instead of 1 or 2 or 3 as number to identify a station. You use 2^5 and 2^6 and 2^7. ( or 32 64 and 128 ). Why ? well because 1+2=3 but 32+64=/=128 ! If you want to call station 1 and station 2 at the same time, you don't call station 3 by mistake ! 0 risk even you let the signal add up. You can easily recover the information you want.
In other word the way you choose your range of number in your blueprint 10000 20000 30000 40000 make sense in decimal but makes for complicated operation in combinators. But if you where to try out with powers of 2 instead and think about the binary form. Then it would require less combinators. The isolating numbers part of the problem could be simplified in wiring by using powers of 2.
Is that answering your questions or where you more interested into the frame by frame operation that occurs for each combinators and signal value of your blueprint ?
[Edit] Oh and in case it wasn't obvious after that novel, i found your system very interesting ! cool stuff
