Cookie Clicker
Orteil and Opti's 2013 browser game about baking cookies; each building costs 15% more than the last of its kind.
Cookie Clicker is a web incremental game by Orteil and Opti1. You click a cookie, then buy buildings that bake for you. It launched on 8 August 20132, reached Android in 20193 and Steam in 20214. Its web code is one unminified main.js, archived from the first weeks.
#Prices
Prices scale exponentially: each building owned multiplies the next of its kind by 1.155, one constant for all 20 buildings. Free buildings from prestige upgrades come off the exponent6. Discounts multiply in before the rounding7.
Only the Cursor keeps the 15 written into its definition; a formula on the index overwrites the rest8,9. It gives Grandma 100, Farm 1,100, Mine 12,000, and so on10. A sibling formula sets base production11, and a type’s output is its count times that rate12.
| Rule | Where | Evidence |
|---|---|---|
| ×1.15 per one owned | Game.priceIncrease, main.js L7972 | 5 |
getPrice, L8090–L8095 | 13 | |
| Buy 10 / 100 = geometric sum, rounded once | getSumPrice, L8096–L8105 | 14 |
| Purchase loops one at a time, each rounded | buy, L8125–L8152 | 15 |
| Sell pays 25% of the next price | sell, L8156–L8176 | 16 |
Ten Grandmas from zero show 2,031 but cost 2,035, and one cookie short of the label still buys nine15. The sell label is 25% of the last building’s price, so the refund is about 15% more16.
#History of the price rule
The earliest capture, 13 August 2013, sets each new price to 17,18. By v1.035, captured 10 September 2013, the rule was 19. The changelog’s 24 August “big update!” falls between the two20. The 2014 legacy beta lists “price and CpS curves revamped”21.
References
- ^The game's About text credits it as “a javascript game by Orteil and Opti”. T2Cookie Clicker main.js v2.058 · main.js L1410
- ^The changelog dates the launch to 8 August 2013; Orteil says he made the original “in a couple hours, for laughs”. T2Cookie Clicker main.js v2.058 · main.js L2020–2021
- ^The changelog's 28 September 2019 entry announces the official Android version, with iOS to follow. T2Cookie Clicker main.js v2.058 · main.js L1553–1559
- ^ abThe changelog's 1 September 2021 entry announces the Steam release and says web and Steam will get the same updates. T2Cookie Clicker main.js v2.058 · main.js L1505–1507
- ^ abOne global constant,
Game.priceIncrease= 1.15, multiplies a building's price for each one already owned. T4Cookie Clicker main.js v2.058 · main.js L7972Cookie Clicker Wiki, “Building” · Building Pricesprobeprobes/idle-costs/cookie-clicker.mjs - ^Free buildings (Starter kit: 10 Cursors; Starter kitchen: 5 Grandmas) come off the exponent, so the next one costs the base price. T4Cookie Clicker main.js v2.058 · main.js L8266–8275, L3828–3829probe
probes/idle-costs/cookie-clicker.mjs - ^Discounts from upgrades, auras, buffs, and gods multiply the price by constants such as 0.99 or 0.95, lowering the curve without changing its 1.15 slope. T3Cookie Clicker main.js v2.058 · main.js L8792–8814
- ^ abOnly the Cursor keeps its
Game.Objectconstructor price; the formula overwrites the rest (the Farm's 500 becomes 1,100). T4Cookie Clicker main.js v2.058 · main.js L8003–8034, L9104probeprobes/idle-costs/cookie-clicker.mjs - ^Every building after the Cursor gets its base price from one formula on its index : , rounded to two significant figures. T4Cookie Clicker main.js v2.058 · main.js L8024–8031probe
probes/idle-costs/cookie-clicker.mjs - ^Base prices (the first one's price) are Cursor 15, Grandma 100, Farm 1,100, Mine 12,000, Factory 130,000, Bank 1.4 million, and so on up to You at 5.4 × 10²⁶. T4Cookie Clicker main.js v2.058 · main.js L8979, L8024–8031Cookie Clicker Wiki, “Building” · buildings table, “Base Cost” columnprobe
probes/idle-costs/cookie-clicker.mjs - ^Base production before upgrades is 0.1 cookies/s for the Cursor, set in its own production function, and to two significant figures for building : Grandma 1, Farm 8, Mine 47, Factory 260, and so on up to You at 5.1 × 10¹⁴. T4Cookie Clicker main.js v2.058 · main.js L8018–8022, L9104–9109, L9001, L8912–8916probe
probes/idle-costs/cookie-clicker.mjs - ^Each type's production is
amount * storedCps, summed into cookies per second, so before upgrades income grows linearly with count. T3Cookie Clicker main.js v2.058 · main.js L5276–5285 - ^A building's next price is , with discounts applied before rounding. T4Cookie Clicker main.js v2.058 · main.js L8090–8095Cookie Clicker Wiki, “Building” · Building Pricesprobe
probes/idle-costs/cookie-clicker.mjs - ^The shown bulk price (
getSumPrice) is the geometric sum , discounted and rounded up once: 20.30× the next single price for 10, and 7.83 million× for 100. T4Cookie Clicker main.js v2.058 · main.js L8096–8105Pecorella 2016 · “BONUS CONTENT!”Cookie Clicker Wiki, “Building” · Building Pricesprobeprobes/idle-costs/cookie-clicker.mjs - ^ ab
buy()charges each unit's rounded-up price in turn and ignores the shown total: 10 Grandmas from zero cost 2,035, not 2,031, and 2,030 cookies still buy 9. T4Cookie Clicker main.js v2.058 · main.js L8125–8152, L8898–8901probeprobes/idle-costs/cookie-clicker.mjs - ^ abEach sale pays 25% of the next one's price, rounded down, about 15% more than the label: selling 1 of 10 Grandmas shows 88 and pays 101. T4Cookie Clicker main.js v2.058 · main.js L8156–8176, L8106–8123, L1620–1628probe
probes/idle-costs/cookie-clicker.mjs - ^The original (13 August 2013 capture) set each new price to , compounding the rounding: the 51st Cursor cost 2,283, not the unrounded 1,761. T4Cookie Clicker, 13 Aug 2013 capture · index.html L503–512probe
probes/idle-costs/cookie-clicker.mjs - ^The original version's starting prices were Cursor 15, Grandma 100, Factory 500, Mine 2,000, Shipment 7,000, Alchemy lab 50,000, and Portal 1,000,000. T3Cookie Clicker, 13 Aug 2013 capture · index.html L521–582
- ^By v1.035 (captured 10 September 2013), the price was via the same
Game.priceIncrease, still unrounded. T3Cookie Clicker main.js v1.035 · main.js L1836, L1871–1876 - ^The changelog's 24 August 2013 “big update!”, which “revamped the whole game (new graphics, new game mechanics)”, falls between the 1.1 and 1.15 captures. T2Cookie Clicker main.js v2.058 · main.js L2014–2015
- ^ abThe 25 August 2014 “legacy beta, part I” notes say “price and CpS curves revamped”. T2Cookie Clicker main.js v2.058 · main.js L1790–1792
- ^In v1.035,
Game.Objectsets each building'sbasePriceto the literal its definition passes, such as the Farm's 500. T3Cookie Clicker main.js v1.035 · main.js L1841–1851, L2114
Sources
Code
Primary
- Pecorella, Anthony. 2016. “The Math of Idle Games, Part I.” Kongregate Developers Blog. Kongregate. original · archived · licence, all uses