During a recent discussion in one of the many splitter-suggestion threads it has become clear that the exact splitter functionality is not quite as simple as it seems at first glance. Since it was off-topic in that thread, I'm making a new one to discuss the exact algorithm that the splitter uses.
At first glance it might seem that the splitter simply alternates between the left and right output, for each input item. With only one type of item, this is what it does. Lets have a look:
A splitter with a balanced feed of 1 item type. Every other item goes to the other output belt. Items stay on the same lane
Because in this screenshot the input is perfectly balanced between the left and right lane, it seems as though the splitter splits the lanes: Items on the left lane go to the left output belt, items on the right lane go to the right output belt. This is just an illusion. Adding 1 single extra item to the input belt will make the output pattern switch around. (ToDo: add screenshot)
Now lets replace all items on the right half of the input belt with copper. If the splitter simple alternates between the left and right output belt we would expect all copper to go to the right belt, since that is where the iron plates went, that we replaced with copper.
The output pattern completely changes! Instead of sending items left - right - left - right, it now sends left - left - right - right. The splitter alternates each item type independently. If you only look at the copper, it goes left - right - left - right. If you only look at the iron it also goes left - right - left - right. If you look at both of them, it goes (iron)left - (copper)left - (iron)right - (copper)right.
If we add even more item types this becomes even clearer:
(Image by ssilk)
The first four items (one of each type) go to the right. The next four items go to the left.
One last image by ssilk:
Here we have two copper plates in each group, so the first plate goes to one side, the second plate to the other. The iron plates seem to go to the "wrong" side, but iron is actually the first item in each group of four. You can see that on the previous image.
Conclusion:
To me it seems the splitter has an internal state for each item type: Did the last item of that type go left, or right? The next item of that type is then sent to the other output belt.
Update:
The splitter also counts items, if one side of the splitter is blocked. Once that side is unblocked, it will receive up to 5 items before the other side starts receiving items again:
The exact inner workings of the splitter
The exact inner workings of the splitter
Last edited by DrNoid on Sat May 24, 2014 2:24 pm, edited 1 time in total.
Re: The exact inner workings of the splitter
After what you showed in the topic, I was in a bit of disbelief. But I found it too after doing some testing.
Ignore this
Re: The exact inner workings of the splitter
Just for fun:
Re: The exact inner workings of the splitter
This is, what fascinates me every time, when it is found: I play that for more than a year and I didn't saw it. Sometimes I looked at the splitter and thought "Uh? interesting....". And at first I really thought DrNoid is just one of those, who doesn't understand the splitter, but it was me.
I'm sure there are more of such "hidden" stuff in the game.
I'm sure there are more of such "hidden" stuff in the game.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: The exact inner workings of the splitter
Kovarex mentions some inner workings here.
[Resolved 0.3.2] Splitter error - not splitting
[Resolved 0.3.2] Splitter error - not splitting
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Re: The exact inner workings of the splitter
I moved this to general, cause the help board is for getting help, not sending unneeded help.
------
Interesting, this means, that it tries to keep the balance up to a difference of 5 items.
------
Interesting, this means, that it tries to keep the balance up to a difference of 5 items.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: The exact inner workings of the splitter
How does it decide which input to take from? It seems one side only gets taken from if there is a gap in the other.
Re: The exact inner workings of the splitter
The inserters has a preference for input on the left side. So if the left input is at 100% capacity, nothing from the right input will be taken. Only the left lane will be able to flow through. You can take advantage of this for some applications, such as a buffer on the side.
Build a splitter that puts 25% of all stuff in chests. Then add inserters to take the stuff out of it. Place another splitter to join the buffer again, but let the main line be on the left input, and the buffer on the right. This way, when the left(main) belt gets a bit empty, the buffer will be able to fill it. Hopefully for long enough for you to work on the supply problem.
Build a splitter that puts 25% of all stuff in chests. Then add inserters to take the stuff out of it. Place another splitter to join the buffer again, but let the main line be on the left input, and the buffer on the right. This way, when the left(main) belt gets a bit empty, the buffer will be able to fill it. Hopefully for long enough for you to work on the supply problem.
Ignore this
Re: The exact inner workings of the splitter
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Re: The exact inner workings of the splitter
Oh, you didn't know?ssilk wrote:This is, what fascinates me every time, when it is found: I play that for more than a year and I didn't saw it. Sometimes I looked at the splitter and thought "Uh? interesting....". And at first I really thought DrNoid is just one of those, who doesn't understand the splitter, but it was me.
I'm sure there are more of such "hidden" stuff in the game.
I remember kovarex talking about it.. (rk98's link)
Agreed, that the picture with all-distict items nicely illustrates the point
Re: The exact inner workings of the splitter
Thanks for that link, it contains some more info. I've added an illustrating screenshot to the first post, for that counting behaviour.rk84 wrote:Kovarex mentions some inner workings here.
[Resolved 0.3.2] Splitter error - not splitting