Consumables
Overview
Consumables in KoL are computed very strangely.
Each consumable has a minadv, and a maxadv. These two values are internal to the database. The player never sees these.
- minadv is always an integer.
- maxadv does not necessarily have to be.
Each consumable has a range that gets computed from minadv and maxadv (quite possibly a chopped range). The minimum of this range is always an integer. The maximum doesn't have to be. When a food or drink is consumed, the following happens:
- The game chooses a value between the minimum and (the integer part of) the maximum in a uniformly random fashion.
- The decimal part of the maximum is used as a probability of adding another adventure.
- Munchies pills are computed after a value is chosen, but before Milk is computed.
- Milk of magnesium and The Ode to Booze are calculated next.
- Salty Mouth gets added on next, for applicable drinks.
- Frosty's frosty mug and Ol' Scratch's salad fork are computed after that.
- Finally, the Tuxedo shirt gets added on after everything else, for applicable drinks.
A table of foods with various modifiers active.
A table of boozes with various modifiers active.
Many consumables also have a Size (equal to the fullness/drunkenness of that item) and a Quality (value chosen to make adventure gains better). The S/Q paradigm denotes that a food uses Size and Quality to determine its minadv and maxadv. Most older (NS11) consumables follow S/Q. Size and Quality are very important for crafted consumables, when two craftable things are put together, the Size and Quality values of the two get added together.
For any consumables following S/Q:
- minadv=Size
- maxadv=Size*Quality
Range Chopping
If the difference between minadv and maxadv is greater than 7, then a chop is performed from either end of the range. This chop is equal to:
- Food: floor(floor(maxadv-minadv-6)/2) from both sides.
- Booze: floor(floor(maxadv-minadv-4)/2) from both sides.
Consequences
Because of this, a food that has been chopped will always have its unmodified observed range be 6 or 7, due to the following:
- T = top of range, B = bottom of range, M=max, m=min.
- T = M - floor(floor(M-m-6)/2)
- B = m + floor(floor(M-m-6)/2)
- T - B = M - floor(M - m - 6)/2 - m - floor(M - m - 6)/2
- = M - m - floor(M) + m + 6
- = [M - floor(M)] + 6
- = 6 + (0 or 1)
Similarly, a booze that has been chopped will always have its unmodified observed range be 4 or 5.
What to take away from this: If a food's unmodified observed range is not 6 or 7, then either it has not been chopped, or the food has been messed with in some way by the game designers. Similar logic can be applied for a booze which has a range that is not 4 or 5.
Other Consumables
There are also many consumables which do not follow the S/Q pattern. Supernova Champagne is an example. Its range is hardcoded 7-11.0. While that would fit with S=3, Q=5, it does not fit because of the way Blender would affect maxadv of 15, and because of the observed values for Supernova Champagne seen with Blender alone. These types of consumables are assumed to have their minadv and maxadv hardcoded.
Examples of Size and Quality
A Booze example
Size and Quality values are added together for craftable things. Basic booze has S=3 and Q=1, basic fruits have S=1 and Q=1, and cocktail garnishes have Q=3. Therefore, Advanced Cocktails are S=4 and Q=5. Their minadv is 4, and their maxadv is 20. They get chopped by floor(20-4-4)/2 = 6 from both sides, producing the range 10-14.0. So the minimum is 10, and the maximum is 14.0. With no modifiers, this means that all 5 observable values are equally likely to show up, and there will never be an adventure added.
A Food example
Hi meins are S=5 and Q=8.9. Their minadv is 5, and their maxadv is 44.5, they get chopped by floor(44.5-5-6)/2 = 16 from both sides, producing the range 21-28.5. So the minimum is 21, and the maximum is 28.5. With no modifiers, this means that the 8 observable values (21-28) are equally likely to show up. However, there is also a 0.5 probability (50% chance) that an additional adventure will get added on. So 21 and 29 will each appear 1/16 of the time, and 22-28 will each appear 1/8 of the time.
Modifiers
Blender and Opossum both increase maxadv by 10%. Blender affects only Booze. Opossum affects only Food. For consumables that follow S/Q, this is mathematically indistinguishable from an increase in Q by 10% since maxadv=S*Q, and Blender makes it maxadv=S*Q*1.1. If instead one multiplies Q by 1.1, it is the exact same formula.
For those in Bad Moon, Gluttony acts the exact same way as Opossum, and Pride has half of the opposite effect. Which is to say that Gluttony gives +10% maxadv, and Pride gives -5% maxadv, so having both together gives +5% maxadv.
Using the above examples, we show that Advanced Cocktails under Blender have a range of 4-20*1.1 = 4-22. This range is then chopped by floor(22-4-4)/2 = 7, and becomes 11-15.0. So, with only Blender as a modifier, 11-15 are all equally likely to be seen.
Hi Meins under Opossum have a range of 5-44.5*1.1 = 5-48.95. This range is then chopped by floor(48.95-5-6)/2 = 18 and becomes 23-30.95. So, with only Opossum as a modifier, 23 would be observed 1/160 (about 0.62%) of the time, 24-30 would be observed 1/8 (about 12.5%) of the time, and 31 would be observed 19/160 (about 11.88%) of the time.
After this range modification is done by Opossum and Blender, then the game rolls for an actual consumption adventure amount.
Munchies pills add adventures to Food in a tiered fashion. If the actual amount that the consumable would give you is in the following ranges, then that's how much Munchies pills will add.
- 1-3 adventures, +3
- 4-6 adventures, +2
- 7+ adventures, +1
Then Milk of magnesium and Ode to Booze are added on. Unlike Opossum and Blender, but similar to Munchies Pills, Milk and Ode add adventures in tiers. If the actual amount that the consumable would give you is in the following ranges, then that's how much Milk or Ode will add.
- 1-4 adventures, +1
- 5-7 adventures, +2
- 8-10 adventures, +3
- 11+ adventures, +4
A consequence of this is that for a food like boring spaghetti, which has a range of 4-11, applying Milk of magnesium (with no other modifiers) can give it:
- +1 (if a 4 is rolled)
- +2 (if 5-7 are rolled)
- +3 (if 8-10 are rolled)
- +4 (if an 11 is rolled)
After that, for applicable beers, Salty Mouth gives a 4-6 adventure boost uniform-randomly.
Frosty's frosty mug increases adventures gained from booze by 30%, rounded down. If the booze is a beer, however, adventures are increased by 50%, also rounded down.
Ol' Scratch's salad fork increases adventures gained from food by 30%, rounded up. If the food is a salad, however, adventures are increased by 50%, also rounded up.
Finally, for applicable boozes, the Tuxedo shirt gives a 1-3 adventure boost uniform-randomly.
Example with Modifiers
This example will show how Superhuman Cocktails behave when modified by Blender, Ode, and Frosty's Mug.
It may be easier to follow along with this example by looking at the table below, since sometimes it is not readily clear why the math works out the way it does.
Superhuman Cocktails are minadv 4, with maxadv 28. This means the chop is floor(28-4-4)/2 = 10. This means that the base range to 14-18.0. The average of this range is 16.0.
Drinking these under Blender increases maxadv to 30.8, which chops by floor(30.8-4-4)/2 = 11. This produces the range 15-19.8. The average of this range is 17.8. The reason it is not 17.4 is the way the game chooses values for consumption, noted in the first section. 15-19 are rolled for in a uniformly random fashion (the average of that is 17). Then, with probability 0.8, the game adds on another adventure, so the average is 17.8.
Note that Blender changes the underlying distribution of the values that the drink can give you. Looking at the table below, you can actually observe 15-20 with Blender (and no other modifiers). The probability of getting a 20 is (1/num_values)*(chance of extra adventure) = (1/5)*(0.8) = 16%. The value of num_values is 5 here because that's what the actual number of observable values is, 20 isn't included because it only shows up as an extra adventure, not as a part of the base range.
Applying Ode to this increases all values of this chopped range by 4, since they're all above 11 (the threshold above which Ode always adds 4 adventures). This makes the range 19-23.8. The average of this range is 21.8.
Finally, drinking with Frosty's Mug increases all values of the range by 30%, but they are floored. This can be seen in the table below. Frosty's Mug acts after everything else, so 19-24 are chosen to be modified.
The average must be calculated by finding the weighted average of each possible value that's produced from the range. The minimum of the range occurs with probability (1/num_values)*(1-chance of adding an adventure), where the chance of adding an adventure is the decimal portion of the max, in this case it is 0.8, since the max is 23.8. The maximum of the range occurs with probability (1/num_values)*(chance of adding an adventure). All other values in the range occur with probability 1/num_values.
- floor(19 * 1.3) = 24, occurs with probability (1/num_values)*(1-chance of adding an adventure) = 4% chance
- floor(20 * 1.3) = 26, occurs with probability (1/num_values) = 20% chance
- floor(21 * 1.3) = 27, occurs with probability (1/num_values) = 20% chance
- floor(22 * 1.3) = 28, occurs with probability (1/num_values) = 20% chance
- floor(23 * 1.3) = 29, occurs with probability (1/num_values) = 20% chance
- floor(24 * 1.3) = 31, occurs with probability (1/num_values)*(chance of adding an adventure) = 16% chance
The weighted average is the sum of each possible value multiplied by its probability of occurring. In this case, the range is 24-31, and the average is 27.92.
It should be noted that if the chance of adding an extra adventure is zero, then all values will occur with probability 1/num_values, where num_values = the number of observable values. If chance of adding an extra adventure is not zero, then num_values is equal to the number of observable values minus one, because the highest value is a special case of getting added when the game chooses the amount of adventures you get from the consumable.
For SHCs with no modifiers (14-18.0), this produces a value for num_values of 5; and for the above example from 24-31, this also produces a num_values of 5, since there are six possible values, but the highest value is a special case of being seen only after the game chooses the maximum value and adds one. Frosty's mug affects the drink's observable values in a predictable way, and that's why there are jumps in the observable values between 24 and 26, and between 29 and 31.
Without Blender | ||||||||
---|---|---|---|---|---|---|---|---|
Modifiers | Possible Values | Average | ||||||
Chance | 20% | 20% | 20% | 20% | 20% | |||
Base | 14 | 15 | 16 | 17 | 18 | 16.00 | ||
+Ode | 18 | 19 | 20 | 21 | 22 | 20.00 | ||
+Frosty | 18 | 19 | 20 | 22 | 23 | 20.40 | ||
+Ode and Frosty | 23 | 24 | 26 | 27 | 28 | 25.60 | ||
With Blender | ||||||||
Chance | 4% | 20% | 20% | 20% | 20% | 16% | ||
Base | 15 | 16 | 17 | 18 | 19 | 20 | 17.80 | |
+Ode | 19 | 20 | 21 | 22 | 23 | 24 | 21.80 | |
+Frosty | 19 | 20 | 22 | 23 | 24 | 26 | 22.72 | |
+Ode and Frosty | 24 | 26 | 27 | 28 | 29 | 31 | 27.92 |
A Food Example
The math is the same idea for Food and Booze alike, here is an example of hi meins. Notice that, like with the Booze example above, there are jumps in the amount of adventures that are observable. So with no Opossum, but with a Fork, a player will never see an adventure gain of 31 or 35 for a hi mein.
Without Opossum | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Modifiers | Possible Values | Average | ||||||||
Chance | 6.25% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 6.25% | |
Base | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 25.00 |
+Munchies | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 26.00 |
+Milk | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 29.00 |
+Fork | 28 | 29 | 30 | 32 | 33 | 34 | 36 | 37 | 38 | 33.00 |
+Munchies and Milk | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 30.00 |
+Milk and Fork | 33 | 34 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 38.12 |
+Munchies, Milk, Fork | 34 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 45 | 39.44 |
With Opossum | ||||||||||
Chance | 0.625% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 12.5% | 11.4% | |
Base | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 27.45 |
+Munchies | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 28.45 |
+Milk | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 31.45 |
+Fork | 30 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 41 | 36.18 |
+Munchies and Milk | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 32.45 |
+Milk and Fork | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 45 | 46 | 41.31 |
+Munchies, Milk, and Fork | 37 | 38 | 39 | 41 | 42 | 43 | 45 | 46 | 47 | 42.56 |
How to Spade
Many players will only try to find the observed range of a consumable with no modifiers. While this gives a good approximation of what the consumable will do, it does not tell the whole story, due to many consumables not having an integer maxadv value.
In order to properly spade a consumable, all observed values must be recorded, and the frequency of those values must be calculated.
At that point, the middle values of the range will all occur at the same rate, and the bottom and top of the range will occur at rate*(1-chance_of_extra) and rate*(chance_of_extra), respectively. Where chance_of_extra is the decimal portion of maxadv.
Spooky mushrooms are a nice example of this, their observed range is 2-3, however, 3 will be observed 80% of the time, due to the maxadv actually being 2.8, so the range is really 2-2.8.
There are some consumables for which the maxadv cannot be ascertained without using modifiers. Imp Ale is an example of this, the observed range is 1-2, and with no modifiers, a player will see each at 50% likelihood. However, if they are instead consumed with Blender active, the player will see more twos (but no threes). In fact, the player will see twos 65% of the time, since Imp Ale is actually 1-1.5, and Blender would make them 1-1.65.