Monday, 23 September 2013

Cookie Clicker

Have you player Cookie Clicker?  You click the cookie to make a cookie, and then you use cookies as currency to buy buildings that make cookies automatically for you.  Solid gameplay.

Like other browser games of this genre, you can leave Cookie Clicker running all night while you are asleep or all day while you are at work and the currency just keeps piling up.  Of course this is only useful up to a point.  When you begin the game by buying yourself a 0.1 cookie per second income and eventually work your way up to billions, the idea of simply never logging in doesn't work as well as it does in a game like, oh, Diablo 3.

But also the most expensive things in the game are so outrageously expensive that simply waiting to acquire them starts to take extremely long periods of time.  Oddly enough, Cookie Clicker has an early game that makes you want to use your mouse to click things, a middle game where you might as well just leave it running for the evening, and a late game where once again you have to click, but this time you have to pay attention to the screen.

So lets start with the basics.  You generate 1 cookie every time you click the cookie.  For 15 of these you can buy a cursor that will automatically click the cookie every 10 seconds, that is, you can buy 0.1 cookies per second.  For 100 cookies you can buy a grandma who bakes 0.5 cookies per second.  For 500 you could buy a farm that grows 2 cookies per second, and so on.  Every time you buy a building the price of the next one of the same type increases by 15%.  As you might have noted, buying 0.1 Cps for 15 C gets you 1 Cps per 150 C invested, while buying 0.5 Cps for 100 C gets you 1 Cps per 200 C invested.  Cursors, in fact, are more efficient than all of the other building types.  But because the second cursor actually costs 17, the third 20 and the fourth 23, it rapid becomes better to save for a grandma.  This kind of math means that later on you'll buy an anti-matter condenser where you have to invest nearly 4000 C per Cps gained.

There are also upgrades.  For almost all the buildings - cursors and grandmas being the exceptions - upgrades are quite simple.  When you buy the building there are two upgrades.  One costs about ten times the base cost of the building and adds to the amount you get from each of the buildings.  For farms you buy another 0.5 cookies per second per farm, which means that if you have four farms then it would increase your Cps by 2, the same amount as buying another farm would.  Of course if you have four farms, the next farm costs 874 while the upgrade costs 5000, so you would probably just buy another farm.  At some point, though, the upgrade will be worthwhile, depending on the specific numbers.

The second upgrade double production of those buildings and costs 100 times the base price.  This one is easy.  Since the next upgrade always costs 1.15^n times the base amount and the upgrade gets you +n for 100 times the base amount, it is easy to see that when n=15, 100/n is less than 1.15^n, so you should buy the upgrade.

That is just in time to unlock the next upgrade.  When you get more copies of each building it unlocks more doubling upgrades that cost 1000 and 10,000 times the base amount.  These are more efficient than buying another copy of the building when you have 27 and 40 of the building respectively, although since the latter doesn't unlock until you have 50 copies of the building it is more of a buy-immediately type of thing.

So basically you sit on your farms until you get your mines, ride the mines until your factories, factory your way up and up until you get the better buildings.  When your Cps is only 0.5 clicking the cookie a couple of times a second to make 1 more cookie per click is your main source of income.  When you Cps is 10,000 it hardly seems worth doing.  Even after you get the upgrades that allows you to add 4% of your current Cps to each click, the numbers still look awefully small and increasing your overall production by 8-12% is not worth the effort of click - nor is increasing it by 20% worth the effort of clicking really fast.

But then there are golden cookies.  Every 5 to 15 minutes a golden cookie will appear at a random spot on the screen.  If you click it you will get one of a few different bonuses.  There actually four different golden cookies, but the odds of getting two of them are very low.  Also, there is something that prevents you from getting the same one as you got last time 80% of the time.  Naturally this means there is only about a 10% chance you will get the same one since not only does it have to be not removed from the list, but it also has to be chosen over the other likely candidate.  For the most part, you alternate between lucky cookies and frenzy cookies.

Frenzy multiplies your production by seven for seventy-seven seconds.  Lucky cookies increases your current holdings by 10%, up to a maximum of 20 minutes worth of production.  So if you get one of these every ten minutes, and it mostly alternates, then with 462 seconds of cookes from frenzy and 1200 seconds of cookies from lucky every 600 seconds, the combined effect is to increase your production by 137%.  You really have to click those cookies.

The problem is it is not realistic to get 1200 seconds of production from the lucky cookies.  Suppose you have 100 Cps.  At this stage you are able to access building and upgrades that give you about 0.3% to 0.4% of their purchase price in Cps.  For example, by spending 10,000 to buy a mine you get 40 Cps.  So by saving up 200 minutes to make sure that 10% of your current cookies is 20 minutes of production, you could get 120,000 cookies every 20 minutes, or 100 extra Cps.  But instead of saving up for just over three hours, you could have bought ten mines for around 200,000.  Basically it is never worth it to stockpile cookies because you can spend those cookies to increase your Cps by more than the stockpile does.

After after you click 7 golden cookies you can spend some millions on an upgrade that halves the time between the cookies.  And after clicking 27 you can halve the time again for some billions.  Then after clicking 77 you can double the duration of the golden cookie effects for some trillions of cookies.  What's more, when you have your production up a billion per second, because of the exponential cost of buildings, you are going to be hard pressed to increase your Cps by more than a ten thousandth of a pecent - that is a millionth - of what you spend.

So now frenzy gives you 924 seconds of production.  The time for a golden cookie to spawn is only 75 to 225 seconds which means a little more than half the time the lucky cookie spawns while you still have seven times your normal production, letting you get up to 2 hours and 20 minutes of production from that one click.  So you could be increasing your current production of 1 billion cookies by about 1000 per second - and that increase would rapidly decrease, or you could stockpile 84 trillion cookies to make sure that when you get that frenzied lucky cookie you can collect your rewards.  This is a very different decision.

If you don't stockpile you are probably going to accumulate a few trillion cookies at a time, so we'll say a lucky cookie will be worth about 200 seconds of production.  That means that every 300 seconds you are getting a 924 seconds of production frenzy and a 200 seconds of production lucky cookie.  So golden cookies are effectively increasing your production by about 374%.  If you have the stockpile then every 300 seconds you are getting 924 seconds of production from a frenzy and 4800 seconds of production from a lucky cookie, a 1908% increase over your base amount, and a total of over four times as much production as you would have without stockpiling.  Because of the meagre returns from buying buildings, that same 84 trillion cookies would only increase your production by about 10% to 15%, a far cry from four times.

So golden cookies always have the potential to make a big difference, but when you only have so much attention to pay to the game, going to sleep for eight hours is going to increase your horde far more than paying attention to the screen.  In end game, when golden cookies can multiply your production by 20 times, paying attention can really matter, just like clicking mattered a lot when a click gave you more than a second of production.

My goal is to make a browser game that you actually play to play.  The late game of cookie clicker fits this nicely because one hour of play almost as important a as a whole day of non-play.  The mid game, however, is all about doing something else while the cookies pile up.  I have some ideas of how to make this work.


  1. ....You're making me want to play Cookie Clicker, damn you.

    1. Just wait for my browser-based non-game. It will be much better than Cookie Clicker - but only because I am using Glitch art.