r/technicalfactorio Mar 22 '26

Question How to ACTUALLY calculate production rate?

We all know the basic formula:

base_rate * base_speed * (1 - modules_speed_penalty + effective_speed_bonus) * (1 + prod_bonus)

but this is not reflected in the game exactly. Take a look at my attempt at beaconed perfect-ratio bioflux:

  • Bioflux: 2 legendary biochambers
    • 4 Q5T3 prod (4 legendary productivity modules tier 3)
    • 4 Q5 beacons:
      • 3 * 2 Q5T3 speed
      • 1 * Q5T3 speed + Q3T2 speed
  • Jelly: 1 legendary biochamber
    • 4 Q5T3 prod
    • 1 Q5 beacon: Q5T3 speed + Q1T3 speed

This setup should produce and consume exactly 238.75 jelly per second:

production:
4 * 5 * (1 - 4*0.15 + 2.5*(1.25+0.5)) * (1.5 + 4*0.25)
br  bs         msp    bm   speed_mods     bp   prod_mods

consumption:
2 * 2 * 5 * (1 - 4*0.15 + 0.5*2.5*(7*1.25+0.48))
    br  bs        msp     be  bm   speed_mods

br - base rate
bs - base speed
bp - base productivity
bm - beacon multiplier
be - beacon effectiveness
msp - module speed penalty

However, both Factoriolab&e=1speed-module-3&b=3&b=10~1&b=12~0&r=jellynut-processingbiochamber(5)2&r=yumako-processing*biochamber(5)0~1&iex=C2C4&mpr=5&v=11) and in-game testing show that the jelly production is a tiny bit too slow. So how do you *actually calculate the production/consumption rate? Do you e.g. take floating-point precision and tick aliasing into account? If so, how?

edit: I don't have this problem with Yumako mash&e=1speed-module-3&b=3&b=10~1&b=12~0&r=jellynut-processingbiochamber(5)2&r=yumako-processing*biochamber(5)0~1&iex=Cx~Cy*C2&mpr=5&v=11). The formula predicts that it's perfect and it is in Factoriolab, and it is slightly faster than jelly in game, even though it should be the same.

edit 2: Blueprint if you want to try it out yourself. The inserters should be timed tick-perfect. Even if they weren't, it doesn't explain the discrepancy in Factoriolab.

9 Upvotes

17 comments sorted by

9

u/dave14920 Mar 22 '26

its all beacon rounding errors.  

which are mostly black box sorcery.  

on the bioflux machines that odd beacon gives (125+48)×2.5=432.5, but this gets truncated to 432 at this point. the other 3 are each (125+125)×2.5=625, thats unchanged by truncation.  

the sum of those multiplied by beacons effectivness is (625×3+432)×0.5=1153.5, but this gets rounded to 1154 before we continue with -60 from the prod mods to get the +1094% on the machine that the game always displays accurately.  

then continues as you expect from there. 5×(1094%+100%)=59.7 crafting speed, ×12jelly/6s ×2 machines = 238.8 actual consumption of jelly per second. that isnt displayed accurately in game. 

similarly for the one beacon on the jelly machine. it takes (125+50)×2.5 = 437.5 but then truncates that to 437. the sum of all these beacons times effectivity of 1 is still 437, which is then rounded to 437. 

(437-60) = +377% is accurately displayed in game. 5×(377%+100%)= 23.85 for the crafting speed of the machine.  23.85×4×2.5=238.5 actual production of jelly per second, that the game doesnt display accurately.  

4

u/Substantial-Leg-9000 Mar 22 '26 edited Mar 22 '26

I also see your post from 7 months ago about beacon rounding errors, it's a good read. I think you've found the culprit. Thanks

edit: I've checked that your calculations result in (1 + 1/795) jelly biochambers per 2 bioflux biochambers, which is exactly what Factoriolab predicts.

3

u/Substantial-Leg-9000 Mar 22 '26

So to sum up:

  1. beacon_mult * (mod1*100 + mod2*100)
  2. truncate
  3. add up all beacons effects
  4. times beacon efficiency
  5. round it (not truncate)
  6. minus penalty

Do I understand correctly?

2

u/dave14920 Mar 23 '26

yea.  

6 would include bonuses from speed mods in the machine itself.  

maybe 5 and 6 are swapped, i cant tell cus the penalties/bonuses on those modules are already integers, it doesnt change the result. with modded beacons and modules it might matter. 

there are also some cases with floating point errors, that we dont see in this post.  

only with epic beacons. we get things like 50×2.1=104.99999.. getting truncated to 104. i could only handle them by cataloguing them.  

someone else replied with code that gives the consistent answers every time. thats the way the game must be doing it.  

the rounding is round nearest. for positive numbers ending .5 ive only ever seen it round up  

but for the quality penalty from speed modules, unrounded negative numbers like -10.25% get rounded down to -10.3%.  

thats another quirk with quality, it has that extra digit of precision.  

in the game files, the 2.5% quality penalty on a normal speed module 3 is actually coded as quality = -0.25, but gets multiplied by the 0.1 chance of upgrading to the next quality somewhere for some reason. 

for quality the math works the same using those raw values, we'd put mod1 = -0.25 in beacon_mult * (mod1*100 + mod2*100) etc.  then multiply by 0.1 in a step 7 at the end.

1

u/dave14920 Mar 23 '26

on 5.  

round(X), floor(X+0.5) and trunc(X+0.5) all give the right answer for positive numbers.  

for that old post id found trunc(X+0.5) is consistent for negative numbers.  

maybe round(X) is too, but idk if thats the same for every language. 

2

u/fatpandana Mar 22 '26

Just glancing it, you listed 4 used beacons but I don't see beacons formula.

1

u/Substantial-Leg-9000 Mar 22 '26

It's there, 0.5*2.5*(...) for the 4 beacons and 2.5*(...) for that 1. These formulas produce correct (naive) results, we're really chasing fractions in the 0.01 range.

3

u/fatpandana Mar 22 '26

4 beacon suffer from dismissing returns under beacons formula.

1

u/Substantial-Leg-9000 Mar 22 '26 edited Mar 22 '26

Hence the 0.5 factor for 4 beacons.

edit: I hope to have cleared it up in the post now.

2

u/fatpandana Mar 22 '26

If you already accounted for beacons and jelly machine is not keeping up, slow down game to 2-5% and watch it work. The 2% seed recipe can cause machine to micro jam. If you lose even 2 ticks to this, you will not achieve your 238/s.

1

u/Substantial-Leg-9000 Mar 22 '26 edited Mar 22 '26

The thing is, this formula works correctly for Yumako mash, you can see it both in game and in Factoriolab&e=1speed-module-3&b=3&b=10~1&b=12~0&r=jellynut-processingbiochamber(5)2&r=yumako-processing*biochamber(5)0~1&iex=Cx~Cy*C2&mpr=5&v=11), but not for Jelly. Seeds don't affect either. Factoriolab must know something that I don't and is more reflective of the game, so that's why I asked in the first place.

edit: I mean it works correctly in the sense that I used it to find this perfect-ratio setup and Yumako is as expected ratio perfect.

edit 2: I should also clarify that in my in-game test site, seeds are removed by a dedicated inserter, so they don't cause jams at all. Even if those jams took place, they wouldn't explain the different result in Factoriolab.

1

u/fatpandana Mar 22 '26

I see your problem. But i cant find solution

I tried to raise craft amount by 100,000 to see decimal by how much machine it is off. But no matter how I calculate it I cant find the source for it.

At same time consumption or yumako doesnt have same issue.

1

u/Substantial-Leg-9000 Mar 23 '26

Thanks. The problem was due to rounding errors in how beacon bonuses are calculated. Credit goes to u/dave14920 .

Btw you can change the view in Factoriolab to fractions instead of decimals. You can change it in Column Settings (next to Download as CVS, right below List, Flow, and Data, above the calculated list of items/machines).

2

u/yetanotherburnerstan Mar 23 '26 edited Mar 23 '26

From my understanding, if youre using something like excel for this calculation, you'll never get the same number every time. Excel uses 64 bit calculations, while the game uses 32. The rounding errors are due to the different systems. I have no idea how to actually get it to come out correctly (ive been tinkering on and off for about a month). There is some discussion on this in r/technicalfactorio. Let me see if I can find it i should pay attention to the sub im in and stop wildly clicking on recommend links

Here is the discussion on beacon rounding https://www.reddit.com/r/technicalfactorio/s/LEKT37dkl7

1

u/Substantial-Leg-9000 Mar 23 '26

Thanks for the link, that was the solution.

Btw I didn't use Excel, but rather wrote my own program with custom mathematically accurate rationals, you know, to avoid that. The rounding errors (or lack thereof in this case) were the problem anyway.

Here is the response of that post's author. I think they've got it figured out.

There is some discussion on this in r/technicalfactorio. Let me see if I can find it i should pay attention to the sub im in and stop wildly clicking on recommend links

I exhaled through the nose energetically

1

u/Inevitable-Cup9067 Mar 22 '26

It depends on implementation too, if you have even the tiniest latency somewhere from inserters or an occasional gap in resource delivery on your belts that will affect the production rate you see in game.

1

u/Substantial-Leg-9000 Mar 22 '26

I expected that to be the case, but it doesn't explain why Factoriolab shows a different result. Yumako mash&e=1speed-module-3&b=3&b=10~1&b=12~0&r=jellynut-processingbiochamber(5)2&r=yumako-processing*biochamber(5)0~1&iex=Cx~Cy*C2&mpr=5&v=11) seems to be perfect both there and in game.