Page 1 of 1

[2.0.77] extra_count_fraction is incorrectly applied to product estimation

Posted: Sun May 31, 2026 1:51 am
by PennyJim
I was going to report that util.product_amount does not account for ItemProductPrototype::extra_count_fraction, but then I noticed the description on probability.
This made me go investigate if it really does match the amount on the tooltip and then various other ways it's estimated across the engine.
Testing setup
The recipe I used:

Code: Select all

data:extend{	
	{
		type = "recipe",
		name = "extra-count-testing",
		results = {
			{type = "item", name = "coin", amount = 1, probability = 0.90, extra_count_fraction = 0.3}
		}
	}
}
Hypotheses
I found that the equation described in the description for probability, does in fact produce the result used in the "0.9 x Unknown Key"
But I found that it instead uses this one for the craft-rate on the assembling machine tooltips

Code: Select all

probability * (0.5 * (amount_max + amount_min)) + extra_count_fraction
Which does not line up with both what I expected and what experimentation seems to have produced:

Code: Select all

probability * (0.5 * (amount_max + amount_min) + extra_count_fraction)
Results
I let it run until a machine produced 300,546 products, and found 351,456 coins produced.
This is a result of 1.169391707 per craft.
If the engine's estimation was correct, it should be approaching 1.2
If my proposed one was correct, it should be approaching 1.17. Which seems to be the case.

I do not know if the manual crafting queue logic has implemented this correctly, as that feels more annoying to test and I've already proven a problem.
Disproving an alternative equation
While composing this, someone proposed the idea of the equation being

Code: Select all

probability * (0.5 * (amount_max + amount_min) * (1 + extra_count_fraction)
Which, while feeling wrong to me, produced the same number when the amount was 1.
So I did some quick testing with the amount as 2 to disprove it
I let the machine produce 100,586 products, and got 207,757 coins (2.065466367)
Thus approaching 2.07 instead of the 2.34 that the incorrect alternative equation proposed.
Fix(es)
1. The tooltip estimation needs to account for extra_count_fraction in the first place
2. The product rate estimation needs to apply extra_count_fraction before the probability
3. Investigate the crafting queue product estimation
4. util.product_amounts needs to be updated
5. ItemProductPrototype::probability needs its documentation updated
This to me sounds like it's a good place for a single function to consolidate the multiple implementations, but I don't know your codebase.

Re: [2.0.77] extra_count_fraction is incorrectly applied to product estimation

Posted: Sun May 31, 2026 8:24 am
by boskid
I am not interested in verifying this until 2.1 is out because i was already fixing code around this due to 131864 and i remember the extra count fraction was extra annoying to fix in a way that makes tooltips match simulation. Its likely already fixed for 2.1.