1 The game in numbers

Cookie Clicker is an idle game by Orteil. You bake cookies and spend them on buildings and upgrades, which bake more cookies. A run is the period between two resets.

Each building type has a base price p0. Each copy costs 15% more than the copy before it:

pk=1.15kp0(k=0,1,2,…)

Buildings and upgrades set the cookies per second c, also called CpS. Clicks, golden cookies and wrinklers add more. The sum is the income.

At any time you can ascend. Ascension ends the run. In return you keep prestige, which grows with the cube root of all cookies ever baked, A:

P=A/10123

After the heavenly upgrade Legacy, each prestige level adds 1% to production in all later runs. Each new level also gives one heavenly chip, which buys permanent upgrades.

Four decisions occur many times in a game: what to buy next, when to keep cookies in the bank for golden cookies, how to spend heavenly chips, and when to ascend. Chapters 2 to 5 give a rule for each decision. Chapters 6 to 9 cover the other systems. The paper contains the complete proofs. The Tools page has the patcher for Cookie Monster+, a mod that plays by these rules.

2 What to buy next

You want two items, A and B, and you cannot buy either now. Item i costs pi and adds Δi to the income c. Which item do you buy first?

If you buy A first, you save pA at income c. Then you save pB at the higher income c+ΔA. The other order is symmetric. Both orders end in the same state, so the faster order is better. Compare the two total times:

TAB=pAc+pBc+ΔA,TBA=pBc+pAc+ΔB

The comparison simplifies to one index for each item.

Rule 1 (pairwise exchange). Buy A first if and only if EA≤EB, where

Ei=pic+piΔi.

The first term is the time to save for the item. The second term is its payback time: the time that the item needs to earn back its price. Cookie Monster shows the sum as the payback period. When you cannot buy any of the items, the payback period gives the same order as Ei. Thus the usual community rule is exactly correct in that case.

The rule is local. Ei changes as c increases, so no single sorted list is correct for the whole game. At each decision, buy the item with the smallest Ei.

A large bank changes the rule. If the bank holds enough for either item but not for both, buy the item with the larger Δi first. In simulations this difference changes the time to a goal by less than 0.4%.

Which purchase first

Set the income and the two items. The display compares the two orders.

3 Golden cookies and the bank

A golden cookie appears on the screen at random times. A click gives one of several effects. The most frequent are Frenzy, which multiplies production by 7 for 77 seconds, and Lucky!, which pays

min⁡(0.15b, 900c)+13

cookies, where b is the bank. Below the cap, at a bank of 6,000 seconds of CpS, the payout is 15% of the bank. Thus each cookie in the bank earns a part of every Lucky! payout.

Lucky! payout

Move the bank. The payout grows with the bank until the cap.

First, find how often golden cookies appear. The game waits at least tmin⁡=5 minutes and at most tmax⁡=15 minutes. In each frame after the minimum, the chance of a golden cookie is ((t−tmin⁡)/W)5. Here t counts frames, and the window has W frames at 30 frames per second. The chance that no cookie appears before the fraction x of the window is close to e−Wx6/6. One integral then gives the mean fraction:

𝔼[x]≈Γ(76)(6W)1/6

At the base frequency, a golden cookie appears every 447 seconds on average. Lucky day and Serendipity each halve both limits. With both upgrades, the mean interval is 121 seconds.

Golden cookie interval

Select the frequency upgrades.

About 42% of golden cookies give Lucky!. They occur at the rate λL=0.42/𝔼[I], where I is the interval. Thus a banked cookie earns 0.15gλL per second, where g multiplies golden cookie gains. A cookie spent on item i earns Δ‾i/pi per second.

Rule 2 (the Lucky! bank). Spend the cookie if and only if

piΔ‾i<θ=10.15gλL.

Here Δ‾i is all the income that the item adds: its CpS, its click power at the clicker's rate, and the extra income that Frenzies and other golden effects make from both. With both frequency upgrades, θ is about 1,900 seconds. Early in a run, payback times are seconds or minutes, so spend every cookie. Late in a run, payback times are hours, so keep the bank.

4 Heavenly chips

Heavenly upgrades cost chips. Each upgrade multiplies the speed of every later run. Upgrade j costs pj chips and multiplies the speed by mj>1. New chips arrive faster at a higher speed, so an upgrade bought early also shortens the wait for every later upgrade.

Rule 3 (ratio rule). Buy the upgrades in decreasing order of

ρj=1−1/mjpj.

To prove the rule, swap two adjacent upgrades i and j. Every other wait stays the same. The swap shortens the total time if and only if ρi>ρj. This is Smith's rule from the scheduling of jobs.

The rule tells you to save. Do not buy a cheap upgrade with a low ratio while an upgrade with a higher ratio is still too expensive. Value an upgrade that needs a parent together with the parent, as one block.

5 When to ascend

Ascension is a trade. It ends the run, and in return every later run is faster. If a run at speed 1 bakes F(x) cookies in time x, the same run at speed S bakes F(St) cookies in time t. A faster run follows the same path in less time.

Late in the game, the speed is proportional to prestige. Suppose that the cookies of a run grow like tβ, where β is the growth exponent of the run, and write γ=3/β−1. A telescoping lower bound on the total time then gives the best schedule. Each run multiplies all-time cookies by the same factor v⋆, the root of

β3(1−1v)=1−v−γ/3γ.

For β=2, v⋆≈7.9, and for β=3, v⋆≈16.8. Prestige grows by the cube root of v⋆ in each run: about 2.0 and 2.6 times.

Growth in each run

Select the growth exponent of the current run.

A familiar rule says: ascend when the marginal rate falls to the average rate. This is the marginal value theorem. It is correct only at β=3, because it ignores that later runs become longer or shorter. At β=6, it waits 6.5 times too long.

Early in the game, prestige changes the speed very little, and a reset only loses time. If every run has the same speed, one long run is the fastest way to bake any number of cookies. The mod therefore uses a dynamic program over all future ascensions, including the heavenly upgrades that each ascension can buy. Late in the game it agrees with the formula above, and early in the game it does not reset too soon.

6 Achievements and milk

Each achievement, except the shadow achievements, adds 4% milk. Kitten upgrades turn milk into production. With kitten factors ki, milk μ and a milk multiplier m, production carries the factor ∏i(1+kimμ). One more achievement multiplies production by

∏i1+kim(μ+0.04)1+kimμ.

On an observed save with eight kittens and 952% milk, one achievement adds 2.14% to production. The mod takes every achievement that needs only an action at once. Examples are a click on the news ticker in a narrow window, one of Santa's helper grandmas, and a gift code sent to yourself.

Some achievements cost time, for example a special run. The rescaling of time also gives these a price. A permanent gain of a share x of income makes all later play x times faster. Over the remaining play time H, the gain is worth xH seconds. A delay of D seconds costs D seconds.

Rule 4 (worth of an achievement). An action that delays play by D seconds and earns achievements worth x1,…,xk pays if and only if

D<H∑ixi.

Nobody knows H in advance. With no other information, the median remaining time equals the time played so far, so the mod uses that estimate. After 77 hours of play, one achievement is worth 1.66 hours.

Neverclick and Hardcore need a Born again run, which starts without prestige or upgrades. A simulation of that run needs about 4 hours for both achievements, so the mod starts one after about 93 hours of play. Wrinklesquisher and Moistburster need 50 and 200 wrinklers burst in one run. Such a spree costs some minutes of income, so the mod does it when the run is long enough.

Worth of an achievement

Set the kittens, the milk and the hours played.

7 Godzamok

Godzamok is a god in the Pantheon minigame. When you sell buildings, Godzamok gives a 10-second buff to click power. Each building sold adds b=1% in the first slot, 0.5% in the second slot and 0.25% in the third slot. Sales during the buff add to it without a limit, but they do not make it longer.

Sell all n copies of a building whose next copy costs p, and buy them back in the same frame. Production does not change. A sale returns 25% of the price of the next copy, so the refund is 1.15×25% of the cost to buy the copies back. The round trip therefore costs

(1−1.15⋅0.25)p(1−1.15−n)0.15=0.7125×(cost to buy back).

The round trip adds bn to the buff. This is worth bnKt cookies, where K is the click income without the buff and t is the remaining time of the buff. Late in a run, this value is much larger than the cost for every building type except the newest ones.

Suppose that you cycle U buildings in each of the F=300 frames of one buff. The multiplier increases by bU in each frame, so its average over the buff is

1+bUF+12≈1+150bU.

The mouse upgrades make a click worth 15% of CpS, so 20 clicks per second bring 3 times CpS. On a late-game save, the mod cycled about 2,200 buildings per frame in 3 milliseconds. The buff averaged ×3,329, and the income increased to about 22,000 times CpS.

Godzamok buff

Select the slot and the number of buildings that the mod sells and buys back in each frame.

8 Wrinklers and wrath

The Grandmapocalypse has three stages of wrath. At stage ℓ, each golden cookie is a wrath cookie with probability ℓ/3. Wrinklers also appear. A wrinkler takes a part of CpS and returns 1.1 times its contents when you burst it.

With n wrinklers, a share s=n/20 of CpS withers. Each wrinkler receives that whole share, not a part 1/n of it. Thus wrinklers multiply the income from CpS by

W(n)=1−s+snr,W(10)=6,W(12)=8.32(r=1.1).

Wrath cookies replace Frenzies with clots and Ruin. In return they bring Elder frenzies, which multiply production by 666 for 6 seconds, and cookie storms. The table gives the share of each effect at each stage, simulated from the choice rule of the game.

Shares of golden cookie effects by stage
StageFrenzyLucky!BuildingClick frenzyStormChainElder frenzyClotRuinCursed
0.422.422.100.040.008.008––––
1.294.341.076.032.024.023.017.090.090.008
2.157.280.056.027.039.039.034.171.171.015
3–.245.041.023.055.055.051.245.244.023

When most income comes from CpS, wrath wins. With ten wrinklers, the total income is about 2.8 times that of stage 0. Godzamok changes this result. With the Elder Pact, an Elder Pledge costs at most 814≈4.4×1012 cookies, and it becomes available again when it ends. Thus the stage is a free choice.

Rule 5 (calm or wrath). Golden cookies multiply click income by 11.8 in calm and by 8.5 in wrath, and they multiply CpS income by 8.7 and 62.8. These values assume twelve wrinklers, doubled effect durations and a mean interval of 121 seconds. Calm earns more if and only if click income is more than about 16 times CpS.

With Godzamok, click income is thousands of times CpS, so the mod keeps a pledge active. It lets wrath reach stage 3 once for an achievement. Then it revokes the Elder Covenant, because the covenant costs 5% of CpS and a pledge costs nothing.

Wrinklers and the stage

Set the wrinklers and the ratio of click income to CpS.

9 Minigames and seasons

Grimoire. Below its cap M, magic regenerates at the rate κm. To fill an interval of magic from a to a+C takes

∫aa+Cdmκm=2κ(a+C−a),

which decreases in a. Thus a spell that costs C is cast most often when you cast it at full magic. The mod casts Force the Hand of Fate at full magic. Cheaper spells would reach the spell-count achievements sooner, but they would lose more golden cookies than the achievements are worth.

Pantheon. The mod tries every order of the useful gods with the CpS formula of the game and the income model. It moves gods only when income increases by more than 1%. Each ascension restores three worship swaps, but from zero swaps the next swap takes 16 hours. When a much better arrangement waits for a swap, the mod spends the next sugar lump on a refill.

Garden. New seeds come only from mutations, and mutations grow only in empty tiles next to mature parent plants. Plant parent kind A on the tiles where x+y is even and x is even. Plant kind B where x+y is even and x is odd, and leave the other tiles empty. Then every empty tile touches both kinds, on every plot of at least 2 × 2 tiles. The mod breeds Thumbcorn first, which adds 2% click power, and then Cronerice, Gildmillet, Clover and Golden clover. Wood chips give three mutation rolls in each tick.

Breeding layout

Select the farm level. A and B mark the parent tiles.

Stock Market. Prices return toward the resting value Ri=10+10i+(ℓbank−1). A purchase costs at most 20% extra and a sale costs nothing. Thus a purchase below 0.6Ri and a sale at Ri return at least 1/(0.6⋅1.2)−1=39%. The office upgrades open loans. Each loan multiplies CpS for a period and then divides it for a longer period.

Stock Market loans
LoanCpSForThenForDown payment
1×1.52 h×0.254 h20% of bank
2×240 s×0.140 min40% of bank
3×1.248 h×0.8120 h50% of bank

If the run ends before the boost ends, the penalty never applies. The mod takes a loan when the planner expects the run to end in time. It ascends early when a loan is about to end and an early ascension costs less than the penalty.

Dragon. To buy back n copies of a building whose next copy costs p takes p(1−1.15−n)/0.15, about 6.67p for n=100. The mod trains the dragon toward Radiant Appetite, which doubles production, when the buildings are available and the buy-back costs at most one hour of income.

Seasons. Christmas gives 14 levels of Santa, which cost about 1.2×1016 cookies in total. Valentine's Day gives seven heart cookies that add 2% each, and Easter gives eggs. Each run visits these seasons in that order and then stays in Christmas for the reindeer.

Sugar lumps. Lumps go first to the minigames, then to a Sugar frenzy in each run, then to cursor levels for the first loan, and then to building levels by gain per lump.