Ludeon Forums

RimWorld => Bugs => Topic started by: Ospish on November 20, 2017, 01:40:00 PM

Title: Cooks use more ingredients than necessary depending on scan order
Post by: Ospish on November 20, 2017, 01:40:00 PM
Hi to all.
I'm using the last RimWorld build v0.18.1722 and I'm not exactly sure if it's been posted already, but I saw a bug with cooking nutrition mathematics, which consists of pawns making inappropriate decisions while cooking simple meal with items counting 0.25 nutrition, like egg. Specifically, when I sent the pawn to cook, it first tried to cook 1 egg with 9 meat chunks. I saw it, and suspecting that as an inappropriate behaviour due to miscalculation, I gave him a second "Cook" command, executing which the pawn landed the corrrect 1 egg and 5 chunks.
Is that a bug? If so, please take a look.
P.S. I thank the RimWorld creators sincerely for their wonderful work.
Title: Re: Cooking Nutrition Mathematics Bug
Post by: asanbr on November 22, 2017, 05:34:40 PM
I have seen this too. Several times.
Title: Re: Cooking Nutrition Mathematics Bug
Post by: Razuhl on November 23, 2017, 01:41:03 AM
Its not a math problem. The algorithm works like this:
Find ingredients that are applicable to the recipe.
Order them by distance(closest first).
Select from the beginning until you have enough.

So after selecting 9 chunks it was missing 0.05 nutrition. The next best ingredient was an egg. The overflow is lost.

The method WorkGiver_DoBill.TryFindBestBillIngredientsInSet_AllowMix can easily be fixed by doing a pass over the "List<Thing_Amount> chosen" variable if the aggregated ingredient count is too far negative. The list must be ordered by the recipes IngredientValueGetter.ValuePerUnitOf, putting the biggest ingredients first and then dropping ingredients from beginning to end that do not tilt the ingredient count into the positive.
Title: Re: Cooking Nutrition Mathematics Bug
Post by: Ospish on March 04, 2018, 05:52:01 AM
Well explained, thanks! I guess I made a mistake in topic name. Such game behavior doesn't look like logical though...
Title: Re: Cooking Nutrition Mathematics Bug
Post by: Razuhl on March 11, 2018, 11:01:57 AM
It certainly isn't what a player would expect based on what the game teaches. You might wan't to look at: https://ludeon.com/forums/index.php?topic=38051.0 (https://ludeon.com/forums/index.php?topic=38051.0)
Title: Re: Cooking Nutrition Mathematics Bug
Post by: Tynan on September 14, 2018, 04:17:04 AM
It's a tiny issue, but one with a clear solution, I think. As Raz said:

0 Make ingredients list as now
1 Sort ingredients big-to-small by nutrition
2 Drop ingredients from the end of the list as long as doing so doesn't reduce total nutrition under the requirement
Title: Re: Cooks use more ingredients than necessary depending on scan order
Post by: Kenneth on November 06, 2018, 10:36:16 AM
Fixed, thanks for reporting! ;)