# Cookie Clicker Chocolate Egg strategy

## Introduction

Cookie Clicker is a silly Javascript based web game. Here is a brief description of what you do: (description taken from this question: Explain a surprisingly simple optimization result)

You have an initial production capacity $p_0$ and a number of improvements $A, B, C, \ldots$ to build in some sequence you can choose. Each improvement $X$ has a cost $c_X$ and will take time to build proportional to its cost and inversely proportional to your capacity. When finished it will increase your production capacity by a given amount $p_X$. You can only build one improvement at a time. Which sequence should you build in in order to get all improvements as quickly as possible?

## Background

However, there are a few twists in the game, not mentioned by that description:

• Heavenly Chips
• Essentially, the more cookies you have produced in all runs combined, the faster you can produce chips beginning with the next playthrough.
• The amount of cookies required for the next Heavenly chip increases linearly.
• Specifically, the first chip requires 1 trillion cookies baked all time, the second 2 trillion, the third, three, etc.
• Therefore the total number of chips you will have after a reset is the next triangular number, multiplied by 1 trillion.
• the Chocolate Egg.
• When you buy the Chocolate Egg (which costs a relatively negligible amount of cookies), you gain cookies equal to $5%$ of your current supply of cookies - not counting the cookies you spent to buy buildings and upgrades.
• You may sell buildings for half of what you paid for them. This does not affect your cookies produced total.
• Each new building of the same type costs $1.15$ times more than the previous building of that type.

So, late in a round of cookie clicker, buildings begin to cost an astronomical amount of cookies.

Consider the following scenario:

1. You build a building, which costs $c_X = 10^{21}$, and has a production rate of $1.5*10^{14}$ cookies per second. You now have $0$ cookies.
2. You immediately sell it (after $t=0$ seconds), so you get a refund of $5*10^{20}$.
3. You buy Chocolate Egg, which gains you (approximately) $2.5*10^{19}$ cookies. You then reset, gaining the appropriate amount of extra Heavenly chips for that bonus amount.
4. If you had not built the building, you would have gained $5*10^{19}$ cookies.
5. However, if you had allowed the building to produce for some number of seconds, it would have eventually produced enough cookies to pay for the lost Chocolate Egg cookies, plus all the cookies it will continue to produce after that point.

## The Question

Towards the end of a run, you might often let the game produce cookies for awhile, without building more buildings. This is because of the phenomenon described above - if you don't let the building produce for long enough, you will lose potential Chocolate Egg cookies. So here's the question:

For simplicity, assume there is only one type of building. Given:

• Current bank of cookies $B_0$
• Initial production $p_0$
• Incremental production $p_X$
• Incremental cost $c_X$, where $c_{X+1} = 1.15 \cdot c_X$
• Current time $t_0$
• Planned time to reset $t_{reset}$

How long before $t_{reset}$ should you stop making new buildings and start banking cookies?

It's more about the number of cookies you want to bake before reseting than the time you want to wait before reseting.

Suppose you want to bake $n$ more cookies before selling all your buildings (without buying the supplementary prism). Suppose the boost given by a supplementary prism take your production from $P$ to $P(1+\alpha)$. If you play as hard and as long with that extra prism than without you'll produce $n(1+\alpha)$ cookies before selling your buildings. So the extra cookie given by the extra prism will amount to $\alpha \cdot n$.

Now the amount of cookies lost by the extra prism in the use of chocolate egg is (without the auras) $0,05\times0,5\times$cost of the extra prism. If this quantity is inferior to $\alpha\cdot n$ then it's more efficient to buy the prism. With the auras (and believe me it's more efficient to switch to the aura to sell at 85%) there is a shifting of one prism and the amount of cookie lost is $0,05\times 0,15 \times$cost of the prism before the extra prism. For the other buildings it's juste $0,05\times 0,15 \times$ cost of the extra building.

I think it's better to think in terms of number of cookies before reseting because with this technique you can take account of the cookies given by the golden cookies (which account for the majority of your cookies for an active gameplay). If you just play by iddeling then number of cookies before reset and time before reset are roughly the same thing, you can deduce one from the other easily as they're proportional.

However this is all theoretical and it doesn't really matter. The amount of lost cookies by buying lots of building is usually negligible, especially with the update with auras. The difference between best chocolate egg strategy and "buying everything i can" strategy is only about $0,75$% of your bank.

• Thanks for your answer; I asked this question before auras existed, I think it should be discussed in that context. – durron597 May 13 '16 at 17:23
• Also, the "number of cookies" might be the right way to think about it, but t_reset is the number you need to know when planning your life. – durron597 May 13 '16 at 17:25
• Heh i can respect that, i'm more of a "round number" guy so i like to have round number of heavenly chips, hence these calculations. – Renart May 14 '16 at 9:49
• Sure. Though of course t_reset = num_cookies / cookie_per_s anyway, easy enough. But I got to a point where I realized that the only thing that mattered was getting that stacked golden cookie and it was super boring to wait around for it for hours and hours so I stopped playing. – durron597 May 16 '16 at 21:20