The exact inner workings of the splitter

Post all other topics which do not belong to any other category.
DrNoid
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Tue Apr 22, 2014 10:43 am
Contact:

The exact inner workings of the splitter

Post by DrNoid »

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:
Image
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.
Image
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
(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:
Image
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:
A splitter shortly after a blocked side was unblocked
A splitter shortly after a blocked side was unblocked
Splitter_Madness_7.png (223.92 KiB) Viewed 8949 times
Last edited by DrNoid on Sat May 24, 2014 2:24 pm, edited 1 time in total.
Gammro
Filter Inserter
Filter Inserter
Posts: 361
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

Re: The exact inner workings of the splitter

Post by Gammro »

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
DrNoid
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Tue Apr 22, 2014 10:43 am
Contact:

Re: The exact inner workings of the splitter

Post by DrNoid »

Just for fun:
This splitter, it won't split!
This splitter, it won't split!
Splitter_Madness_6.png (195.08 KiB) Viewed 9406 times
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: The exact inner workings of the splitter

Post by ssilk »

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. :D

I'm sure there are more of such "hidden" stuff in the game. :roll:
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: The exact inner workings of the splitter

Post by rk84 »

Kovarex mentions some inner workings here.
[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
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: The exact inner workings of the splitter

Post by ssilk »

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.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
Fossil
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Feb 15, 2014 11:52 pm
Contact:

Re: The exact inner workings of the splitter

Post by Fossil »

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.
Gammro
Filter Inserter
Filter Inserter
Posts: 361
Joined: Wed Oct 09, 2013 1:45 pm
Contact:

Re: The exact inner workings of the splitter

Post by Gammro »

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.
Ignore this
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12889
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: The exact inner workings of the splitter

Post by ssilk »

Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...
MF-
Smart Inserter
Smart Inserter
Posts: 1235
Joined: Sun Feb 24, 2013 12:07 am
Contact:

Re: The exact inner workings of the splitter

Post by MF- »

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. :D

I'm sure there are more of such "hidden" stuff in the game. :roll:
Oh, you didn't know?
I remember kovarex talking about it.. (rk98's link)


Agreed, that the picture with all-distict items nicely illustrates the point
DrNoid
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Tue Apr 22, 2014 10:43 am
Contact:

Re: The exact inner workings of the splitter

Post by DrNoid »

rk84 wrote:Kovarex mentions some inner workings here.
[Resolved 0.3.2] Splitter error - not splitting
Thanks for that link, it contains some more info. I've added an illustrating screenshot to the first post, for that counting behaviour.
Post Reply

Return to “General discussion”