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
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 beingCode: Select all
probability * (0.5 * (amount_max + amount_min) * (1 + extra_count_fraction)
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 place2. 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.

