Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Displayed Food Preferences  (Read 6103 times)

fortunawhisk

  • Bay Watcher
    • View Profile
Displayed Food Preferences
« on: July 09, 2018, 01:14:07 am »

I was looking at setting food preferences for my citizens and it looks like there is a difference between what the unit "Thoughts and Preferences" screen reports and what the unit actually prefers. So far, it only looks like this applies to preferences for eating butchered creature components(LikeFood/MEAT). For instance, the TaP screen will report something like "prefers to consume kaniwa beer and mandrill". If you look at the unit preferences directly (using gm-editor), it looks like the unit actually prefers something a bit more exotic: mandrill hearts. I always assumed that meant that any meal containing mandrill or any mandrill parts would generate a good thought, but it appears it does not. Only meals containing EXACTLY the preference item generate good thoughts. Has anyone run into this before?

Also, some science (44.10):
Units will get a "decent meal" thought for eating any food they have a preference for, no matter how diluted:
- Raw: 100%, Easy: 50%, Fine: 33%, Lavish: 25%
Units will not get a "decent meal" thought for eating foods they don't have a preference for, no matter how skillfully prepared.
The "decent meal" thought doesn't appear to depend on having tables, chairs, or a dining room available.
Units will seek out preferred (edible) raw ingredients over prepared meals with preferred ingredients.

Replication:
It's possible to check this at scale, using PatrikLundell's script from the post below:
Quote
http://www.bay12forums.com/smf/index.php?topic=164123.msg7670974#msg7670974

I just added a "print(material)" immediately below the "local material =" line. It's (generally) expected to output lines like:
<material 419:172 PLANT:MUSHROOM_HELMET_PLUMP:STRUCTURAL>
<material 29:728 CREATURE:SPIDER_MONKEY:LUNG>

Example Save:
http://dffd.bay12games.com/file.php?id=13876

Reported:
http://www.bay12games.com/dwarves/mantisbt/view.php?id=10828

Edit:
1 - Added Replication steps
2 - Updated subject and summary, Added save file link
3 - Added link to bug
« Last Edit: July 10, 2018, 12:01:37 pm by fortunawhisk »
Logged

clinodev

  • Bay Watcher
  • Embark Profile Enthusiast, Kitfox & reddit mod.
    • View Profile
Re: Food Preferences
« Reply #1 on: July 09, 2018, 03:54:10 am »

sigh

It's a such a frustrating implementation I have to assume it's a bug. It's been repeatedly suggested to me on the /u/dwarffortress subreddit that dwarves couldn't "find" favorite ingredients unless they were at the top of the list of ingredients in a meal, (causing cooking to actually lead to unhappier dwarves.) I have to wonder now if it was really what you're pointing out that was happening, mandrill meat meals being ignored because they're not mandrill hearts meals.

I'm curious why you posted this in the Utilities and 3rd Party Applications board? Not in the "you shouldn't post this here!" sense at all, but because it seems like a topic of widespread interest, more suited to DF Dwarf Mode Discussion.
Logged
Team Bug Fix!

fortunawhisk

  • Bay Watcher
    • View Profile
Re: Displayed Food Preferences
« Reply #2 on: July 09, 2018, 11:31:59 am »

@clinodev:
You're right, it may not be clear what I'm saying. I'm just trying to see if anyone has noticed the mismatch between the displayed 'prefers to consume $creature' and the actual preference for $creature_bodypart.

I've updated the subject and summary to try to make it less confusing. I've also uploaded and linked a save for anybody that wants to examine it directly. I was trying to test a couple of different things when I ran across this issue :
- Can food preferences be directly set
- Do food preferences work with meals to generate good thoughts
- Do units prefer/seek out raw or cooked foods

As to the 'why here', all of this was discovered by gm-editor and lua script. I'm hoping that someone will tell me if I've screwed up the unit preferences (by editing) or I'm misreading them before I go through the effort of replicating in vanilla for a bug report.
Logged

clinodev

  • Bay Watcher
  • Embark Profile Enthusiast, Kitfox & reddit mod.
    • View Profile
Re: Displayed Food Preferences
« Reply #3 on: July 09, 2018, 04:25:19 pm »

Cheers!

May your efforts lead to a glorious "everyonelovesplumphelmets" DFHack function!
Logged
Team Bug Fix!

Clément

  • Bay Watcher
    • View Profile
Re: Displayed Food Preferences
« Reply #4 on: July 09, 2018, 05:23:41 pm »

Already exists: https://dfhack.readthedocs.io/en/stable/docs/_auto/base.html#pref-adjust (I never tested it).

I saw the meat issue when looking at preferences for Dwarf Therapist. I think the shape preference descriptions are wrong too, but I did not do any test with them.
Logged

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: Displayed Food Preferences
« Reply #5 on: July 10, 2018, 12:36:24 am »

In general using gm-editor to adjust preferences does not screw them up.  On a case by case basis it may introduce oddities, for example by giving dwarfs preferences it is impossible to attain in vanilla.

Replicating in vanilla makes any report more effective.

Also suspect that there may be some interest here in your observations with regard to dwarfs seeking out prepared meals containing preferred ingredients, and if being the top/naming ingredient makes any difference.  ;)
Logged

fortunawhisk

  • Bay Watcher
    • View Profile
Re: Displayed Food Preferences
« Reply #6 on: July 15, 2018, 11:17:11 pm »

Some follow-up food/preference findings.

Findings:
Units will get a decent meal thought from meals containing alcohol they prefer, but not a decent drink thought.
Units will seek out available food, no matter where it is on the map (assuming it is pathable).
Units will then seek out preferred food, if it is within a specific range of the first found food item.
 - X is East/West, Y is North/South, Z is Up/Down
 - This appears to be a range of 230 y and 95 z spaces.
 - There doesn't appear to be a max range for x spaces. I had units seeking out preferred food at ~760 tiles.
 - If there is no preferred food within the search range, any available food will be eaten.
 - Path restriction costs don't appear to impact this seek (d-o-r).

If preferred food is found, a second search for 'more preferred' seems to take place.
- This looks ? x, 1 y, and 0 z spaces for 'more preferred' food stacks
- I saw no evidence that the units will extend the search space after the second preferred food is found.
- The 'most preferred' food appears to be raw ingredients.
- Units don't appear to prefer any mealtype or meal quality over another, as long as it has the preferred ingredient.
-- biscuits == stews == roasts and no quality == masterwork
- There doesn't appear to be any involvement from greed, immoderation, or excitement_seeking traits

Known problems:
Some weirdness with the 'more preferred' search
- There might be code that detects 'same old' food/drink choices and prevents the same choice X times in a row.
- Or there might be a minimum search area. I got to where I could 90% predict food choice depending on where the dwarf was standing.
- Either way, if the raw ingredient was found within ?x,1y,0z of a meal, units went for it ~50% of the time.
Food and preferences were created by script, rather than by the game. I didn't see any difference with a test embark specifically created to test this, but...
Mealmaker doesn't guarantee ingredient order, so specifically named meals were only lightly tested.

Testing:
All testing took place in 44.12 with dfhack 44.12 alpha.
I gave all dwarves a preference for plump helmets.
I created a large number of plump helmets with create-items.
I created a large number of meals containing plump helmets with mealmaker.
I locked two dwarves and two cats(vermin control) in two locked rooms with 3 stacks of food each: non-preference, meal with preference ingredient, raw preference ingredient. Rooms were 3X by 5Y and mirrored each other.
I placed a 1 tile meeting zone on end of the chamber and the food stacks on the other (in a vertical line). Like: Zone>NonPreferred>floor>Meal>Raw
I then used the hunger script on repeat every day to force the dwarf to eat.
I ran this for 56 days, then counted the remaining food.
I ran this trial 10 times.

Trial results pretty consistently looked like:
NonPreference Eaten: 0%
Meals Eaten: 50%
PlumpHelmets Eaten: 50%

Scripts used for testing:
Hunger: Makes a unit hungry (39900) and resets thirsty/sleepy/exhaustion to 0.
Spoiler (click to show/hide)

Set Preference: Gives everyone a preference for plump helmets
Spoiler (click to show/hide)

Mealmaker: Makes stacks of meals at the cursor.
Spoiler (click to show/hide)

Lessons?
- Separate prepared meals and raw ingredient piles by at least one Y block.
- Units only get quality modifiers for foods they have a preference for. Meals have a high quality modifier (value), raw ingredients don't. Meals will make your units happier.
- Maybe give your units a preference for a booze type and make your meals from that.
- Maybe give your units a preference for a high value material that isn't edible in the raw form (milk, flour, sugar).

Edits:
- Added max Z testing results
« Last Edit: July 21, 2018, 01:27:44 pm by fortunawhisk »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Displayed Food Preferences
« Reply #7 on: July 16, 2018, 02:52:45 am »

A good examination of the issues!
Logged

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile
Re: Displayed Food Preferences
« Reply #8 on: July 17, 2018, 05:14:45 am »

Thank you for the detailed and helpful post.  Prepare to be immortalized.  :P
Logged