Page 1 of 1

[Twinsen] 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Sat Nov 02, 2019 8:00 am
by PyroFire
Hi, i've noticed that setting an ingredient probability doesn't appear to function consistently.

e.g.

Code: Select all

results={ {type="item",name="iron-ore",amount=1,probability=0.1} }
This will give the recipe a 10% chance to produce one iron-ore.

But if i do

Code: Select all

results={ {type="item",name="iron-ore",amount=2,probability=0.1} }
This will give the recipe a 20% chance to produce two iron-ore.

And you can immediately see the problem.

I'm guessing factorio is trying to auto balance the probability recipes, such that a recipe with amount of 2 and probability of 0.1 should actually be 5% chance to produce two, which maintains the "true" probability factor.
If that was the intention, then this doesn't appear to be working correctly.

After 10 crafts, scenario 1 will produce 1 iron ore.
After 10 crafts, scenario 2 will produce 4 iron ore, even though the amount is only x2.

By applying the probability to each individual "amount" as factorio currently is, you are introducing a random/stray exponent into the equation.
... Why?


Continuing the chain it looks like this:
amount:3, probability: 0.1 = 30% chance to produce 3. After 10 crafts this will produce 9 items.
amount:4, probability: 0.1 = 40% chance to produce 4. After 10 crafts this will produce 16 items.
amount:5, probability: 0.1 = 50% chance to produce 5. After 10 crafts this will produce 25 items.
amount:6, probability: 0.1 = 60% chance to produce 6. After 10 crafts this will produce 36 items.
amount:7, probability: 0.1 = 70% chance to produce 7. After 10 crafts this will produce 49 items.
...
amount:10, probability:0.1 = A standard recipe that produces 10 items?

So amount_factor_after_10_crafts_with_0.1_probability=amount^2.

This gets a lot worse with higher probability factors.


* After further looking into this, this may just be a visual "bug" only because the overlay can't show the actual amounts relative to its probability.
Here's a screenshot of amount:10, probability: 0.1
Image

With the right math, i could make it say you'll get 1000 of an item... but you'll never actually get it because the probability would be set to something like 0.1e-10000
But if it succeeded, you would not get the displayed 1000, you'd actually get something to the order of 1e100000000


No matter how you look at it, the behavior here seems very inconsistent.

Re: 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Sat Nov 02, 2019 8:23 am
by Arch666Angel
This is a display bug, what your second example will result in is that it produces 2 ores at 10%, or 90% nothing. Displayed would be a production of 0.2 (2 x 0.1).

Re: 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Sat Nov 02, 2019 8:25 am
by PyroFire
Arch666Angel wrote:
Sat Nov 02, 2019 8:23 am
This is a display bug, what your second example will result in is that it produces 2 ores at 10%, or 90% nothing. Displayed would be a production of 0.2 (2 x 0.1).
Yeah that's what i was expecting to happen.
Not really easy to measure the actual probability while it's telling you it's a 100% chance lol.

Thanks for confirmation, glad i don't need to sweat about this being an actual mechanical bug.

Re: [Twinsen] 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Wed Nov 06, 2019 2:47 pm
by Twinsen
I made it so now all possibilities are shown more clearly in the tooltip.
Capture.JPG
Capture.JPG (26.16 KiB) Viewed 3546 times
Fixed in Version: 0.17.76

Re: [Twinsen] 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Wed Nov 06, 2019 3:45 pm
by valneq
Twinsen wrote:
Wed Nov 06, 2019 2:47 pm
I made it so now all possibilities are shown more clearly in the tooltip.
Capture.JPG

Fixed in Version: 0.17.76
I want this recipe! produce 60 to 65 uranium-235 from just 10 uranium ore in 12 seconds. Want!! :lol:

Re: [Twinsen] 0.17.74 LuaRecipe.results[x].probability is inconsistent

Posted: Wed Nov 06, 2019 6:05 pm
by eradicator
Twinsen wrote:
Wed Nov 06, 2019 2:47 pm
I made it so now all possibilities are shown more clearly in the tooltip.
Capture.JPG

Fixed in Version: 0.17.76
Oh noez, since when are the ingredients at the top. It messes with my brain logic "machine + ingredients = product".
Also how bad does it look if "1 x" is also shown (on the U238).