[1.0] Smarter Food Selection, Hydroponics with lamps and more...

Started by Wishmaster, February 20, 2017, 05:34:05 PM

Previous topic - Next topic

Wishmaster

Well that's not the current steam release.
Did you get it from github ? my branches are messed up so master is not stable.

Btw I just updated the direct download link that was not up to date.

Pink Photon

#136
I downloaded it from the link in the "Smarter Food Selection" part of the opening post. https://github.com/Wishmaster01/Smarter.food.selection

Edit: I replaced it with the version from the link in the list at the start of the post (https://www.dropbox.com/s/lps5uj639dk382g/WM-Smarter-food-selection-v2.1.1.zip?dl=0) and that appears to have fixed the problem.

thinkpad



thinkpad

#139
Damn.  Alright thanks.  If you happen to find it let me know please

Canute

Look if you can find a A16 version of Vegetable garden, that got Adv. hydroponics which don't need lamps anymore.

Antaios

Quote from: Wishmaster on June 03, 2017, 09:58:20 AM
Quote from: Antaios on June 02, 2017, 11:02:23 PM
...colonists to always prefer to eat whatever food is in their inventory over any food elsewhere...
I don't know why this is happening. Colonists your ignore their inventory if they have something better to eat.

I did some digging with ILSpy, and I'm new to the Rimworld code, but from what I can see:

It looks like you have SFS giving any inventory food a 500 point buff in FoodScoreUtils.FoodScoreFor().
https://github.com/Wishmaster01/Smarter.food.selection/blob/master/source/FoodScore/FoodScoreUtils.cs#L59
For comparison, as I understand it fine meals have about 80 points over simple meals (+5 mood * 2x (MoodEffectFactor) * 8 (mood curve)) in the standard colonist policy.
That's not counting the negative points given to food based on distance either, where inventory gets a distance malus of 0.

Its further exacerbated by the fact that, as far as I can see, SFS doesn't interact with colonists 'packing' food in their inventory in any way ("JobGiver_PackFood", I think) which just grabs the nearest food that isn't awful or have negative mood buffs.

So pawns grab whatever random food is nearby and put it in their inventory (i.e. a simple meal) because they like having a backup food. Then when its time to eat, the inventory food gets a huge preference over any other food such that they eat it regardless of if it's the 'best' food available according to their policy (to eat a 'better' meal on the floor over a simple one in their inventory, the meal would have to be on the pawn's tile more or less, and give something like a +32 mood buff).

Personally I'd want the inventory to be selected last always, given the food selected to pack into a pawns inventory is based on distance only.

As I understand it though, removing the +500 inventory boost and making it 0 would make pawns eat a fine meal from the floor over a simple meal in their inventory, at up to 80 squares away, then they'd switch to eating from their inventory, They'd still eat a fine meal in their inventory over one on the floor aswell. I think is more the intended effect. Mind you it could lead to some odd situations where a pawn has picked up a simple meal to eat, and there's a lavish meal available back home, so the pawn goes trudging across 160 tiles :/.

Wishmaster

Quote from: Antaios on June 12, 2017, 06:59:31 AM
Quote from: Wishmaster on June 03, 2017, 09:58:20 AM
Quote from: Antaios on June 02, 2017, 11:02:23 PM
...colonists to always prefer to eat whatever food is in their inventory over any food elsewhere...
I don't know why this is happening. Colonists your ignore their inventory if they have something better to eat.

I did some digging with ILSpy, and I'm new to the Rimworld code, but from what I can see:

It looks like you have SFS giving any inventory food a 500 point buff in FoodScoreUtils.FoodScoreFor().
https://github.com/Wishmaster01/Smarter.food.selection/blob/master/source/FoodScore/FoodScoreUtils.cs#L59
For comparison, as I understand it fine meals have about 80 points over simple meals (+5 mood * 2x (MoodEffectFactor) * 8 (mood curve)) in the standard colonist policy.
That's not counting the negative points given to food based on distance either, where inventory gets a distance malus of 0.

Its further exacerbated by the fact that, as far as I can see, SFS doesn't interact with colonists 'packing' food in their inventory in any way ("JobGiver_PackFood", I think) which just grabs the nearest food that isn't awful or have negative mood buffs.

So pawns grab whatever random food is nearby and put it in their inventory (i.e. a simple meal) because they like having a backup food. Then when its time to eat, the inventory food gets a huge preference over any other food such that they eat it regardless of if it's the 'best' food available according to their policy (to eat a 'better' meal on the floor over a simple one in their inventory, the meal would have to be on the pawn's tile more or less, and give something like a +32 mood buff).

Personally I'd want the inventory to be selected last always, given the food selected to pack into a pawns inventory is based on distance only.

As I understand it though, removing the +500 inventory boost and making it 0 would make pawns eat a fine meal from the floor over a simple meal in their inventory, at up to 80 squares away, then they'd switch to eating from their inventory, They'd still eat a fine meal in their inventory over one on the floor aswell. I think is more the intended effect. Mind you it could lead to some odd situations where a pawn has picked up a simple meal to eat, and there's a lavish meal available back home, so the pawn goes trudging across 160 tiles :/.

Good finding.

Now that you mention that part of the code in FoodScoreUtils.FoodScoreFor(), I remember I did that and why: you said it. I really want them to eat what they have in inventory.

Also to be honest, I just missed that JobGiver_PackFood. SFS detours TryFindBestFoodSourceFor() but JobGiver_PackFood uses something different... it will just get a near thing.
Until now I just wondered why ppl complain so much about food picked in inventories. I thought it was affected by TryFindBestFoodSourceFor()...
If I had to rework this, I'm not sure what do to. Maybe pick the best available food if it's not too far ??
Also I maybe I should add the "ate without table" to the mood curve math.

btw I missed up with my Github so "master" is not the stable branch... it's "2.1.1 stable" instead. However the point you mention is exactly the same.


Antaios

Quote from: Wishmaster on June 12, 2017, 08:53:30 AM
Good finding.

Now that you mention that part of the code in FoodScoreUtils.FoodScoreFor(), I remember I did that and why: you said it. I really want them to eat what they have in inventory.

Also to be honest, I just missed that JobGiver_PackFood. SFS detours TryFindBestFoodSourceFor() but JobGiver_PackFood uses something different... it will just get a near thing.
Until now I just wondered why ppl complain so much about food picked in inventories. I thought it was affected by TryFindBestFoodSourceFor()...
If I had to rework this, I'm not sure what do to. Maybe pick the best available food if it's not too far ??
Also I maybe I should add the "ate without table" to the mood curve math.

btw I missed up with my Github so "master" is not the stable branch... it's "2.1.1 stable" instead. However the point you mention is exactly the same.

Yeah I was using ILSpy more than Github, I only remembered the git when I went to post.

Hmm... I think detouring JobGiver_PackFood to use TryFindBestFoodSourceFor() instead of it's logic is probably a good idea.


As for the table stuff,

I looked through, and Rimworld's default distance to search for food before preferring inventory meals is only 32 tiles. Given the search radius for a table is 25 tiles, SFS forcing pawns to eat from their inventory isn't as big an impact as I first thought it was. It still boils back to rimworld's lousy table radius.

Given 1 point at the moment represents 1 tile, and +1 mood represents 16ish points, the +3 from eating at a table represents 48 tiles. If the food selection accounted for the mood boost, and didn't apply a huge bonus to inventory, the net effect as I see it would just be more or less the same as doubling the table radius, which isn't SFS's scope. The work probably isn't worth it to account for the mood effect, given the added code to search for chairs/tables nearby the pawn and possibly near food sources.

Putting that aside, if the JobGiver_PackFood is detoured, the only difference between the +500 for inventory food or not is an edge case. Under normal circumstances, they'd prefer inventory food regardless, less travel :), But
if a pawn decides to refill their inventory while the best option happens to be a simple meal, and then a bunch of fine meals get made, with the +500 the pawn would still eat the simple meal. On the flip side, without the bonus the simple meal would rot in the pawn's inventory while they eat fine meals from the freezer. I don't think either of those matter too much, personally. Alternatively, it might not be a bad idea to put that inventory offset as a variable in the policies, which would allow for varying degrees of inventory-prefferedness, if someone wants that.

Wishmaster

So I don't know what do to exactly to fix this. Technically it would be very quick to fix however. But still I don't know if I will make a hotfix or wait for the next major version.

I think colonists will simply pack food within a limited radius, only if its rating is the best accross all map/ allowed area.

Antaios

Quote from: Wishmaster on June 12, 2017, 12:58:28 PM
So I don't know what do to exactly to fix this. Technically it would be very quick to fix however. But still I don't know if I will make a hotfix or wait for the next major version.

I think colonists will simply pack food within a limited radius, only if its rating is the best accross all map/ allowed area.
Well, I did up a fix for myself, if you want it, I added it to Github and made a pull request.

The way it works is if a colonist's inventory is empty and there's a meal within 20 tiles, it triggers SFS checks to find the best meal (which could be more than 20 tiles away)

Wishmaster

Well that looks good. (beside what I commented for the namespace).
I would totally make a quick test and publish a hotfix right now... but for some reasons, Xamarin won't let me switch to another branch than "master" ^^' (which is not stable).

flechoide

Hi, Im having issues with smarter food selection (im at A17 latest), I downloaded it form steam workshop (version 2.1.1) Im getting errors at the beginning of game start :
ReflectionTypeLoadException getting types in assembly WM Smarter Food Selection: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <filename unknown>:0




And later a lot of errors of empty xml  :
Found no usable data when trying to get defs from file colonists.xml
Verse.Log:Error(String)
Verse.<AllDefsFromAsset>c__Iterator226:MoveNext()
Verse.ModContentPack:LoadDefs(IEnumerable`1)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)

Im the on with that issues ?

Wishmaster

Quote from: flechoide on June 17, 2017, 05:26:44 AM
Hi, Im having issues with smarter food selection (im at A17 latest), I downloaded it form steam workshop (version 2.1.1) Im getting errors at the beginning of game start :
ReflectionTypeLoadException getting types in assembly WM Smarter Food Selection: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <filename unknown>:0




And later a lot of errors of empty xml  :
Found no usable data when trying to get defs from file colonists.xml
Verse.Log:Error(String)
Verse.<AllDefsFromAsset>c__Iterator226:MoveNext()
Verse.ModContentPack:LoadDefs(IEnumerable`1)
Verse.LoadedModManager:LoadAllActiveMods()
Verse.PlayDataLoader:DoPlayLoad()
Verse.PlayDataLoader:LoadAllPlayData(Boolean)

Im the on with that issues ?

Your installation must be wrong. You must be missing the .dll and you probably got it from github which you should not. Where did you pick the link ?

Just download from the link in the topic or use steam.