FANDOM


There are two things follow this mechanism, Golden cookie (Wrath Cookie) and Reindeer. They are called shimmers in the game. The spawning mechanism basically is probabilistic, however the probability density function can be approximated nicely by a simple function. This mechanism is also affected by your current FPS (frames per second), which can be changed via cheating. From now on we shall assume the FPS is 30.

Let us first ignore first Tmin seconds which the probability of spawning Golden Cookie is 0.

There are two basic parameter for shimmers, Tmin and Tmax and there are many factors in the game can alter these two parameters. For first Tmin seconds, the probability of spawn shimmers is 0. After Tmin seconds every frame, the game checks if a random number between 0 and 1 is less than the proportion of time elapsed between the minimum and maximum time, taken to the 5th power. Define the test probability at frame n:

f_n=\left(\frac{n}{N}\right)^5,

where N=30(Tmax-Tmin) frames is the difference of max time and min time in frame.The probability of spawning shimmer at frame n is:

p_n=f_n\Pi_{i=1}^{i=n-1}\left(1-f_i\right),

which means the game failed to spawn from frame 1 to frame n-1, but successes at frame n. The cumulative density function can be calculated:

P_n=1-\Pi_{i=1}^{i=n}\left(1-f_i\right).

Notice that

P_n-P_{n-1}=p_n=f_n(1-P_{n-1}).

Since the time of each frame is short compared to the maximum time, we may approximate the difference of left hand side as a derivative:

P'=f(1-P)

The solution can be found by usual technique. The cumulative density function of the cookie spawning at kth frame is:

P(k)=1-\exp\left(-\int_0^k f(n)dn\right)=1-\exp\left(\frac{-k^6}{6N^5}\right)

We can change the time unit to more familiar second. Let k=30t and N=30T,and we have:

P(t)=1-\exp\left(\frac{-5t^6}{T^5}\right) and p(t)=P'(t)=\frac{30t^5}{T^5}\exp\left(\frac{-5t^6}{6T^5}\right)

The resulting cumulative probability of the cookie spawning looks logistic, with the probability early in the range nearly zero but increasing extremely quickly. These function fits well, but fails when t=T=Tmax-Tmin, P(T)=1-\exp(-5T)\neq1. However it should not be bother in most case. Now we shall put the initial non-spawning time back.

\bar{p}(t)=\begin{cases}0&T_\text{min}>t\\
p(t-T_\text{min})&T_\text{max}>t\ge T_\text{min}\\
0&t\ge T_\text{max}\\
\end{cases}

\bar{P}(t)=\begin{cases}0&T_\text{min}>t\\
P(t-T_\text{min})&T_\text{max}>t\ge T_\text{min}\\
1&t\ge T_\text{max}\\
\end{cases}

It is also convenient to consider the inverse function of \bar{P}(t):

\bar{P}^{-1}(c)=\begin{cases}
\left(\frac{-T^5}{5}\ln(1-c)\right)^{\frac{1}{6}}+T_\text{min}&1-\exp(-5T)\ge c> 0\\
1&c> 1-\exp(-5T)\\
\end{cases}

The expectation value of spawning time can be obtained:

\langle t\rangle=\int_0^\infty t\bar{p}(t)dt\approx
T_\text{min}+\int_0^\infty tp(t)dt

=T_\text{min}+\left(\frac{T^5}{5}\right)^{\frac{1}{6}}\Gamma\left(\frac{7}{6}\right)\approx T_\text{min}+0.7094497 T^{\frac{5}{6}},

where \Gamma is the gamma function.