Page 1 of 1

Beacon calculations

Posted: Tue May 13, 2025 4:28 pm
by ilbJanissary
As the author of FactorioLab, I've recently seen a few issues opened noting edge cases where FactorioLab calculates beacon bonuses off by 1-2% from the tooltips in-game. I have been trying to determine how the game engine calculates beacon bonuses, and have been having some difficulty.

As an example, I have been looking at 2 rare beacons, each with 2 rare efficiency module 3. The basic math for this looks like:

80 (80% bonus from module) * 2 (# modules) * 2 (# of beacons) * 1.9 (rare beacon distribution efficiency) * 0.7071 (diminishing beacon effect)
80 * 2 * 2 * 1.9 * 0.7071 = 429.9168

In game, the resulting bonus is 430%. This makes some sense assuming the engine rounds after multiplying by the diminishing beacon effect.

However, there are many edge cases that a simple round-at-the-end does not cover. I've tried many variations, including attempting to account for the fact that effects are integers under the hood (which means some of the calculations result in truncation). I have been unable to find an order of operations that accounts for, for example, various quality effects (including 1 or 2 negative quality effects per 1-4 beacons).

The closest I think I have gotten is:
80 (80% bonus from module) * 2 (# of modules) * 1.9 (efficiency) = 304%
Truncate this result to the precision of the effect: 304% (no change)
304 * 2 (# of beacons) * 0.7071 (diminishing effect) = 429.9168%
Round this result: 430%

This _seems_ to be accurate for 1-2 negative quality effects per 1-4 rare beacons, even! However, it breaks down with 2 negative quality effects in one epic beacon and three empty beacons.
-2.5% * 2 * 2.1 = -10.5%
Truncate this result: -10.5% (extra digit of precision in quality)
10.5 * 1 * 0.5 = -5.25%
Round this result: -5.3%

In game, however, this results in -5.2%.

Another unexpected result is 2 negative quality effects in one epic beacon by itself.
-2.5% * 2 * 2.1 = -10.5%
Truncate this result: -10.5% (extra digit of precision in quality)
10.5 * 1 * 1 = -10.5%
Round this result: -10.5%

However, in game, this results in -10.4%.

If I change the order of operations in the first step, this accounts for this discrepancy with epic beacons, but breaks the calculations for rare beacons.
-2.5% * 2.1 = -5.25%, truncate to -5.2%; this accounts for -5.2% / -10.4%
-2.5% * 1.9 = -4.75%, truncate to -4.7%; this predicts a -9.4% bonus with two modules in a rare beacon, when the game says -9.5%.

Clearly I am missing something. Can anyone help me understand the math here?

Re: Beacon calculations

Posted: Tue May 13, 2025 6:39 pm
by ilbJanissary
Fiddling with this more, it seems like the formula I developed is _essentially_ right, with one exception: epic beacons. Epic appear to show a lower effect than expected. This is true for speed module 3 speed bonus (50%), but the calculations are correct for speed module 1 bonus (20%), so it appears there may be a rounding error that even-by-tens numbers (20%, 40%, 60%, 80%) counteract, _on epic beacons_.