Cookie Clicker
Orteil and Opti's 2013 browser game about baking cookies; each building costs 15% more than the last of its kind.
Facts
- Released
- 2013-08-08 (web)
- Genre
- Clicker, Idle
- Platforms
- web, Windows, Android
- Developer
- Orteil, Opti
- Code
- Game script by Orteil and Opti
Game script, Cookie Clicker, 13 Aug 2013 capture
Game script, Cookie Clicker main.js v1.035 - Evidence
- Verified (11)
Developer (6)
Code (5) - Sources
- 5
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 | main.js L7972 | 5 |
main.js L8090–L8095 | 13 | |
| Buy 10 / 100 = geometric sum, rounded once | main.js L8096–L8105 | 14 |
| Purchase loops one at a time, each rounded | main.js L8125–L8152 | 15 |
| Sell pays 25% of the next price | main.js 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.
Mechanics
| Mechanic | Kind | How |
|---|---|---|
| Exponential cost scaling | Fixed ratio | ×1.15 per building owned, one constant for all buildings |
| Bulk buying | One at a time | buy 1, 10, or 100; the label is the geometric sum rounded once, and the purchase rounds each building |
| Prestige | Currency | the prestige level is the cube root of cookies baked over 10¹², each level a heavenly chip |
Every claim about this game, by concept (26)
References
- ^DeveloperCookie Clicker main.js v2.058
How we know
The game's About text credits it as “a javascript game by Orteil and Opti”.
Cookie Clicker is a javascript game by %1 and %2.
main.js#L1410 · archived copy ↗ - ^DeveloperCookie Clicker main.js v2.058
How we know
The changelog dates the launch to 8 August 2013; Orteil says he made the original “in a couple hours, for laughs”.
made <a href="https://orteil.dashnet.org/experiments/cookie/" target="_blank">the game</a> in a couple hours, for laughs
main.js#L2020-L2021 · archived copy ↗ - ^DeveloperCookie Clicker main.js v2.058
How we know
The changelog's 28 September 2019 entry announces the official Android version, with iOS to follow.
also released the official Android version of Cookie Clicker
main.js#L1553-L1559 · archived copy ↗ - ^DeveloperCookie Clicker main.js v2.058
How we know
The changelog's 1 September 2021 entry announces the Steam release and says web and Steam will get the same updates.
web version and Steam version will receive the same updates from now on
main.js#L1505-L1507 · archived copy ↗ - ^ abVerifiedCookie Clicker main.js v2.058 · Cookie Clicker Wiki, “Building”
How we know
One global constant, 1.15, multiplies a building's price for each one already owned.
Game.priceIncrease=1.15;
main.js#L7972 · archived copy ↗ Building Prices · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker main.js v2.058
How we know
Free buildings (Starter kit: 10 Cursors; Starter kitchen: 5 Grandmas) come off the exponent, so the next one costs the base price.
this.free+=amount;
main.js#L8266-L8275 · archived copy ↗ if (Game.Has('Starter kit')) Game.Objects['Cursor'].getFree(10);
main.js#L3828-L3829 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^CodeCookie Clicker main.js v2.058
How we know
Upgrades, auras, buffs, and gods multiply the price by factors that don't depend on the count, most of them discounts such as 0.99 or 0.95 and one a rise (the Nasty goblins buff, 1.02), so they scale the curve without changing its 1.15 slope.
if (Game.Has('Season savings')) price*=0.99; … if (Game.hasBuff('Nasty goblins')) price*=1.02; … price*=Game.eff('buildingCost');
main.js#L8792-L8814 · archived copy ↗ - ^VerifiedCookie Clicker main.js v2.058
How we know
Only the Cursor keeps its
Game.Objectconstructor price; the formula overwrites the rest (the Farm's 500 becomes 1,100).if (this.n!=0)
main.js#L8003-L8034 · archived copy ↗ main.js#L9104 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker main.js v2.058
How we know
Every building after the Cursor gets its base price from one formula on its index : , rounded to two significant figures, then ×10 at id 16, ×100 at 17, ×1,000 at 18, and ×20,000 at 19.
this.basePrice=(this.n*1+9+(this.n<5?0:Math.pow(this.n-5,1.75)*5))*Math.pow(10,this.n)*(Math.max(1,this.n-14)); … if (this.id>=16) this.basePrice*=10; … if (this.id>=19) this.basePrice*=20;
main.js#L8024-L8031 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker main.js v2.058 · Cookie Clicker Wiki, “Building”
How we know
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²⁶.
new Game.Object('Cursor'…{},15,function(me){
main.js#L8979 · archived copy ↗ this.basePrice=(this.n*1+9+(this.n<5?0:Math.pow(this.n-5,1.75)*5))*Math.pow(10,this.n)*(Math.max(1,this.n-14)); … var digits=Math.pow(10,(Math.ceil(Math.log(Math.ceil(this.basePrice))/Math.LN10)))/100; this.basePrice=Math.round(this.basePrice/digits)*digits; if (this.id>=16) this.basePrice*=10; if (this.id>=17) this.basePrice*=10; if (this.id>=18) this.basePrice*=10; if (this.id>=19) this.basePrice*=20;
main.js#L8024-L8031 · archived copy ↗ buildings table, “Base Cost” column · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker main.js v2.058
How we know
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¹⁴.
this.baseCps=Math.ceil((Math.pow(this.n*1,this.n*0.5+2))*10)/10;//0.45 used to be 0.5
main.js#L8018-L8022 · archived copy ↗ return me.baseCps*mult;
main.js#L9104-L9109 · archived copy ↗ return Game.ComputeCps(0.1,
main.js#L9001 · archived copy ↗ return ((base)*(Math.pow(2,mult))+bonus);
main.js#L8912-L8916 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^CodeCookie Clicker main.js v2.058
How we know
Each type's production is its count times its stored rate per building, summed into cookies per second, so before upgrades income grows linearly with count.
me.storedTotalCps=me.amount*me.storedCps;
main.js#L5276-L5285 · archived copy ↗ - ^VerifiedCookie Clicker main.js v2.058 · Cookie Clicker Wiki, “Building”
How we know
A building's next price is , with discounts applied before rounding.
var price=this.basePrice*Math.pow(Game.priceIncrease,Math.max(0,this.amount-this.free));
main.js#L8090-L8095 · archived copy ↗ \text {Price} = \text {Base cost} \times 1.15 ^ {M-F}
Building Prices · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker main.js v2.058 · Pecorella 2016 · Cookie Clicker Wiki, “Building”
How we know
The shown bulk price is the geometric sum , discounted and rounded up once: 20.30× the next single price for 10, and 7.83 million× for 100.
price+=this.basePrice*Math.pow(Game.priceIncrease,Math.max(0,i-this.free));
main.js#L8096-L8105 · archived copy ↗ $cost = b * \frac{r^k(r^n-1)}{r-1}$
“BONUS CONTENT!” · archived copy ↗ \text {Price of Buy 10} = \text {Price} \times 20.303718238
Building Prices · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^ abVerifiedCookie Clicker main.js v2.058
How we know
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.if (Game.cookies>=price)
main.js#L8125-L8152 · archived copy ↗ Game.ObjectsById[what].buy();
main.js#L8898-L8901 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^ abVerifiedCookie Clicker main.js v2.058
How we know
Each 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.
price=Math.floor(price*giveBack);
main.js#L8156-L8176 · archived copy ↗ var giveBack=0.25;
main.js#L8106-L8123 · archived copy ↗ buildings now sell back for 25% of their current price (down from 50%)
main.js#L1620-L1628 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^VerifiedCookie Clicker, 13 Aug 2013 capture
How we know
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.
this.price=Math.ceil(this.price*1.1);
index.html#L503-L512 · archived copy ↗ Measured by a script. It fails if the result disagrees with the claim.
- ^CodeCookie Clicker, 13 Aug 2013 capture
How we know
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.
new Buyable('Cursor','Autoclicks every 5 seconds.','cursoricon',15,function(){Cursors++;});
index.html#L521-L582 · archived copy ↗ - ^CodeCookie Clicker main.js v1.035
How we know
By v1.035 (captured 10 September 2013), the price was via the same global constant, still unrounded.
Game.priceIncrease=1.15;
main.js#L1836 · archived copy ↗ var price=this.basePrice*Math.pow(Game.priceIncrease,this.amount);
main.js#L1871-L1876 · archived copy ↗ - ^DeveloperCookie Clicker main.js v2.058
How we know
The changelog's 24 August 2013 “big update!”, which “revamped the whole game (new graphics, new game mechanics)”, falls between two Wayback captures, the original version of 13 August 2013 and v1.035 of 10 September 2013.
24/08/2013 - big update!
main.js#L2014 · archived copy ↗ revamped the whole game (new graphics, new game mechanics)
main.js#L2015 · archived copy ↗ - ^ abDeveloperCookie Clicker main.js v2.058
How we know
The 25 August 2014 “legacy beta, part I” notes say “price and CpS curves revamped”.
price and CpS curves revamped
main.js#L1790-L1792 · archived copy ↗ - ^CodeCookie Clicker main.js v1.035
How we know
In v1.035, the building constructor sets each building's base price to the literal its definition passes, such as the Farm's 500.
this.basePrice=price;
main.js#L1841-L1851 · archived copy ↗ main.js#L2114 · archived copy ↗
Sources
Code
Primary
- Pecorella, Anthony. 2016. “The Math of Idle Games, Part I.” Kongregate Developers Blog. Kongregate. original · archived · licence, all uses