Calculating the flavour of a dish in a cooking game

I'm currently working on a game that sees players cook dishes and are scored on their performance. To determine whether a dish is good or not, I will be looking to see if these elements are balanced:

• Salt
• Fat
• Acid

A dish is made up of multiple ingredients and each ingredient will have its own salt, fat and acid levels. Adding too much or too little of an element (e.g. over-salting) results in a weaker score for the player.

There are also a few other factors that affect the salt, fat and acid balance:

• The number of ingredients (adding more ingredients should reduce saltiness, fattiness and acidity)
• Acid can reduce the saltiness and fattiness of a dish.
• Salt can reduce the acidity of a dish.

This idea comes from Samin Nosrat's book Salt, Fat, Acid Heat. Below is an image from her book where she breaks down 4 popular salads and shows how each of the ingredients affects each element. If the player was to recreate "The Caesar" salad, they should get a perfect score for balancing all those ingredients but if they created a salad with just bacon and anchovies it should be considered too salty.

Texture is another element that the player needs to balance but this won't need to be calculated in the same way as the other elements. My plan here is to check if the player is making a salad it should have some crunch to it, whereas if they are making a roast the meat should be tender.

Given a set of ingredients, I would like to calculate whether the dish is balanced or not. The game will probably have 100s of ingredients and I would like some advice on how to best calculate these elements, score the player and balance the many ingredient combinations a player can come up with.

• It sounds like you could base your grading on a Ternary Plot, with regions of the triangle corresponding to different ratings. – DMGregory Aug 1 '20 at 12:40
• @DMGregory I'm unfamiliar with Ternary Plots but after looking into it, I don't think it will work for me. If I have an ingredient such as lettuce which is rather bland and has 0 salt, acid and fat then it would be plotted in the centre of the triangle and considered a perfect meal. Unless I've misunderstood Ternary Plots, I don't think I can go this route. Thank you though. – Ajay Aug 2 '20 at 6:44
• Lettuce is perfectly balanced then... you could use a Ternary Plot to determine how "balanced" it is, but then also multiply by the total amount of salt, fat, and acid in the meal, so Lettuce would have a value of 1 for balance but 0 for having flavor and 1 times 0 is 0. – Foxwarrior Aug 7 '20 at 17:31

I would first model this by creating a table which includes the taste components (and perhaps far more data) of each ingredient per unit. This table could look something like this:

Ingredient | Salt   | Fat   | Acid   | Crunch | Umami  |
--------------------------------------------------------
Bacon      |    5   |     6 |      3 |      7 |      8 |
Lettuce    |    0   |     0 |      1 |      3 |      1 |
Vinegar    |    0   |     0 |      9 |      0 |      2 |
Cheese     |    3   |     7 |      1 |      1 |      6 |


(this is just an example, please don't nail me down on those numbers)

When the player creates their dish from multiple ingredients, just add them up. So when the player creates a bacon salad from 2 units of bacon, 3 units of lettuce and one unit of cheese, then the final sum for "umami" would be:

2 * 8 = 16
3 * 1 =  3
1 * 6 =  6
----------
25


When the player just adds twice as many ingredients, then they of course don't get a dish which tastes twice as intense, they get twice as much food of the same taste. So to calculate the final taste, you should divide the sum by the total units of ingredients in the dish to get the average umami value of the dish, which would in this case be 25 / 6 =  4.17.

Do this with each taste-component and you got the average taste of the dish on each component.

Now what combination of these values is a "balanced" taste and what isn't is more of a topic for cooking stack exchange. But your implementation will likely boil down to finding target values for each taste component and grade the player by how close they got to the target values.

• This does seem the best approach so far. I knew I'd have to find target values, which has been rather straightforward as typing in "salt in lettuce" in Google provides you with the amount of salt per 100g - which I convert to my own ranking system. Thank you for the cooking stack exchange link, I was unaware there was one. – Ajay Aug 2 '20 at 6:49