Page 1 of 1

probability in recipe output causing bloated numbers in production screen

Posted: Sat Apr 18, 2020 7:06 am
by kingarthur
i have a recipe that has 4 outputs and the second one has a probability of 10% and anytime that part of the results triggers it causes the production screen to show the recipe as having produced several million items per minute. the second result with probability doesnt do that at all and seems to report much more expected numbers.

Code: Select all

data:extend(
{
	{
    type = "recipe",
    name = "moondrop-seeds",
    category = "crafting",
    enabled = true,
    energy_required = 5,
    ingredients = {
        {type = "item", name = "iron-plate", amount = 5},
    },
    results = {
        {type = "item", name = "iron-plate", amount = 2, catalyst_amount = 2},
        {type = "item", name = "iron-plate", amount_min = 1, amount_max = 3, probability = 0.10, catalyst_amount = 3},
        {type = "item", name = "copper-plate", amount= 7},
        {type = "item", name = "copper-plate", amount_min = 1, amount_max = 3, probability = 0.25}
    },
    main_product = 'copper-plate',
	}
}
)
this one breaks

Code: Select all

 {type = "item", name = "iron-plate", amount_min = 1, amount_max = 3, probability = 0.10, catalyst_amount = 3}
this one is fine.

Code: Select all

 {type = "item", name = "copper-plate", amount_min = 1, amount_max = 3, probability = 0.25}
ive made a little example mod that recreates the problem using just base game items in an assembly machine

Re: probability in recipe output causing bloated numbers in production screen

Posted: Sat Apr 18, 2020 11:51 am
by boskid
Hm.. uint32 underflow on substraction because there was 1 item produced while catalyst is set to 3. Not sure if this should be handled as "1 item produced, 3 lost" or as "2 items lost". Having less amount on output than catalyst amount feels quite troublesome.

Re: probability in recipe output causing bloated numbers in production screen

Posted: Tue Apr 28, 2020 5:36 am
by boskid
Thanks for the report. Test case is added and issue is now fixed for 0.18.22