FEP calculation algorithm

Ask, answer and discuss any and all topics about the hows, whys, wheres and whens of playing Haven & Hearth.

FEP calculation algorithm

Postby digzol » Fri Mar 15, 2019 9:55 pm

This thread is to gather data on cooking recipes ingame and eventually figure out the algorithm behind FEP calculation for ingredients.
The end goal is being able to dynamically calculate recipe results based on ingredients to use in cookbook tools without having to hardcode massive lists (i.e. 20,000 autumn steak variations) like on Not a Cat's cookbook.

I will update this post with latest findings. So far here are some of what I know from experiments & small talk with jorb in pm's:
- FEPs are indeed calculated via an algorithm based on ingredients and not simply hardcooked.
- Ingredients are "combobulated" onto the base values of the recipe one by one to determine an end result.
- There are both additive and multiplicative modifiers which makes me believe the algorithm multiplies matrices.
- The idea of matrices is also based on how salem's algorithm seem to work (see here).
- +1 and +2 values seem to have separate modifiers.

For now, I believe we should focus on finding out the value modifiers of meat and then go onto more complex recipes from there.
I'll start with this sample size. Please add any recipes you think might be helpful.

Kebab
Code: Select all
Base:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00
Bat:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.40    0.70    0.00    0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00
Bear:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    1.50    0.00    0.00    0.25    0.00    0.00    0.00    0.00    0.00
Boar:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.8    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00    0.66    0.00    0.00    0.00    0.00    0.00
Fox:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.60    0.70    0.00    0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00
Lynx:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    1.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00    0.00    0.50    0.00    0.00    0.00    0.00    0.00
Venison:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.80    1.00    0.00    0.00    0.00    0.00    0.00    0.00    0.70    0.00    0.00    0.00    0.00    0.00
Swan:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    0.00    0.50    0.60    0.00    0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00
Wolverine:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.80    0.00    0.00    0.00    0.60    0.00    0.00    0.00    0.00    0.00    0.00    1.00    0.00    0.00    0.00    0.00    0.00

Marrow Roast
Code: Select all
Base:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    3.00    0.00    0.00    0.00    2.00    0.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    0.00    0.00
Bat:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.80    3.00    0.00    0.00    0.00    1.40    0.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    0.00    0.00
Bear:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    9.00    0.00    0.00    0.00    2.00    0.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    0.00    0.00
Boar:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    6.20    0.00    0.00    0.00    2.00    0.00    0.00    0.00    0.00    0.00    0.00    2.60    0.00    0.00    0.00
Fox:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    1.20    3.00    0.00    0.00    0.00    1.40    0.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    0.00    0.00
Lynx:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    4.00    0.00    3.00    0.00    0.00    0.00    2.00    0.00    0.00    0.00    0.00    0.00    0.00    2.00    0.00    0.00    0.00
Venison:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    3.00    2.40    0.00    0.00    2.00    0.00    0.00    0.00    0.00    0.00    0.00    2.80    0.00    0.00    0.00
Swan:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    1.00    3.00    0.00    0.00    0.00    1.20    0.00    0.00    0.00    0.00    0.00    0.00    4.00    0.00    0.00    0.00
Wolverine:
STR+1   AGI+1   INT+1   CON+1   PER+1   CHA+1   DEX+1   WIL+1   PSY+1   STR+2   AGI+2   INT+2   CON+2   PER+2   CHA+2   DEX+2   WIL+2   PSY+2
 0.00    0.00    0.00    3.00    0.00    0.00    0.00    1.20    0.00    0.00    0.00    0.00    0.00    0.00    4.00    1.60    0.00    0.00
digzol
 
Posts: 35
Joined: Sat Jan 25, 2014 7:08 am

Re: FEP calculation algorithm

Postby digzol » Sun Mar 17, 2019 8:21 pm

Using matrix multiplication seems to be how ingredients affect the base FEPs, but I can't figure out how to insert that "extra stat" each ingredient adds.
Each ingredient seems to be limited to a single added stat, so there must be an addition parameter or operation that limits it somehow.
Problem is this added stat can change (only between 2 stats? needs more testing...) between recipes. This stat switching doesn't always happen for the same recipes (i.e. one ingredient might change to it's "secondary" stat for a recipe while another ingredient doesn't).
However, I noticed that from kebab to marrow roast, the extra stat is always 2x, 3x or 4x greater, without exception. This is promising, it means each ingredient has an "extra stat" modifier.

I barely know anything about matrix operations, so please post anything you know that might help.
Any ideas how this algorithm could work would be greatly appreciated.
digzol
 
Posts: 35
Joined: Sat Jan 25, 2014 7:08 am

Re: FEP calculation algorithm

Postby MagicManICT » Sun Mar 31, 2019 7:30 am

So I had a little time today to do a bit of "refresher" on linear algebra and matrix multiplication. I dug up this on finding B if A x B = C: http://mathworld.wolfram.com/MatrixInverse.html

Since we're looking at a 18x18 matrix, I think it's going to need a math program to run numbers to get B^-1, otherwise it will be hell doing it via pen and paper. I think if one or two ingredients can be unlocked, others can start being pulled apart. (My brother was a math major in college... no idea if he took any linear algebra classes... was before quaternions were this huge means of computation that they've become the last couple decades with high performance GPUs.)

edit: maybe i'm barking up the wrong tree... /scratch head.
Opinions expressed in this statement are the authors alone and in no way reflect on the game development values of the actual developers.
User avatar
MagicManICT
 
Posts: 18437
Joined: Tue Aug 17, 2010 1:47 am

Re: FEP calculation algorithm

Postby digzol » Tue Apr 02, 2019 3:52 am

I've looked into this a lot more since I posted my last reply and came up with a new idea to replace 18x18 matrices. Looking at the page you linked, I see matrices within matrices, which fits with this new idea's logic.
I sent a message to loftar in hopes of seeing if I was right or wrong, but no reply yet. The idea goes like this:

- The modifier for each ingredient (and recipe) consists of an array of size 18 along with a matrix of size 18 by 1 which I'll mention again later.
- Each entry of the array represent a potential attribute bonus. These entries contain matrices with a width of 1 and an unknown depth (at least 2)
- Then to calculate the final bonus, it first loops through the matrix, multiplying each matrix together and flipping them accordingly. This results in a new array of integers (or a matrix) representing the recipes modifiers.
- The base recipe attributes are then multiplied with its respective modifier.

This part alone is enough to explain how certain combo of foods seem to increase or decrease the modifiers. It would be because there are "secondary" (or more) modifiers that usually multiply with 0 and cancel out. More on this below.

Now, the other part (which I assume is different block altogether) is where each ingredient seemingly only adds 1 attribute each.
This part is a lot trickier and I probably have it wrong, but the idea I have is that each ingredient has another 1 by 18 array of attributes it can supply, this array is also multiplied by the modifier matrix and only the highest value is kept (if any). It would also be multiplying a hidden attribute modifier on the recipe itself? I.e. kebab vs marrow roast are always increased by 2x 3x or 4x.

The idea behind an array of arrays came from looking at steak and tubers (https://i.imgur.com/N9LQp7j.png). As you can see on the first attribute, Red onion + Beets and Yellow onion + Turnips are strangely out of place which suggests a sort of "combo" matching. I tried solving this using regular algebra and my very limited knowledge in linear algebra, but couldn't find a solution. Instead I opted with an inner array that would "unlock" modifiers only if both ingredients have it.

I don't however know how true this theory is. I was hoping to first get an answer from loftar before testing with actual values.
digzol
 
Posts: 35
Joined: Sat Jan 25, 2014 7:08 am

Re: FEP calculation algorithm

Postby Sevenless » Tue Apr 02, 2019 12:00 pm

Without the math behind it, I can verify that general statement.

Ingredients have (obviously) hidden boosting attributes. Often they line up with the base food item, but not always. Deer is a notable case in that it doesn't tend to be perception heavy.

When matching multiple food items together that have shown to give certain FEP types in other food combos you'll usually get an expected result. For example, moose and turnips both often give INT to a food, and when used in steak and tubers you find a nice int bonus. However some food items get odd. Flour types for example always give exactly 1 attribute bonus but it's not always the same. Simplest example being dream cookies, wheat gives will. I've never seen it give will anywhere else, and I can't say I've ever seen it reinforce an existing recipe FEP before. Cave lanterns often give int, but in pirogies they randomly flip to agility.

After enough cooking with useful meats/mushrooms (ones you can get in notable volume) I've been getting the hang of intentionally crafting recipes. However, how these ingredients interact with each recipe isn't always the same, which I agree hints at some unique modifier in the food itself. But considering the list of realistically useful ingredients is cut down to something sane (25 potential recipes per food worst case scenario) I don't have much trouble testing a food thoroughly anymore. Wait till you play with spices. Those are a wild ride.

The unfortunate conclusion I come to is that due to each food having unique modifiers, I don't think we'll ever be able to get 100% predictive on every food. The ones with crazy combos should be doable though.
Lucky: haven is so quirky
Lucky: can be so ugly, can be so heartwarming
Sevenless: it is life

The Art of Herding
W15 Casting Rod Cheatsheet
Explanation of the logic behind the cooking system
User avatar
Sevenless
 
Posts: 7292
Joined: Fri Mar 04, 2011 3:55 am
Location: Canada

Re: FEP calculation algorithm

Postby digzol » Sun Apr 07, 2019 5:49 am

My theory (or atleast part of) gets disproved when mixing variation foods.

For example, if you mix Venison meat and Reindeer Venison meat in a Roast Marrow, there is a modifier on CON+1 which normally isn't there for individual recipes.

Image
digzol
 
Posts: 35
Joined: Sat Jan 25, 2014 7:08 am

Re: FEP calculation algorithm

Postby Leksar » Mon Apr 08, 2019 11:21 am

not sure if it could help, but yesterday, when i was cooking, i remembered this post and decided to make some experiment with onion salad (9 recipes) and concluded, that ingredients are more likely to create a some kind of desirable results, rather then add some stats.

Thus, leek, in my case, can add or, conversely, subtract the "int" value depending on the ingredients. And yellow onion tries to remove "int" completely,
So the leek and yellow onion mix divides the "int" value in half.
And using leek with turnip(IIRC), which, i believe, has "int" desirable value more than leek's, causes "int" to underestimate to a leek's desirable value.

Sorry for the crumpled explanations, but you will see it youself if you make these 9 recipes (+ some mixed maybe), i will try to brind some numbers after work, hope my experimental exhibits have not yet been eaten :lol:
User avatar
Leksar
 
Posts: 191
Joined: Thu Apr 08, 2010 6:43 pm

Re: FEP calculation algorithm

Postby Leksar » Tue Apr 09, 2019 6:42 pm

Nah.. i think i was too tired. Made some calculations today and and it seems that adding and subtracting values somehow works, but not in all cases. For example:

Image

turnip and red onion mix gave me a str+1 bonus, which i never seen in previous results... i guess i will just share my numbers and try my luck another day

https://docs.google.com/spreadsheets/d/ ... sp=sharing
User avatar
Leksar
 
Posts: 191
Joined: Thu Apr 08, 2010 6:43 pm


Return to How do I?

Who is online

Users browsing this forum: No registered users and 4 guests