There are many things in the game that follow this mechanism to choose different effects/types randomly such as Golden cookie, Wrath cookie, Force the Hand of Fate, Garden mutations, and Sugar lump types. Basically, the mechanism starts with a pool which contains certain effects. Then, it adds different effects to the pool randomly. Finally, it chooses one effect from the pool with equal probability.
Contents
- 1 Garden Mutations
- 2 Force the Hand of Fate
- 3 Golden/Wrath Cookie
- 4 Sugar Lump
- 4.1 Without Sucralosia Inutilis
- 4.2 With Sucralosia Inutilis
- 5 Code
- 6 Notes
Garden Mutations
At each tick, the game will check every empty plots for possible mutation recipes. If certain conditions are satisfied[note 1], there will be a corresponding base chance to add the mutated plant into the candidate pool. The final outcome will be chosen from the candidate pool with equal probability. If the soil is Woodchips, the above procedure will loop 3 times at each tick.
For example, if an empty plot is surrounded by 8 Queenbeets, there are 3 possible mutations with an equal base chance of p = 0.1%; Juicy Queenbeet, Duketater and Shriekbulb. The candidate pool has 2^3 = 8 possibilities and can be grouped into four kinds according to the size. All pools in the same group have the same probability to be generated.
Group ID | Pool size | Pool generation probability | Number of pools |
---|---|---|---|
0 | 1 | ||
1 | 3 | ||
2 | 3 | ||
3 | 1 |
Among the all eight pools, there are four pools which contain Shriekbulbs: 1, 2 and 1 belong to G1, G2 and G3, respectively. The probability of picking Shriekbulbs in pool Gi will be 1/i.
After adding all four pools together, the total probability of picking Shriekbulbs is:
Since in this case all three mutating plants have the same base chance, the probability of picking Duketaters and Juicy Queenbeets will also be P = p - p^2 + (p^3)/3. Hence the probability of picking nothing is P0 = 1 - 3P.
If the soil is Woodchips, the procedure will run three times. The final result will be the plant picked in the last round. If no plant was picked in the last round, the final result will be the plant picked in the second round, and so on. The following table lists all three situations which give Shriekbulb after three rounds.
First round | Second round | Third round | Probability |
---|---|---|---|
any result | any result | Shriekbulb | |
any result | Shriekbulb | Nothing | |
Shriekbulb | Nothing | Nothing |
Therefore the total probability of mutating Shriekbulbs after three loops will be:
Hence the probability of picking nothing will be:
Take another example, if an empty plot is surrounded by 2 Baker's Wheat, then there are three mutation candidates; Baker's Wheat, Thumbcorn and Bakeberry. These have a base chance of p1 = 20%, p2 = 5% and p3 = 0.1%, respectively. There are 2^3 = 8 possible candidate pools.
Probability | |||
---|---|---|---|
Baker's Wheat | Thumbcorn | Bakeberry | |
Yes | Yes | Yes | |
Yes | Yes | No | |
Yes | No | Yes | |
Yes | No | No | |
No | Yes | Yes | |
No | Yes | No | |
No | No | Yes | |
No | No | No |
The probability of picking Baker's Wheat, Thumbcorn, Bakeberry or nothing are:
Plant | Probability |
---|---|
Baker's Wheat | |
Thumbcorn | |
Bakeberry | |
Nothing |
If the soil is Woodchips, the probability of picking Baker's Wheat, Thumbcorn, Bakeberry or nothing are:
Plant | Probability |
---|---|
Baker's Wheat | |
Thumbcorn | |
Bakeberry | |
Nothing |
Force the Hand of Fate
The procedure of Force the Hand of Fate is a little different. For golden cookie, the procedure is:
Win:
- Add Frenzy and Lucky to a pool.
- If there is no Dragonflight buff active, add Click Frenzy.
- 10% chance to add Storm, Storm and Blab to the pool.
- 25% chance to add Building Special, if you own 10 or more total buildings.
- For all buildings of which the number of buildings owned is more or equal to 10, choose one and buff according to the chosen building's amount. If no building has such quantity, choose Frenzy.
- 15% chance to replace the pool with Storm Drop.
- 0.01% chance to add Free Sugar Lump to the pool.
- Pick a random effect from the list.
Note that there is 15% chance for the pool to be replaced completely instead of adding something into the pool. To handle this rule, consider the two possible conditions, then apply the chance of these two conditions for the final result.
Frenzy=Lucky=C.Frenzy | Storm | Blab | Building | Sugar |
---|---|---|---|---|
29.73144554% | 3.214241071% | 1.607120536% | 5.982025893% | 0.002275892857% |
StormDrop | Sugar |
---|---|
99.995% | 0.005% |
Frenzy=Lucky=C.Frenzy | Storm | Blab | Building | StormDrop | Sugar |
---|---|---|---|---|---|
25.27172871% | 2.732104911% | 1.366052455% | 5.084722009% | 14.99925% | 0.002684508929% |
Fail:
- Add Clot and Ruin to a pool.
- 10% chance to add Cursed Finger, Elder Frenzy to the pool.
- 0.3% chance to add Free Sugar Lump to the pool.
- 10% chance to replace the pool with Blab.
- Pick a random effect from the list.
Clot=Ruin | Cursed Finger=Elder Frenzy | Sugar | Blab |
---|---|---|---|
42.70815% | 2.24865% | 0.0864% | 10% |
Golden/Wrath Cookie
Below is an overview of the pool selection process. For information on the effects, see Golden Cookie and Wrath Cookie. For complete probability tables, see here.
Golden Cookies
- Add Frenzy and Lucky to a pool.
- 3% chance to add Chain and Storm to the pool, if at least 100,000 cookies have been baked this ascension.
- 5% chance to add Everything Must Go to the pool, if current season is Business Day.
- 10% chance to add Click Frenzy to the pool.
- If roll succeeds and the Dragonflight effect is active, re-roll with 5% chance to add Click Frenzy (total chance: 0.5%).
- 25% chance to add Building Special to the pool, if you own more than or equal to 10 total buildings.
- 0.05% to add Sweet, if Sugar Lumps are growing.
- If any of the auras Reaper of Fields, Dragonflight, or Reality Bending is active, Dragon Harvest and/or Dragonflight may be added.
- Make two rolls with 15% and 5% chance of success, respectively (total chance: 19.25%).
- If either roll succeeds, Dragon Harvest is added with 100% chance if Reaper of Fields is active, or 10% if Reality Bending is active, and Dragonflight is added with 100% chance if the Dragonflight aura is active, or 10% if Reality Bending is active.
- With Reaper of Fields, Reality Bending has no effect on the chance of Dragon Harvest. With the Dragonflight aura, Reality Bending has no effect on the chance of Dragonflight.
- 80% chance to remove the previous outcome from the pool, if there is at least one in the pool.
- 0.01% chance to add Blab to the pool.
- Pick a random effect from the pool.
- If Building Special, check for buildings with 10 or more built, then pick one. If none are found, pick Frenzy.
Wrath Cookies
- Add Clot, Lucky, and Ruin to a pool.
- If Skruuia, Spirit of Scorn is currently selected in the Pantheon: Add Clot, Ruin, Clot and Ruin to the pool (3 total each).
- 30% chance to add Elder Frenzy, Chain and Storm to the pool.
- If previous step fails (70%), 3% chance to add Chain and Storm to the pool (2.1% total), if at least 100,000 cookies have been baked this ascension.
- 5% chance to add Everything Must Go to the pool, if current season is Business Day.
- 10% chance to add Click Frenzy to the pool.
- If roll succeeds and the Dragonflight effect is active, re-roll with 5% chance to add Click Frenzy (total chance: 0.5%).
- 10% chance to add Cursed Finger to the pool.
- 25% chance to add Building Special, if you own more than or equal to 10 total buildings.
- 0.05% to add Sweet, if Sugar Lumps are growing.
- If any of the auras Reaper of Fields, Dragonflight, or Reality Bending is active, Dragon Harvest and/or Dragonflight may be added.
- Make one roll with 5% chance of success. (The secondary 15% roll is disabled for Wrath Cookies.)
- If the roll succeeds, Dragon Harvest is added with 100% chance if Reaper of Fields is active, or 10% if Reality Bending is active, and Dragonflight is added with 100% chance if the Dragonflight aura is active, or 10% if Reality Bending is active.
- With Reaper of Fields, Reality Bending has no effect on the chance of Dragon Harvest. With the Dragonflight aura, Reality Bending has no effect on the chance of Dragonflight.
- 80% chance to remove the previous outcome from the pool, if there is at least one in the pool.
- 0.01% chance to add Blab to the pool.
- Pick a random effect from the pool.
- If Building Special, check for buildings with 10 or more built, then pick one. If none are found, pick Frenzy.
- If any applicable buildings were found, roll 30% chance of debuff, 70% chance of buff.
Sugar Lump
- Add Normal to a pool.
- Run unusual type selection.
- 10% chance to add Bifurcated to the pool. (15% with Sucralosia Inutilis)
- 0.3% chance to add Golden to the pool.
- 2% chance to add Caramelized to the pool.
- 0%-30% chance to add Meaty to the pool, depending on Grandmapocalypse stage.
(Appeased: 0%, Awoken: 10%, Displeased: 20%, Angered: 30%)
- If Dragon Curve Aura is active, run unusual type selection a second time.
- If Reality Bending Dragon Aura is active, 10% chance to run unusual type selection again.
- Pick a random effect from the pool.
Without Sucralosia Inutilis
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 93.9285% | 4.9617% | 0.1441% | 0% | 0.9657% | 1.0395075 |
Awoken | 89.3327% | 4.7970% | 0.1393% | 4.7970% | 0.9341% | 1.038202333 |
Displeased | 84.7368% | 4.6322% | 0.1346% | 9.5939% | 0.9025% | 1.036897167 |
Angered | 80.1410% | 4.4674% | 0.1299% | 14.3909% | 0.8708% | 1.035592 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 93.3704% | 5.4177% | 0.1573% | 0% | 1.0546% | 1.043140383 |
Awoken | 88.4160% | 5.2091% | 0.1513% | 5.2091% | 1.0145% | 1.041487482 |
Displeased | 83.5168% | 5.0035% | 0.1455% | 10.3593% | 0.9750% | 1.03985864 |
Angered | 78.6727% | 4.8009% | 0.1397% | 15.4507% | 0.9361% | 1.038253859 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 88.3470% | 9.5220% | 0.2766% | 0% | 1.8544% | 1.075836333 |
Awoken | 80.1658% | 8.9182% | 0.2594% | 8.9182% | 1.7384% | 1.071053817 |
Displeased | 72.5360% | 8.3449% | 0.2430% | 17.2479% | 1.6282% | 1.066511904 |
Angered | 65.4576% | 7.8021% | 0.2275% | 24.9890% | 1.5239% | 1.062210594 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 87.8334% | 9.9415% | 0.2889% | 0% | 1.9362% | 1.079180117 |
Awoken | 79.3755% | 9.2734% | 0.2698% | 9.2734% | 1.8079% | 1.073887806 |
Displeased | 71.5534% | 8.6447% | 0.2518% | 17.8630% | 1.6871% | 1.068906618 |
Angered | 64.3561% | 8.0547% | 0.2349% | 25.7808% | 1.5736% | 1.064230651 |
With Sucralosia Inutilis
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 91.4668% | 7.4426% | 0.1416% | 0% | 0.9491% | 1.053519394 |
Awoken | 87.0348% | 7.1954% | 0.1370% | 4.7146% | 0.9183% | 1.051752899 |
Displeased | 82.6027% | 6.9483% | 0.1324% | 9.4291% | 0.8875% | 1.049986403 |
Angered | 78.1707% | 6.7011% | 0.1278% | 14.1437% | 0.8567% | 1.048219908 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 90.7102% | 8.1022% | 0.1542% | 0% | 1.0334% | 1.058266588 |
Awoken | 85.9595% | 7.7915% | 0.1484% | 5.1059% | 0.9947% | 1.056046236 |
Displeased | 81.2595% | 7.4853% | 0.1427% | 10.1559% | 0.9565% | 1.053857397 |
Angered | 76.6104% | 7.1835% | 0.1371% | 15.1501% | 0.9189% | 1.051700071 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 83.9011% | 14.0387% | 0.2675% | 0% | 1.7927% | 1.100991335 |
Awoken | 76.2819% | 13.1566% | 0.2511% | 8.6277% | 1.6826% | 1.094686272 |
Displeased | 69.1708% | 12.3188% | 0.2355% | 16.6969% | 1.5780% | 1.08869634 |
Angered | 62.5677% | 11.5252% | 0.2208% | 24.2076% | 1.4788% | 1.083021538 |
Phase of Grandmapocalypse | Normal | Bifurcated | Golden | Meaty | Caramelized | Average number of lumps |
---|---|---|---|---|---|---|
Appeased | 83.2290% | 14.6245% | 0.2787% | 0% | 1.8678% | 1.105210659 |
Awoken | 75.3857% | 13.6529% | 0.2606% | 8.9542% | 1.7465% | 1.098265737 |
Displeased | 68.1232% | 12.7381% | 0.2436% | 17.2628% | 1.6322% | 1.091724534 |
Angered | 61.4319% | 11.8789% | 0.2276% | 24.9367% | 1.5248% | 1.085579625 |
Code
Given an array of probabilities pi describing the probability that item i will be added to the random list. This function returns a new array of probabilities Pi describing the overall probability that item i will be picked from the random list.
function randomListProb(list) { let out = new Array(list.length).fill(0); for (let i=1; i<Math.pow(2, list.length); i++) { let prob = 1; let count = 0; for (let j=0; j<list.length; j++) { if (i & Math.pow(2, j)) { count++; prob *= list[j]; } else { prob *= 1 - list[j]; } } prob /= count; for (let j=0; j<list.length; j++) { if (i & Math.pow(2, j)) { out[j] += prob; } } } return out; }
Example
randomListProb([0.5, 0.5]); // [0.375, 0.375]
Notes
- ↑ Some plants will prevent other plants from emerging. For example, if an empty plot is surrounded by 2 Crumbspores and 1 Everdaisy, Doughshrooms will never grow on that plot.