Auto-Calculate Productivity for Selected Recipes

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
2833680766
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Jan 02, 2026 9:00 am
Contact:

Auto-Calculate Productivity for Selected Recipes

Post by 2833680766 »

For auto change recipe, we are always looking at avoid loosing productivity.
Now I create a machine to auto calculate productivity. Automatically calculates productivity for specific recipes by monitoring item quantity changes inside the machine.

When the recipe completion signal F is output:

If the item count decreases, it indicates normal operation. This quantity is recorded as A.

If the item count increases (all items increase), it indicates a productivity bonus. This quantity is recorded as B.

By reading the item changes on the inserter, I eliminated the impact of the inserter's picking action on the contents.
But I can't remove the effect of fluid input/output on the contents, since I can't read the pump's contents or flow rate. Specifically, even when I disable the pump, the fluid already inside it keeps flowing out, which is really frustrating.

Obviously, it can not use for Metallic asteroid crushing.

I start recording from the frame where A = 1, and continue until the frame just before A = 101. In this way, the machine runs exactly 100 cycles, and the value of B is the productivity. After that, we apply the Euclidean algorithm to A and B to obtain the minimum guaranteed productivity number.

To be honest, I’m not a fan of “guaranteed productivity,” because I feel that no matter what the productivity is, can’t I just request 100 times the raw materials at once?
2833680766
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Jan 02, 2026 9:00 am
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by 2833680766 »

The language I use is zh-CN. When I have free time, I will upload an English version.

The core implementation of the Euclidean algorithm is two arithmetic combinators: one does A % B and outputs A, the other does B % A and outputs B.
Attachments
Euclidean.png
Euclidean.png (158.09 KiB) Viewed 696 times
mmmPI
Smart Inserter
Smart Inserter
Posts: 5049
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by mmmPI »

2833680766 wrote: Wed Mar 25, 2026 5:42 am When I have free time, I will upload an English version.

The core implementation of the Euclidean algorithm is two arithmetic combinators: one does A % B and outputs A, the other does B % A and outputs B.
I am curious because it look smaller (better) than my version : viewtopic.php?t=113159, but on the blueprint, i can not see the same as in the picture.

Also the blueprint look like it could be made even smaller if you used pulse mode for the inserters :
pulse.jpg
pulse.jpg (93.21 KiB) Viewed 534 times
Maybe there are some reason i don't understand why you use "Hold" and not "Pulse" ? it look like the purpose of some combinators is to create a 1 tick signal,but if you change the mode of the inserter, it can create 1 tick signal too, without extra combinators with *-1 but i can not read zh-CN, so it is a bit like magic, maybe it is already explained :(

Maybe you can use trains for fluid ? or a tank ? you cannot read pump flow easily, but you can read content of tanks or fluid wagon, if you read the quantity at when the receipe is finished.
Check out my latest mod ! It's noisy !
2833680766
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Jan 02, 2026 9:00 am
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by 2833680766 »

mmmPI wrote: Mon Mar 30, 2026 3:39 pm
2833680766 wrote: Wed Mar 25, 2026 5:42 am When I have free time, I will upload an English version.

The core implementation of the Euclidean algorithm is two arithmetic combinators: one does A % B and outputs A, the other does B % A and outputs B.
Maybe there are some reason i don't understand why you use "Hold" and not "Pulse" ? it look like the purpose of some combinators is to create a 1 tick signal,but if you change the mode of the inserter, it can create 1 tick signal too, without extra combinators with *-1 but i can not read zh-CN, so it is a bit like magic, maybe it is already explained :(

Thank you for your question.

Why I use "Hold" instead of "Pulse": because "Pulse" only outputs for a single frame at the exact moment the inserter picks up the item. However, different inserters have different rotation speeds, which makes it impossible for me to accurately determine when the item on the picking inserter will actually enter the assembling machine.

Naturally, for the inserter that takes items out, we could use "Pulse". But I prefer symmetry, or perhaps beauty. I want the picking and the placing to use the same structure.

Sorry, I missed uploading some blueprints. The one below includes all of them.
2833680766
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Jan 02, 2026 9:00 am
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by 2833680766 »


Sorry, I missed uploading some blueprints. The one below includes all of them.
I've replied in the thread link you gave me. Don't forget to check it out.
User avatar
MBas
Fast Inserter
Fast Inserter
Posts: 117
Joined: Fri Jan 06, 2017 12:57 pm
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by MBas »

2833680766 wrote: Wed Mar 25, 2026 5:27 am Obviously, it can not use for Metallic asteroid crushing.
Is this obvious? I actually use this trick for asteroid crushing only because there is a very good reason to do such method specifically on crushers in space ships. And it may switch between all crushing options. Basic or advanced. See my post

viewtopic.php?p=666158&hilit=Mbas#p666158

The post is about additional optimizations on the ship. Please ignore other parts. It is an old post anyway, and I have already improved many other things since then. I only want to cherrypick the recipe switching mechanism as it is.
2833680766
Burner Inserter
Burner Inserter
Posts: 14
Joined: Fri Jan 02, 2026 9:00 am
Contact:

Re: Auto-Calculate Productivity for Selected Recipes

Post by 2833680766 »

MBas wrote: Tue May 19, 2026 2:36 pm
2833680766 wrote: Wed Mar 25, 2026 5:27 am Obviously, it can not use for Metallic asteroid crushing.
Is this obvious?
I wasn't clear enough. Under the following conditions, it won't work.

My main approach is to read the signal F (finish) generated when a recipe completes, and at that moment read the item changes inside the assembling machine. Unfortunately, both normal production and the productivity bonus output the signal F once each. So we need to determine whether this particular F is from normal production or from the productivity bonus.

My idea is to read the changes in item counts inside the assembling machine. If any item count decreases, it must be normal production. If all item counts increase, it's a productivity bonus. However, the asteroid processing recipe duplicates itself, so sometimes during normal production, no item count decreases either.

I've looked at your blueprint. It's what I would call "Artisanal Intelligence" — manually entering the productivity value is also a pretty good approach.

Maybe I could read the working signal and the output signal to determine exactly how many. This would at least require assuming that the time interval between each normal completion is the same — but I'm not sure.
Post Reply

Return to “Combinator Creations”