Cookie Clicker Wiki
Advertisement

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.

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.

Candidate pool contents
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 properly, consider two cases. First assume that the pool is never replaced.

Probability without Dragonflight (Win)
Frenzy=Lucky=C.Frenzy Storm Blab Building Sugar
29.73144554% 3.214241071% 1.607120536% 5.982025893% 0.002275892857%

Second, assume that the pool is always replaced:

Probability without Dragonflight (Win)
StormDrop Sugar
99.995% 0.005%

The actual probability will be mix of these two cases.

Probability without Dragonflight (Win)
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.
Probability (Fail)
Clot=Ruin Cursed Finger=Elder Frenzy Sugar Blab
42.70815% 2.24865% 0.0864% 10%

Golden/Wrath cookie[]

Golden cookie[]

For Golden cookie and Wrath cookie, there is an additional rule. Here is a detailed example for the procedure of picking effect of golden cookies in version 1.0466. For probability of Golden/Wrath cookie in current version, see Golden Cookie Probabilities.

  • Add Frenzy and Lucky to a pool.
  • p1 = 3% chance to add Chain to the pool, if at least 100,000 cookies have been baked in this game.
  • p2 = 10% chance to add Click Frenzy to the pool.
  • Removal Rule: 80% chance to remove the previous effect from the pool, if it's there.
  • p3 = 0.01% chance to add Blab to the pool.
  • Pick a random effect from the pool.

The Removal Rule makes things more complicated but still doable. First we shall ignore the rule, and calculate the probability by listing all possible pools as mentioned above. (From now on we shall assume that at least 100,000 cookies have been baked.)

Pool Probability
# of effect Chain C.Frenzy Blab
5 X X X
4 X X
4 X X
3 X
4 X X
3 X
3 X
2

Therefore, the probability of picking Frenzy, Lucky, Chain, Click Frenzy and Blab are:

Effect Primitive probability
Frenzy
Lucky
Chain
Click Frenzy
Blab

However, due to the Removal Rule, the actual probability depends on the previous cookie. For example, if the previous cookie was Frenzy, there is an 80% chance that we shall apply the following table.

Pool Probability
# of effect Chain C.Frenzy Blab
4 X X X
3 X X
3 X X
2 X
3 X X
2 X
2 X
1

From the table, we can calculate the conditional probability:

Conditional probability
Previous Cookie Frenzy Lucky Chain C.Frenzy Blab
Frenzy 0% 93.5954% 1.44995% 4.94984% 0.00478583%

Remember that the actual probability should be a combination of 20% primitive probability and 80% conditional probability:

Actual probability
Previous Cookie Frenzy Lucky Chain C.Frenzy Blab
Frenzy 9.57135% 84.4477% 1.35496% 4.94984% 0.004783%

The actual probability of Lucky is the same as Frenzy. For conditional probability of Chain, we shall consider the following table:

Pool Probability
# of effect Chain C.Frenzy Blab
4 X X X
3 X X
3 X X
2 X
4 X X
3 X
3 X
2

And the actual probability is:

Actual probability
Prev. Cookie Frenzy Lucky Chain C.Frenzy Blab
Chain 48.2368% 48.2368% 0.194995% 3.32825% 0.0032452%

Repeating the process, we can build up the following table. Notice that since we add Blab after applying the Removal Rule, the conditional/actual probability when the previous cookie was blab is the same as the primitive probability.

Current Cookie
Prev. Cookie Frenzy Lucky Chain Click Frenzy Blab
Frenzy 9.5713547% 84.44769536% 1.3549572% 4.62151886% 0.00447386%
Lucky 84.44769536% 9.5713547% 1.3549572% 4.62151886% 0.00447386%
Chain 48.2367547% 48.2367547% 0.1949952% 3.3282502% 0.0032452%
Click Frenzy 49.17004136% 49.17004136% 0.9949752% 0.6616502% 0.00329186%
Blab/None 47.8567735% 47.8567735% 0.974976% 3.308251% 0.003226%

The table above is a transition matrix, the long term (stationary) probability can be found as the eigenvector of the transition matrix with eigenvalue 1.

The Long Term Probability
Frenzy Lucky Chain Click Frenzy Blab
47.121495% 47.121495% 1.3236432% 4.4289617% 0.0044052%

Using this, we can obtain the following table shows the final result. Each cell represents the "combo probability" or "pair probability" of golden cookies. The sum of every possible pair probability is 1.

Current Cookie
Prev. Cookie Frenzy Lucky Chain Click Frenzy Blab Total
Frenzy 4.5101654% 39.793016% 0.6384761% 2.1777288% 0.0021082% 47.121495%
Lucky 39.793016% 4.5101654% 0.6384761% 2.1777288% 0.0021082% 47.121495%
Chain 0.6384825% 0.6384825% 0.0025810% 0.0440542% 0.0000430% 1.3236432%
Click Frenzy 2.1777223% 2.1777223% 0.0440671% 0.0293042% 0.0001458% 4.4289617%
Blab 0.0021082% 0.0021082% 0.0000429% 0.0001457% 0.0000001% 0.0044052%
Total 47.121495% 47.121495% 1.3236432% 4.4289617% 0.0044052% 100%

Wrath cookie[]

For wrath cookies, the procedure of determining effect is different:

  • Add Lucky, Clot and Ruin to a pool.
  • 30% chance to add Elder Frenzy and Chain to the pool.
  • If previous step fails (70%), 3% chance to add Chain to the pool, if at least 100,000 cookies have been baked this game.
  • 10% chance to add Click Frenzy to the pool.
  • 80% chance to remove the last effect from the pool, if it's there.
  • 0.01% chance to add Blab to the pool.
  • Pick a random effect from the pool.

However, the transition matrix can (assuming at least 100,000 cookies have been baked) still be made:

Current Cookie
Prev. Cookie Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Lucky 5.6962699% 38.3759471% 38.3759471% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
Clot 38.3759471% 5.6962699% 38.3759471% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
Ruin 38.3759471% 38.3759471% 5.6962699% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
E.Frenzy 29.6413112% 29.6413112% 29.6413112% 1.1799806% 7.5743544% 2.3194559% 0.0022754%
Chain 29.7757059% 29.7757059% 29.7757059% 7.0598646% 1.2828785% 2.3278556% 0.0022835%
C.Frenzy 29.0223955% 29.0223955% 29.0223955% 5.9799006% 6.5027901% 0.4478916% 0.0022311%
Blab 28.4813495% 28.4813495% 28.4813495% 5.8999029% 6.4143927% 2.2394582% 0.0021977%

And the long term probability can be calculated:

Long Term Probability
Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
27.832181% 27.832181% 27.832181% 6.6406924% 7.2047971% 2.6553223% 0.0026445%

The final table of pair probability then can be obtained:

Current Cookie
Prev. Cookie Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Lucky 1.5853962% 10.680863% 10.680863% 1.9649143% 2.1455130% 0.7738750% 0.0007565%
Clot 10.680863% 1.5853962% 10.680863% 1.9649143% 2.1455130% 0.7738750% 0.0007565%
Ruin 10.680863% 10.680863% 1.5853962% 1.9649143% 2.1455130% 0.7738750% 0.0007565%
E.Frenzy 1.9683883% 1.9683883% 1.9683883% 0.0783589% 0.5029896% 0.1540279% 0.0001511%
Chain 2.1452792% 2.1452792% 2.1452792% 0.5086489% 0.0924288% 0.1677173% 0.0001645%
C.Frenzy 0.7706381% 0.7706381% 0.7706381% 0.1587856% 0.1726700% 0.0118930% 0.0000592%
Blab 0.0007532% 0.0007532% 0.0007532% 0.0001560% 0.0001696% 0.0000592% 0.0000001%
Total 27.832181% 27.832181% 27.832181% 6.6406924% 7.2047971% 2.6553223% 0.0026445%

Grandmapocalypse[]

The Grandmapocalypse has four phases: Appeased, Awoken, Displeased, Angered. For the first phase all the cookies will be golden, and for the last phase all cookies will be wrath.

In the two middle phases, the probability of wrath cookie is 1/3 and 2/3 respectively. If you clicked every cookies no matter what it is, then the transition matrix of these two phases can be obtained by the linear combination of transition matrix of Appeased phase (pure golden cookie) and transition matrix of Awoken phase (pure wrath cookie).

Let us show the golden transition matrix and wrath transition matrix first:

Golden Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy 9.5713547% 84.44769536% 0% 0% 0% 1.3549572% 4.62151886% 0.00447386%
Lucky 84.44769536% 9.5713547% 0% 0% 0% 1.3549572% 4.62151886% 0.00447386%
Clot/None 47.8567735% 47.8567735% 0% 0% 0% 0.974976% 3.308251% 0.003226%
Ruin/None 47.8567735% 47.8567735% 0% 0% 0% 0.974976% 3.308251% 0.003226%
E.Frenzy/None 47.8567735% 47.8567735% 0% 0% 0% 0.974976% 3.308251% 0.003226%
Chain 48.2367547% 48.2367547% 0% 0% 0% 0.1949952% 3.3282502% 0.0032452%
C.Frenzy 49.17004136% 49.17004136% 0% 0% 0% 0.9949752% 0.6616502% 0.00329186%
Blab/None 47.8567735 47.8567735% 0% 0% 0% 0.974976% 3.308251% 0.003226%
Wrath Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy/none 0% 28.4813495% 28.4813495% 28.4813495% 5.8999029% 6.4143927% 2.2394582% 0.0021977%
Lucky 0% 5.6962699% 38.3759471% 38.3759471% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
Clot 0% 38.3759471% 5.6962699% 38.3759471% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
Ruin 0% 38.3759471% 38.3759471% 5.6962699% 7.0598646% 7.7087491% 2.7805042% 0.0027181%
E.Frenzy 0% 29.6413112% 29.6413112% 29.6413112% 1.1799806% 7.5743544% 2.3194559% 0.0022754%
Chain 0% 29.7757059% 29.7757059% 29.7757059% 7.0598646% 1.2828785% 2.3278556% 0.0022835%
C.Frenzy 0% 29.0223955% 29.0223955% 29.0223955% 5.9799006% 6.5027901% 0.4478916% 0.0022311%
Blab 0% 28.4813495% 28.4813495% 28.4813495% 5.8999029% 6.4143927% 2.2394582% 0.0021977%

Then combine them in G:W=2:1 (Awoken) and G:W=1:2 (Displeased):

Awoken Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy 6.38090% 65.79225% 9.49378% 9.49378% 1.96663% 1.96663% 3.82750% 0.00372%
Lucky 56.29846% 8.27966% 12.79198% 12.79198% 2.35329% 3.47289% 4.00785% 0.00389%
Clot 31.90452% 44.69650% 1.89876% 12.79198% 2.35329% 3.21957% 3.13234% 0.00306%
Ruin 31.90452% 44.69650% 1.89876% 12.79198% 2.35329% 3.21957% 3.13234% 0.00306%
E.Frenzy 31.90452% 41.78495% 9.88044% 9.88044% 0.39333% 3.17477% 2.97865% 0.00291%
Chain 32.15784% 42.08307% 9.92524% 9.92524% 2.35329% 0.55762% 2.99479% 0.00292%
C.Frenzy 32.78003% 42.45416% 9.67413% 9.67413% 1.99330% 2.83091% 0.59040% 0.00294%
Blab 31.90452% 41.39830% 9.49378% 1.96663% 1.96663% 2.78811% 2.95199% 0.00288%
Displeased Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy 3.19045% 47.13680% 18.98757% 18.98757% 3.93327% 4.72791% 3.03348% 0.00296%
Lucky 28.14923% 6.98796% 25.58396% 25.58396% 4.70658% 5.59082% 3.39418% 0.00330%
Clot 15.95226% 41.53622% 3.79751% 25.58396% 4.70658% 5.46416% 2.95642% 0.00289%
Ruin 15.95226% 41.53622% 25.58396% 3.79751% 4.70658% 5.46416% 2.95642% 0.00289%
E.Frenzy 15.95226% 35.71313% 19.76087% 19.76087% 0.78665% 5.37456% 2.64905% 0.00259%
Chain 16.07892% 35.92939% 19.85047% 19.85047% 4.70658% 0.92025% 2.66132% 0.00260%
C.Frenzy 16.39001% 35.73828% 19.34826% 19.34826% 3.98660% 4.66685% 0.51914% 0.00258%
Blab 15.95226% 34.93982% 18.98757% 18.98757% 3.93327% 4.60125% 2.59572% 0.00258%

The final tables of pair probability are presented below:

Awoken Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy 2.090926% 21.55913% 3.110970% 3.110970% 0.644436% 0.996633% 1.254214% 0.001217%
Lucky 21.20543% 3.118624% 4.818239% 4.818239% 0.886392% 1.308101% 1.509599% 0.001465%
Clot 3.292897% 4.613170% 0.195973% 1.320273% 0.242885% 0.332295% 0.323291% 0.000315%
Ruin 3.292897% 4.613170% 1.320273% 0.195973% 0.242885% 0.332295% 0.323291% 0.000315%
E.Frenzy 0.692677% 0.907191% 0.214514% 0.214514% 0.008539% 0.068927% 0.064669% 0.000063%
Chain 1.015420% 1.328821% 0.313401% 0.313401% 0.074308% 0.017608% 0.094564% 0.000092%
C.Frenzy 1.177110% 1.524501% 0.347392% 0.347392% 0.071578% 0.101656% 0.021201% 0.000106%
Blab 0.001140% 0.001480% 0.000339% 0.000339% 0.000070% 0.000100% 0.000106% 0.000000%
Total 32.76850% 37.66609% 10.32110% 10.32110% 2.171094% 3.157614% 3.590935% 0.003574%
Displeased Current Cookie
Prev. Cookie Frenzy Lucky Clot Ruin E.Frenzy Chain C.Frenzy Blab
Frenzy 0.559120% 8.260622% 3.327530% 3.327530% 0.689297% 0.828557% 0.531611% 0.000518%
Lucky 8.745448% 2.171032% 7.948467% 7.948467% 1.462247% 1.736964% 1.054508% 0.001026%
Clot 3.103346% 8.080440% 0.738767% 4.977094% 0.915615% 1.062995% 0.575141% 0.000562%
Ruin 3.103346% 8.080440% 4.977094% 0.738767% 0.915615% 1.062995% 0.575141% 0.000562%
E.Fren. 0.698358% 1.563449% 0.865091% 0.865091% 0.034438% 0.235287% 0.115970% 0.000113%
Chain 0.822308% 1.837500% 1.015193% 1.015193% 0.240704% 0.047063% 0.136105% 0.000133%
C.Fren. 0.492380% 1.073631% 0.581251% 0.581251% 0.119763% 0.140199% 0.015596% 0.000078%
Blab 0.000477% 0.001045% 0.000568% 0.000568% 0.000118% 0.000138% 0.000078% 0.000000%
Total 17.52478% 31.06816% 19.45396% 19.45396% 4.377797% 5.114199% 3.004149% 0.002992%

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[]

No Dragon Aura
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
Aura: Reality Bending
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
Aura: Dragon's Curve
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
Both Dragon Auras
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[]

No Dragon Aura
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
Aura: Reality Bending
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
Aura: Dragon's Curve
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
Both Dragon Auras
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[]

  1. 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.
Advertisement