[MOD REQUEST] Use ingredients wisely

Started by Sarge, February 08, 2019, 05:26:48 AM

Previous topic - Next topic

Sarge

It's getting pretty annoying when pawns use ingredients that are fresh instead of ingredients that are about to expire. I just had a cook use mushrooms that were harvested less than 2 game hours before instead of peaches that are 3 hours away from expiration - to cook meals. This kind of thing happens all of the time.

Might someone please consider creating a mod that forces pawns to be 'smart' about this and prioritise ingredients closer to expiration first?

Pelador

I had a quick look in the C# code and specifically WorkGiver_DoBill.

There is a comparison by distance list of valid things for the ingredients in order, sorted in the function "TryFindBestBillIngredients". This currently orders the target ingredients by distance before adding them to a relevant items list that then forms the target queue for the jobs associated with Jobdriver_DoBill.

It may simply be the case that if the thing is of a type degradable or within a certain set like raw food, that this sort order could then be re-sorted (a "further" comparison made) by the health/current level of degradation of the item (lowest being first). And then adding this new further ordered listing into the relevant thing listing prior to making ingredient targets for the job queue.

In other words, the function would take the ordering of items by distance, but in the case of perishable foods would take this ordering and resort it by "most perished" before adding items into the job queue target listing for ingredients TargetIndex.B listing.

Based on how the bill is defined for the recipe, this could however make the job performance much less efficient, as if for example a more perished item is a long distance away in a bill set for infinite distance on a map the pawn would attempt to walk across the map for this item in preference to any nearby. And it may be for an item that has an almost irrelevant stacksize. This since the recipe builds up its ingredients stacks based on this sort order that is added to the list of potentials in the job target queue.

Having said that you could potentially add tolerances to this sort so that if the stacksize is below a certain number or the item is perished to a certain point or even again define what would be an acceptable distance for a degraded item from the billgiver(e.g. stove) to be considered as a priority. But this may effect gaming performance if the sort functions get too complicated/involved, especially when considering that all job/recipes performed using this that are relevant would subsequently be effected by it. It may just help as a process, since in principal this would help to remove degrading items from subsequent jobs as a part of this new process. But it would be interesting to see say how a fire in a food freezer might then change things for example.

These permutations would need testing really to see what might perform the best as more sensible sorting parameters for the ingredient targets so that includes a comparison for degradation values as well as distance.

I don't personally have the time to investigate it further than theory at the moment, but thought I would drop these cursory thoughts into the thread in case any other developer fancied the challenge.