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

This subforum contains all the issues which we already resolved.
PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

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

Post 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.
Last edited by PyroFire on Sat Nov 02, 2019 8:30 am, edited 2 times in total.
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

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

Post 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).
PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

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

Post 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.
Twinsen
Factorio Staff
Factorio Staff
Posts: 1350
Joined: Tue Sep 23, 2014 7:10 am
Contact:

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

Post by Twinsen »

I made it so now all possibilities are shown more clearly in the tooltip.
Capture.JPG
Capture.JPG (26.16 KiB) Viewed 3943 times
Fixed in Version: 0.17.76
User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1262
Joined: Fri Jul 12, 2019 7:43 am
Contact:

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

Post 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:
Last edited by valneq on Wed Nov 06, 2019 6:26 pm, edited 1 time in total.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Resolved Problems and Bugs”