Page 1 of 1

[Solved] Help me understand how combinator works

Posted: Fri Aug 07, 2015 2:11 pm
by DOSorDIE
I can programming (Autoit) so i know how i would solve my problem with it

But in Factorio there is only < = > ... i missing =< => ...

So here is my problem:
I want to balance the both production that the same number are in the box.
As example 20 pipes and 20 gears or 50:50 or 200:200 no limit
The problem is that the pipes are produced double so fast as the gears (Yes i make this intentionally to test the setup)
I found solutions but they stoped when are both the same ... and never start again.

EDIT:
To make it clearer what i want:
I want to balance the production from 2 items (here its pipes and gear as example)
It should work when the chest is empty
I want to take out zb. 50 gear and the gears stop and pipes start to production until its sync.
I want to give 50 pipes in and the pipes stop and gears start to production until its sync.

EDIT2:
Thanks for all Explanations
Here are my solves:
A: 1:1 Ratio
Balancer2.jpg
Balancer2.jpg (105.05 KiB) Viewed 13502 times
B: 3/1 Ratio
Balancer3.jpg
Balancer3.jpg (136.12 KiB) Viewed 13502 times
C: 2/1 Ratio with limiter and Optimised Input & Output
Balancer6.jpg
Balancer6.jpg (136.73 KiB) Viewed 13502 times

Re: Help me understand how combinator works

Posted: Fri Aug 07, 2015 2:33 pm
by DOSorDIE
So first try by myself.
I must multi it by 10 but when come not a full number like 0,4 it doesnt work ...
EDIT: When 1 is emty it doesnt start ... grrr :evil:
Balancer.jpg
Balancer.jpg (200.12 KiB) Viewed 13694 times
But i think its not the easiest setup.

Re: Help me understand how combinator works

Posted: Fri Aug 07, 2015 5:43 pm
by Gus_Smedstad
I can't understand why you're trying to use division or multiplication to solve this problem. This is the simple comparison of two numbers.

Since you want "<=", the solution is to test ">" in a decider, and then have the smart inserter work when it's false.

Decider 1: Pipes > Gears : Blue = 1.
Inserter 1: Insert if Blue = 0.
Decider 2: Gears > Pipes: Green = 1.
Inserter 2: Insert if Green = 0.

I tested it and it works fine. It's a little chunky and slightly slow, since it takes a tick for the state to change, but it works.

Re: Help me understand how combinator works

Posted: Fri Aug 07, 2015 11:41 pm
by Zhab
Well I'm not sure what you want exactly.

Possibility 1) You want the box to contain exactly 20 pipes and 20 gears.

left inserter) If pipe < 20
right inserter) If gear < 20

Production of pipes will stop at 20 and production of gear will stop at 20. Both will be equal at 20.

Posibility 2) You want to slow down pipe production to follow gear production so that numbers of pipes vs gears are always equal.

left inserter) if pipe < then gear

This will force pipe production to slow down and follow the speed of gear production.



All that being said, the reason why pipes are produced faster is because a gear require 2 iron plates. But they both only have a normal inserter to get components. Give your gear assembler a second inserter to take iron plates and it will work at the same speed as your pipe assembler. No need for combinators or even smart inserter or smart box.

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 12:58 am
by DOSorDIE
Zhab wrote:All that being said, the reason why pipes are produced faster is because a gear require 2 iron plates. But they both only have a normal inserter to get components. Give your gear assembler a second inserter to take iron plates and it will work at the same speed as your pipe assembler. No need for combinators or even smart inserter or smart box.
I know how i sync this ... but i want to know how can i make a usefull setup with that combinators.

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 1:04 am
by Zhab
DOSorDIE wrote:I know how i sync this ... but i want to know how can i make a usefull setup with that combinators.
What about what I just suggested. Did you reject them simply because no combinator were involved ? If you want to use combinator this badly. You could do the following.

Possibility 1) You want the box to contain exactly 20 pipes and 20 gears.

Combinator 1) If pipe < 20 then A = 1
Combinator 2) If gear < 20 then B = 1

Left inserter) if A = 1
Right inserter) if B = 1

Production of pipes will stop at 20 and production of gear will stop at 20. Both will be equal at 20.

Posibility 2) You want to slow down pipe production to follow gear production so that numbers of pipes vs gears are always equal.

Combinator 1) if pipe < gear then A = 1

left inserter) if A = 1

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 4:22 am
by Gus_Smedstad
Zhab wrote:Posibility 2) You want to slow down pipe production to follow gear production so that numbers of pipes vs gears are always equal.

Combinator 1) if pipe < gear then A = 1

left inserter) if A = 1
The reason I didn't suggest this, and the reason I'm not fond of this solution, is that I can envision a broad range of cases outside of this narrow test setup where this would fail. For example, if the box is already full of gears, which are being extracted slowly. In that case, no pipes ever make it into the box, because the gear assembler keeps topping up a partial stack of gears. Or, for example, if the two assemblers aren't supplied with the same source of metal plates, and the pipe assembler is starved for some reason.

Assuming that it's OK to leave the gear assembler alone just seems bad practice, if it's really all that important to keep the two production lines in sync.

The other issue is that he's clearly asking "how do I make a <= comparison," which you're not really answering. Sometimes someone asks a question not because they want a solution to the example problem, but because they want to understand a principle. Of course, he did ignore my answer to that specific question, and he seems to have some trouble communicating what he wants in any case.

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 5:57 am
by vampiricdust
Well, if you're talking making them without a cap, then....

A) 1:1 ratio would need 3 deciders.

*gears* > *pipes*, output *gear* = 1
*pipes" > "gears", output *pipe* = 1
*gears* == *pipes*, output *gear* = 1.

Set your smart inserters to run when their item == 1 for pipes & > 0 for gears. This is without a cap limit. If you want to set a limit for this, you'll need to change 2 of the deciders to check each item is under the cap leaving 1 comparison. So they'd look like this:

*gears* > *pipes*, output "pipe* = 1
*gears* < cap, output *gear* = 1
*pipes* < cap, output *pipe* = 1

Set the gear inserter to run when *gears* == 1 and the pipe inserter to run when *pipes* > 1

B) if you want 3 times the amount of pipe of gears, you can do one of two ways, multiply the gears by 3 and do a comparison of that or divide the pipes by 3 and then compare that.

Arithmetic:
*pipes* x 3, output *pipes*

Decider:
*pipes* > *gears*, output *gears* = 1
*pipes* < *gears*, output *pipes* = 1
*pipes* = *gears*, output "pipes* = 1

Run the inserter for gears when *gears* == 1 and run the pipes inserter when *pipes* > 0

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 1:22 pm
by DOSorDIE
Gus_Smedstad wrote:I can't understand why you're trying to use division or multiplication to solve this problem. This is the simple comparison of two numbers.

Since you want "<=", the solution is to test ">" in a decider, and then have the smart inserter work when it's false.

Decider 1: Pipes > Gears : Blue = 1.
Inserter 1: Insert if Blue = 0.
Decider 2: Gears > Pipes: Green = 1.
Inserter 2: Insert if Green = 0.

I tested it and it works fine. It's a little chunky and slightly slow, since it takes a tick for the state to change, but it works.
That work great and is easy to build ... and it also start when the chest is empty.
Thank you

Now it a little bit clearer how i can use this ...
Now looking for the other solves.

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 2:22 pm
by DOSorDIE
The others setups work in the most cases but not all.
So i extended Gus_Smedstad version with a 3:1 version that work great ...

EDIT: Simplified it
Balancer3.jpg
Balancer3.jpg (136.12 KiB) Viewed 13546 times
I think i have understand the basics of the combinators ... it is much cleaner now for me!
And now a limiter and im happy ... but i think i can now make it by my own ...

Re: Help me understand how combinator works

Posted: Sat Aug 08, 2015 7:59 pm
by DOSorDIE
And here the 2:1 with Limiter
Balancer5.jpg
Balancer5.jpg (139.05 KiB) Viewed 9954 times
Only need to simlplified it and optimise inputs

Re: [Solved] Help me understand how combinator works

Posted: Sat Aug 08, 2015 9:28 pm
by DOSorDIE
Simple and easy to copy version with less possible changes
Balancer6.jpg
Balancer6.jpg (136.73 KiB) Viewed 9953 times
The 2 yellow and the 1 white line are you must connect after copy
Set the relationship and the input
Change the limit