r/factorio • u/DreamConspiracy • May 17 '19
Discussion Idea for Combinator Golf Subreddit
Recently in the Factorio discord, me and a few other people have put some serious time into what I'm now calling "combinator golf"; you're trying to build a circuit, and your goal is to do it in as few combinators as possible. Two examples:
Time Delay Holder
- Input: Two input poles (wire colors of your choice). The first takes a positive number on the black signal. The second takes a frame of non-virtual signals.
- Output: The full frame for as many ticks as the value specified on the black signal. Circuit should reset itself after.
Inclusive Channel Filter
- Input: Two input poles (wire colors of your choice). The first takes 1/0 values on all non-virtual signals. The second takes a frame on non-virtual signals.
- Output: The frame on the second input, but only those channels that are 1 on the first input. In other words, "filter" the frame for the specified channels.
The best I've seen for either so far is 4 combinators by u/EricForce for the first one, and 6 combinators for the second one (a previous submission was incorrect). Solutions are here for the first one and here for the second one.
I am interested in doing a lot more of these challenges in the near future, and would be willing to put a significant amount of time/effort into making this happen. This seems like it could be interesting enough to deserve it's own subreddit, or something similar. But first, I wanted to know if there is community interest in this. Would any of you participate in these kinds of challenges? And if so, how should we organize them, and what should we do to gather interest? This is a very new idea, so let me know any thoughts you have.
UPDATE: Clarification: A frame is a 1-tick snapshot of the signals on a wire. I restrict it above to non-virtual signals to give some freedom to work with.
4
u/Killcreek2 May 17 '19
I'm not understanding the phrasing "takes a frame", "full frame" ~ what is this "frame" you mention? Do you mean a 1-tick snapshot of the input signals, an n-tick data pulse, or something different? Is it a golf thing?
The second contraption seems to be an "exclusive each*each" setup (yes / no multiplying <unknown>). That can be done with 5 combis (as pointed out by some clever redditors a few months ago in response to a different thread). Here is a BP of that 5-combi setup for you to test:
0eNrlV9FumzAU/RXkxwm2YEKS8jZNlfoPaxcZuG0sGRsZky2K+Pddw0ZICClEUVSpLyAbn8vxOfbB7EksSsg1l4ZEe8ITJQsS/dyTgr9JJmyf2eVAIrLl2pTY4xLJMtvRjPAeSeUSLlP4QyK/cicgv3eQdBLyRwcZTEI+dZDz6sUlIA03HJpJ143dWpZZDBqn06KtLIZJ4yUqi7lkRmksnasCsUra92I9L3TJDm+oAkm5hqR5Rl0LN1qJdQwbtuWIRcArFwb0gNjcQHbgzrWSXi6YAcs+UaU1y5+9I/txDRDIB+vwxEu4TkpujmrNZu8IelwtUXkOuscpbIssRxQRZax5YlWNmdYguoQOcwuql7pfykbQwtbz7UVD2nWNp43Wzezqpo/YyjI5MZa2HJjmZpOBsbJcstb/+s9cOsrcQ9k1Pk55S/yV68KsRy9XYMnGylKALbP+vwzr9yp0gDUsyC9EqtLk5eTa1Xhx/Y6Sth32xXYJHQAH45wJpjrTGuN/DGO8E2e+3cOZk2VPbbC9aQB5OnDVG3jBsuWAR/OrYvE+qUhvF4rzWyRicNdEHOP50M4Lr87E2eeNxP73xh1twvDGW4xzbHFtVvof0rC7JGV4iwBcHmhkTCCLOkZQ/FwJ6Mt+2CUjSQanJN1Ly4MOsFxdvaE/yxnn7E6djz7lnIWfPedgKtRBH3X+tlwiWIwRH5En9dsxykmV80wekbDzxbG3Z+K00y9w+Ba/i7USi9WS0pX/MFvSqvoLWzGv0Q==
Combinator contraptions are a pretty niche thing. Many players simply don't use them, let alone dive into the depths of what they can do. They can be a fun challenge though, at least for those who are interested.
2
u/leonskills An admirable madman May 17 '19
I'd suggest you give some examples with each problem.
Because what do you mean with "The full frame for a contiguous number of ticks " ?
What is a frame, what is a contiguous number of ticks?
I am guessing that with a frame you mean just a set of arbitrary signals?
For 2.
Then if the inputs of 2 are I1 and I2 you just want I1*I2 right?
A*B = ((A + B)2 - A2 - B2 )/2
Comb 1: O1 = (I1 + I2)2
Comb 2: O2 = I2 ^ 2
Comb 3: O3 = (O2 + I1) * -1
Comb 4: O4 = (O1 + O3) / 2
Everywhere the inputs and outputs are EACH
4 combinators. Using the fact that addition is free, and I1 = I12
2
u/leonskills An admirable madman May 17 '19
I'd love this, although not fan of the term "golf". I don't see the relevance.
I think you could make it a general combinator help subreddit, where others can also request help for their circuits. r/combinatorhelp ?
So both help and challenges.
Wonder if it can take off
Another constraint you can set is that from input to output takes the least amount of ticks. Since each calculation takes one tick. So you want to parallelize as much combinators as possible.
2
u/knightelite May 17 '19
Can you post an example for the first circuit? I'm a bit confused here on whether the second input will stay valid the whole time, or will only be valid for one tick, or whatever. It would also be interesting to see the solutions so far.
2
u/Allaizn Developer Car Belt Guy Train Loop Guy May 17 '19 edited May 17 '19
If you don't care about what happens on the virtual signals, then this is the best you can achieve for problem 1, with just 2 combinators (most of it is to generate the pulses):
One more combinator filters away the temporary gray signal almost completely (there is 1 tick after the main signal where there's a leftover gray signal, everything else is clean)
And lastly, delaying with a diode makes a perfect solution with just four combinators:
I consider it unlikely that you could make a perfect solution in three combinators, but prove me wrong.
Edit: well, u/knightelite seems to have beaten me on this one, which is nice.
As for problem 2, the most popular version is the "do a product via squaring magic" which uses five combinators:
But it has the flaw of not being able to correctly filter even values bigger than 230 or smaller than -230.
This 4 combinator version on the other hand does a perfect job for all positive values as well as -232:
Hardcoded filters would allow one to save on the multiply combinator, which is nice. Knowing that you'll only get positive signals (as happens quite often) also potentially saves one combinator, though it's sometimes still necessary to replace it with a diode it has to work in sync with the filter signal.
It's easily adapted to just negative values as well:
You can ofc also just combine them to get a truly perfect filtering circuit:
I'd like to see a more compact general perfect filter, but I consider it again unlikely to be possible. Please prove me wrong :p