Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Secret cookie wizard
- // @namespace http://cs.wisc.edu/~markus
- // @description Tells you what option you are supposed to pick, taking into account time to achieve the option. This has been updated for the 2014-04-09 update.
- // @version 0.10.1
- // @include http://orteil.dashnet.org/cookieclicker/
- // ==/UserScript==
- function Secret_cookie_wizard()
- {
- function real_game()
- {
- try {
- return Game;
- } catch (e) {}
- return null;
- }
- window.real_game = real_game;
- (function () {
- var BASE_COSTS = [15, 100, 500, 3000, 10000, 40000,
- 200000, 1666666, 123456789, 3999999999, 75000000000];
- var BASE_RATES = [.1, .5, 4, 10, 40, 100, 400,
- 6666, 98765, 999999, 10000000];
- var TIER1 = 10;
- var TIER2 = 100;
- var TIER3 = 1000;
- var TIER4 = 50000;
- var TIER5 = 1000000;
- var TIER6 = 8000000000;
- var UPGRADE_COST = {
- // 1
- //'elder pledge': 1,
- // 2
- 'heavenly chip secret': 11,
- 'a festive hat': 25, // ignored
- // 3
- 'reinforced index finger': 100,
- 'carpal tunnel prevention cream': 400,
- // 4
- 'forwards from grandma': BASE_COSTS[1] * TIER1, // 1000
- 'heavenly cookie stand': 1111,
- 'a lump of coal': 2525,
- 'an itchy sweater': 2525,
- 'ho ho ho-flavored frosting': 2525, // ignored
- 'improved jolliness': 2525,
- 'increased merriness': 2525,
- 'naughty list': 2525,
- 'reindeer baking grounds': 2525, // ignored
- 'santa\'s bottomless bag': 2525, // ignored
- 'santa\'s dominion': 2525,
- 'santa\'s helpers': 2525,
- 'santa\'s legacy': 2525,
- 'santa\'s milk and cookies': 2525,
- 'season savings': 2525,
- 'toy workshop': 2525,
- 'weighted sleighs': 2525, // ignored
- 'cheap hoes': BASE_COSTS[2] * TIER1, // 5000
- // 5
- 'ambidextrous': 10000,
- 'steel-plated rolling pins': BASE_COSTS[1] * TIER2, // 10000
- 'sturdier conveyor belts': BASE_COSTS[3] * TIER1, // 30000
- 'farmer grandmas': BASE_COSTS[2] * TIER2, // 50000
- 'fertilizer': BASE_COSTS[2] * TIER2, // 50000
- 'plastic mouse': 50000,
- // 6
- 'lubricated dentures': BASE_COSTS[1] * TIER3, // 100000
- 'sugar gas': BASE_COSTS[4] * TIER1, // 100000
- 'heavenly bakery': 111111,
- 'worker grandmas': BASE_COSTS[3] * TIER2, // 300000
- 'child labor': BASE_COSTS[3] * TIER2, // 300000
- 'vanilla nebulae': BASE_COSTS[5] * TIER1, // 400000
- 'cookie trees': BASE_COSTS[2] * TIER3, // 500000
- 'thousand fingers': 500000,
- // 7
- 'miner grandmas': BASE_COSTS[4] * TIER2, // 1000000
- 'megadrill': BASE_COSTS[4] * TIER2, // 1000000
- 'antimony': BASE_COSTS[6] * TIER1, // 2000000
- 'sweatshop': BASE_COSTS[3] * TIER3, // 3000000
- 'cosmic grandmas': BASE_COSTS[5] * TIER2, // 4000000
- 'wormholes': BASE_COSTS[5] * TIER2, // 4000000
- 'iron mouse': 5000000,
- 'prune juice': BASE_COSTS[1] * TIER4, // 5000000
- 'kitten helpers': 9000000,
- // 8
- 'ultradrill': BASE_COSTS[4] * TIER3, // 10000000
- 'ancient tablet': BASE_COSTS[7] * TIER1, // 16666660
- 'essence of dough': BASE_COSTS[6] * TIER2, // 20000000
- 'transmuted grandmas': BASE_COSTS[6] * TIER2, // 20000000
- 'genetically-modified cookies': BASE_COSTS[2] * TIER4, // 25000000
- 'heavenly confectionery': 11111111,
- 'frequent flyer': BASE_COSTS[5] * TIER3, // 40000000
- 'million fingers': 50000000,
- 'oatmeal raisin cookies': 99999999,
- 'peanut butter cookies': 99999999,
- 'plain cookies': 99999999,
- 'sugar cookies': 99999999,
- // 9
- 'double-thick glasses': BASE_COSTS[1] * TIER5, // 100000000
- 'radium reactors': BASE_COSTS[3] * TIER4, // 150000000
- 'altered grandmas': BASE_COSTS[7] * TIER2, // 166666600
- 'insane oatling workers': BASE_COSTS[7] * TIER2, // 166666600
- 'true chocolate': BASE_COSTS[6] * TIER3, // 400000000
- 'billion fingers': 500000000,
- 'gingerbread scarecrows': BASE_COSTS[2] * TIER5, // 500000000
- 'titanium mouse': 500000000,
- 'ultimadrill': BASE_COSTS[4] * TIER4, // 500000000
- 'lucky day': 777777777, // ignored
- 'coconut cookies': 999999999,
- 'macadamia nut cookies': 999999999,
- 'white chocolate cookies': 999999999,
- // 10
- 'heavenly key': 1111111111,
- 'flux capacitors': 1234567890,
- 'soul bond': BASE_COSTS[7] * TIER3, // 1666666000
- 'warp drive': BASE_COSTS[5] * TIER4, // 2000000000
- 'recombobulators': BASE_COSTS[3] * TIER5, // 3000000000
- 'trillion fingers': 5000000000,
- //'revoke elder covenant': 6666666666,
- 'kitten workers': 9000000000,
- 'time paradox resolver': 9876543210,
- // 11
- 'ambrosia': BASE_COSTS[6] * TIER4, // 10000000000
- 'h-bomb mining': BASE_COSTS[4] * TIER5, // 10000000000
- 'specialized chocolate chips': 10000000000,
- 'grandmas\' grandmas': BASE_COSTS[8] * TIER2, // 12345678900
- 'designer cocoa beans': 20000000000,
- 'sugar bosons': BASE_COSTS[9] * TIER1, // 39999999990
- 'chocolate monoliths': BASE_COSTS[5] * TIER5, // 40000000000
- 'ritual rolling pins': 40000000000,
- 'adamantium mouse': 50000000000,
- 'quadrillion fingers': 50000000000,
- 'serendipity': 77777777777, // ignored
- 'underworld ovens': 80000000000,
- 'sanity dance': BASE_COSTS[7] * TIER4, // 83333300000
- 'quantum conundrum': 98765456789,
- 'all-chocolate cookies': 99999999999,
- 'double-chip cookies': 99999999999,
- 'white chocolate macadamia nut cookies':
- 99999999999,
- // 12
- 'bingo center': 100000000000,
- 'persistent memory': 100000000000,
- 'one mind': 160000000000,
- 'aqua crustulae': BASE_COSTS[6] * TIER5, // 200000000000
- 'christmas tree biscuits': 252525252525,
- 'holly biscuits': 252525252525,
- 'snowflake biscuits': 252525252525,
- 'snowman biscuits': 252525252525,
- 'mistletoe biscuits': 252525252525,
- 'candy cane biscuits': 252525252525,
- 'bell biscuits': 252525252525,
- 'present biscuits': 252525252525,
- 'exotic nuts': 320000000000,
- 'antigrandmas': BASE_COSTS[9] * TIER2, // 399999999900
- 'string theory': BASE_COSTS[9] * TIER2, // 399999999900
- 'bat cookies': 444444444444,
- 'eyeball cookies': 444444444444,
- 'ghost cookies': 444444444444,
- 'pumpkin cookies': 444444444444,
- 'skull cookies': 444444444444,
- 'slime cookies': 444444444444,
- 'spider cookies': 444444444444,
- 'gem polish': BASE_COSTS[10] * TIER1, // 500000000000
- 'communal brainsweep': 640000000000,
- 'aging agents': BASE_COSTS[1] * TIER6, // 800000000000
- 'dark chocolate-coated cookies': 999999999999,
- 'white chocolate-coated cookies': 999999999999,
- // 13
- 'causality enforcer': 1234567890000,
- 'arcane sugar': 1280000000000,
- 'brane transplant': BASE_COSTS[7] * TIER5, // 1666666000000
- 'elder pact': 2560000000000,
- 'sacrificial rolling pins': 2888888888888,
- 'season switcher': 3333333333333, // ignored
- 'large macaron collider': BASE_COSTS[9] * TIER3, // 3999999999000
- 'pulsar sprinklers': BASE_COSTS[2] * TIER6, // 4000000000000
- '9th color': BASE_COSTS[10] * TIER2, // 5000000000000
- 'rainbow grandmas': BASE_COSTS[10] * TIER2, // 5000000000000
- 'unobtainium mouse': 5000000000000,
- 'kitten engineers': 9000000000000,
- 'eclipse cookies': 9999999999999,
- 'zebra cookies': 9999999999999,
- // 14
- 'deep-bake process': BASE_COSTS[3] * TIER6, // 24000000000000
- 'chocolate light': BASE_COSTS[10] * TIER3, // 50000000000000
- 'quintillion fingers': 50000000000000,
- 'elder covenant': 66666666666666,
- 'get lucky': 77777777777777,
- 'coreforge': BASE_COSTS[4] * TIER6, // 80000000000000
- 'british tea biscuits': 99999999999999,
- 'chocolate british tea biscuits': 99999999999999,
- 'empire biscuits': 99999999999999,
- 'macaroons': 99999999999999,
- 'round british tea biscuits': 99999999999999,
- 'round british tea biscuits with heart motif':
- 99999999999999,
- 'round chocolate british tea biscuits': 99999999999999,
- 'round chocolate british tea biscuits with heart motif':
- 99999999999999,
- 'snickerdoodles': 99999999999999,
- 'stroopwafels': 99999999999999,
- // 15
- 'yestermorrow comparators': BASE_COSTS[8] * TIER5, // 123456789000000
- 'big bang bake': BASE_COSTS[9] * TIER4, // 199999999950000
- 'madeleines': 199999999999999,
- 'palets': 199999999999999,
- 'palmiers': 199999999999999,
- 'sables': 199999999999999,
- 'generation ship': BASE_COSTS[5] * TIER6, // 320000000000000
- 'eludium mouse': 500000000000000,
- 'sextillion fingers': 500000000000000,
- 'kitten overseers': 900000000000000,
- 'caramoas': 999999999999999,
- 'fig gluttons': 999999999999999,
- 'grease\'s cups': 999999999999999,
- 'jaffa cakes': 999999999999999,
- 'loreols': 999999999999999,
- 'sagalongs': 999999999999999,
- 'shortfoils': 999999999999999,
- 'win mints': 999999999999999,
- // 16
- 'origin crucible': BASE_COSTS[6] * TIER6, // 1600000000000000
- 'grainbow': BASE_COSTS[10] * TIER4, // 2500000000000000
- 'reverse cyclotrons': BASE_COSTS[9] * TIER5, // 3999999999000000
- 'septillion fingers': 5000000000000000,
- 'ardent heart biscuits': 9999999999999999,
- 'eternal heart biscuits': 9999999999999999,
- 'gingerbread men': 9999999999999999,
- 'gingerbread trees': 9999999999999999,
- 'golden heart biscuits': 9999999999999999,
- 'pure heart biscuits': 9999999999999999,
- 'sour heart biscuits': 9999999999999999,
- 'weeping heart biscuits': 9999999999999999,
- // 17
- 'deity-sized portals': BASE_COSTS[7] * TIER6, // 13333328000000000
- 'octillion fingers': 50000000000000000,
- 'wishalloy mouse': 50000000000000000,
- 'pure cosmic light': BASE_COSTS[10] * TIER5, // 50000000000000000
- // 18
- 'far future enactment': BASE_COSTS[8] * TIER6, // 987654312000000000
- 'chocolate macarons': 999999999999999999,
- 'hazelnut macarons': 999999999999999999,
- 'lemon macarons': 999999999999999999,
- 'pistachio macarons': 999999999999999999,
- 'rose macarons': 999999999999999999,
- 'violet macarons': 999999999999999999,
- // 20
- 'nanocosmics': BASE_COSTS[9] * TIER6, // 31999999992000000000
- // 21
- 'glow-in-the-dark': BASE_COSTS[10] * TIER6, // 400000000000000000000
- 'kitten managers': 900000000000000000000,
- };
- function compute_rate(base, mult, bonus)
- {
- if (!bonus) bonus = 0;
- return base * Math.pow(2, mult) + bonus;
- }
- function make_accessor(key)
- {
- return function(val)
- {
- if (arguments.length)
- return this[key] = val;
- return this[key];
- }
- }
- function add_accessor(klass, name)
- {
- klass.prototype[name] = make_accessor('_' + name);
- }
- function add_accessors(klass /* , ...*/)
- {
- for (var i = 1; i < arguments.length; i++)
- add_accessor(klass, arguments[i]);
- }
- function Game(options)
- {
- this.constructor = Game;
- var clicks = 0;
- var cookie_total = 0;
- var cookies = 0;
- var golden_cookies = 0;
- var heavenly_chips = 0;
- var milk = 0;
- var santa_level = 0;
- if (options) {
- if (options.clicks != null)
- clicks = options.clicks;
- if (options.cookie_total != null)
- cookie_total = options.cookie_total;
- if (options.cookies != null)
- cookies = options.cookies;
- if (options.golden_cookies != null)
- golden_cookies = options.golden_cookies;
- if (options.heavenly_chips != null)
- heavenly_chips = options.heavenly_chips;
- if (options.milk != null)
- milk = options.milk;
- if (options.available_upgrades != null)
- this.available_upgrades(options.available_upgrades);
- if (options.counts != null)
- this.counts(options.counts);
- if (options.upgrades != null)
- this.upgrades(options.upgrades);
- if (options.santa_level != null)
- this.santa_level = options.santa_level;
- }
- if (this._available_upgrades === undefined)
- this._available_upgrades = {};
- if (this._counts === undefined) {
- var counts = this._counts = new Array(BASE_COSTS.length);
- for (var i = 0; i < counts.length; i++)
- counts[i] = 0;
- }
- if (this._upgrades === undefined)
- this._upgrades = {};
- this._clicks = clicks;
- this._cookie_total = cookie_total;
- this._cookies = cookies;
- this._golden_cookies = golden_cookies;
- this._heavenly_chips = heavenly_chips;
- this._milk = milk;
- this._santa_level = santa_level;
- }
- Game.prototype = {};
- add_accessors(Game, 'clicks', 'cookie_total', 'cookies',
- 'golden_cookies', 'heavenly_chips', 'milk', 'santa_level');
- Game.prototype.available_upgrades = function(available_upgrades)
- {
- var dst, returned, src;
- if (arguments.length) {
- src = available_upgrades;
- dst = this._available_upgrades = {};
- returned = src;
- } else {
- src = this._available_upgrades;
- dst = {};
- returned = dst;
- }
- for (var key in src) dst[key] = null;
- return returned;
- }
- Game.prototype.has_available_upgrade = function(name)
- {
- return name in this._available_upgrades;
- }
- Game.prototype.add_available_upgrade = function(name)
- {
- var available = this._available_upgrades;
- //if (name in available)
- // throw 'upgrade `'+name+'\' already available';
- available[name] = null;
- }
- Game.prototype.upgrades = function(upgrades)
- {
- var src, dst, returned;
- if (arguments.length) {
- src = upgrades;
- dst = this._upgrades = {};
- returned = src;
- } else {
- src = this._upgrades;
- dst = {};
- returned = dst;
- }
- for (var key in src) dst[key] = null;
- return returned;
- }
- Game.prototype.has_upgrade = function(name)
- {
- return name in this._upgrades;
- }
- Game.prototype.count = function(i, count)
- {
- if (arguments.length > 1) {
- this._counts[i] = count;
- return count;
- }
- return this._counts[i];
- }
- Game.prototype.counts = function(counts)
- {
- if (arguments.length) {
- this._counts = counts.slice(0);
- return counts;
- }
- return this._counts.slice(0);
- }
- Game.prototype.costs = function()
- {
- var counts = this._counts;
- var upgrades = this._upgrades;
- var result = [];
- var mult = 1;
- if ('season savings' in upgrades) mult *= .99;
- if ('santa\'s dominion' in upgrades) mult *= .99;
- for (var i = 0; i < BASE_COSTS.length; i++)
- result.push(Math.ceil(
- Math.pow(1.15, counts[i]) * BASE_COSTS[i] * mult));
- return result;
- }
- Game.prototype.rates = function()
- {
- var self = this;
- var types = ('cursor grandma farm factory mine shipment alchemy_lab ' +
- 'portal time_machine antimatter_condenser prism').split(' ');
- return types.map(function (x) {
- return self['rate_' + x]();
- });
- }
- Game.prototype.building_count = function()
- {
- var counts = this._counts;
- var sum = 0;
- for (var i = 1; i < counts.length; i++)
- sum += counts[i];
- return sum;
- }
- Game.prototype.building_cost = function(i)
- {
- return Math.ceil(Math.pow(1.15, this._counts[i]) * BASE_COSTS[i]);
- }
- Game.prototype.purchase = function(i)
- {
- this._counts[i]++;
- }
- Game.prototype.purchase_undo = function(i)
- {
- //if (!this._counts[i])
- // throw 'building '+i+' count is 0';
- this._counts[i]--;
- }
- Game.prototype.upgrade = function(name)
- {
- //if (name in this._upgrades)
- // throw 'upgrade `'+name+'\' already present';
- //if (!(name in this._available_upgrades))
- // throw 'upgrade `'+name+'\' not available';
- this._upgrades[name] = null;
- delete this._available_upgrades[name];
- }
- Game.prototype.upgrade_undo = function(name)
- {
- //if (!(name in this._upgrades))
- // throw 'upgrade `'+name+'\' was not present';
- //if (name in this._available_upgrades)
- // throw 'upgrade `'+name+'\' is available?';
- delete this._upgrades[name];
- this._available_upgrades[name] = null;
- }
- Game.prototype.total_cps = function()
- {
- var cps;
- var heavenly_mult;
- var mult;
- var rates;
- var i;
- var counts = this._counts;
- var milk = this._milk;
- var real = this._real;
- var upgrades = this._upgrades;
- mult = 1;
- mult += .05 * this._count_upgrades([
- 'coconut cookies',
- 'macadamia nut cookies',
- 'oatmeal raisin cookies',
- 'peanut butter cookies',
- 'plain cookies',
- 'sugar cookies',
- 'white chocolate cookies',
- ]);
- mult += .1 * this._count_upgrades([
- 'all-chocolate cookies',
- 'double-chip cookies',
- 'white chocolate macadamia nut cookies',
- ]);
- mult += .15 * this._count_upgrades([
- 'british tea biscuits',
- 'chocolate british tea biscuits',
- 'dark chocolate-coated cookies',
- 'eclipse cookies',
- 'empire biscuits',
- 'macaroons',
- 'round british tea biscuits',
- 'round british tea biscuits with heart motif',
- 'round chocolate british tea biscuits',
- 'round chocolate british tea biscuits with heart motif',
- 'snickerdoodles',
- 'stroopwafels',
- 'white chocolate-coated cookies',
- 'zebra cookies',
- ]);
- mult += .2 * this._count_upgrades([
- 'bat cookies',
- 'bell biscuits',
- 'christmas tree biscuits',
- 'candy cane biscuits',
- 'eyeball cookies',
- 'ghost cookies',
- 'holly biscuits',
- 'madeleines',
- 'mistletoe biscuits',
- 'palets',
- 'palmiers',
- 'present biscuits',
- 'pumpkin cookies',
- 'sables',
- 'skull cookies',
- 'slime cookies',
- 'snowflake biscuits',
- 'snowman biscuits',
- 'spider cookies',
- ]);
- mult += .25 * this._count_upgrades([
- 'ardent heart biscuits',
- 'caramoas',
- 'eternal heart biscuits',
- 'fig gluttons',
- 'gingerbread men',
- 'gingerbread trees',
- 'golden heart biscuits',
- 'grease\'s cups',
- 'jaffa cakes',
- 'loreols',
- 'pure heart biscuits',
- 'sagalongs',
- 'shortfoils',
- 'sour heart biscuits',
- 'weeping heart biscuits',
- 'win mints',
- ]);
- mult += .3 * this._count_upgrades([
- 'rose macarons',
- 'lemon macarons',
- 'chocolate macarons',
- 'pistachio macarons',
- 'hazelnut macarons',
- 'violet macarons',
- ]);
- if ('a lump of coal' in upgrades) mult += .01;
- if ('an itchy sweater' in upgrades) mult += .01;
- if ('specialized chocolate chips' in upgrades) mult += .01;
- if ('designer cocoa beans' in upgrades) mult += .02;
- if ('underworld ovens' in upgrades) mult += .03;
- if ('exotic nuts' in upgrades) mult += .04;
- if ('arcane sugar' in upgrades) mult += .05;
- if ('improved jolliness' in upgrades) mult += .15;
- if ('increased merriness' in upgrades) mult += .15;
- if ('santa\'s dominion' in upgrades) mult += .50;
- if ('santa\'s legacy' in upgrades)
- mult += (this._santa_level + 1) * .1;
- heavenly_mult = 0;
- if ('heavenly chip secret' in upgrades) heavenly_mult += .05;
- if ('heavenly cookie stand' in upgrades) heavenly_mult += .2;
- if ('heavenly bakery' in upgrades) heavenly_mult += .25;
- if ('heavenly confectionery' in upgrades) heavenly_mult += .25;
- if ('heavenly key' in upgrades) heavenly_mult += .25;
- mult += .02 * this._heavenly_chips * heavenly_mult;
- cps = 0;
- rates = this.rates();
- for (i = 0; i < counts.length; i++)
- cps += counts[i] * rates[i];
- if ('santa\'s milk and cookies' in upgrades) milk *= 1.05;
- if ('kitten helpers' in upgrades) mult *= 1 + milk * .05;
- if ('kitten workers' in upgrades) mult *= 1 + milk * .1;
- if ('kitten engineers' in upgrades) mult *= 1 + milk * .2;
- if ('kitten overseers' in upgrades) mult *= 1 + milk * .2;
- if ('kitten managers' in upgrades) mult *= 1 + milk * .2;
- if ('elder covenant' in upgrades) mult *= .95;
- return cps * mult;
- }
- Game.prototype.rate_mouse = function(cps)
- {
- var base = 1;
- var bonus;
- var building_mult;
- var cps_mult;
- var doubles;
- var upgrades = this._upgrades;
- if ('reinforced index finger' in upgrades) base++;
- doubles = 0;
- if ('carpal tunnel prevention cream' in upgrades) doubles++;
- if ('ambidextrous' in upgrades) doubles++;
- building_mult = 0;
- if ('thousand fingers' in upgrades) building_mult += .1;
- if ('million fingers' in upgrades) building_mult += .5;
- if ('billion fingers' in upgrades) building_mult += 2;
- if ('trillion fingers' in upgrades) building_mult += 10;
- if ('quadrillion fingers' in upgrades) building_mult += 20;
- if ('quintillion fingers' in upgrades) building_mult += 100;
- if ('sextillion fingers' in upgrades) building_mult += 200;
- bonus = building_mult * this.building_count();
- cps_mult = .01 * this._count_upgrades([
- 'plastic mouse',
- 'iron mouse',
- 'titanium mouse',
- 'adamantium mouse',
- 'unobtainium mouse',
- 'eludium mouse',
- 'wishalloy mouse',
- ]);
- var mult = ('santa\'s helpers' in upgrades) ? 1.1 : 1;
- bonus += cps_mult * cps;
- return compute_rate(base, doubles, bonus) * mult;
- }
- Game.prototype.rate_cursor = function()
- {
- var base = BASE_RATES[0];
- var bonus;
- var doubles = 0;
- var building_mult = 0;
- var upgrades = this._upgrades;
- if ('reinforced index finger' in upgrades) base += .1;
- if ('carpal tunnel prevention cream' in upgrades) doubles++;
- if ('ambidextrous' in upgrades) doubles++;
- if ('thousand fingers' in upgrades) building_mult += .1;
- if ('million fingers' in upgrades) building_mult += .5;
- if ('billion fingers' in upgrades) building_mult += 2;
- if ('trillion fingers' in upgrades) building_mult += 10;
- if ('quadrillion fingers' in upgrades) building_mult += 20;
- if ('quintillion fingers' in upgrades) building_mult += 100;
- if ('sextillion fingers' in upgrades) building_mult += 200;
- if ('septillion fingers' in upgrades) building_mult += 400;
- if ('octillion fingers' in upgrades) building_mult += 800;
- bonus = building_mult * this.building_count();
- return compute_rate(base, doubles, bonus);
- }
- Game.prototype.rate_grandma = function()
- {
- var base = BASE_RATES[1];
- var doubles = 0;
- var counts = this._counts;
- var upgrades = this._upgrades;
- if ('forwards from grandma' in upgrades) base += .3;
- if ('one mind' in upgrades) base += counts[1] * .02;
- if ('communal brainsweep' in upgrades) base += counts[1] * .02;
- if ('elder pact' in upgrades) base += counts[7] * .05;
- doubles += this._count_upgrades([
- 'steel-plated rolling pins',
- 'lubricated dentures',
- 'prune juice',
- 'double-thick glasses',
- 'farmer grandmas',
- 'worker grandmas',
- 'miner grandmas',
- 'cosmic grandmas',
- 'transmuted grandmas',
- 'altered grandmas',
- 'grandmas\' grandmas',
- 'antigrandmas',
- 'bingo center', 'bingo center', // count twice
- 'ritual rolling pins',
- 'naughty list',
- 'rainbow grandmas',
- 'aging agents',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_farm = function()
- {
- var base = BASE_RATES[2];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('cheap hoes' in upgrades) base++;
- doubles += this._count_upgrades([
- 'fertilizer',
- 'cookie trees',
- 'genetically-modified cookies',
- 'gingerbread scarecrows',
- 'pulsar sprinklers',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_factory = function()
- {
- var base = BASE_RATES[3];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('sturdier conveyor belts' in upgrades) base += 4;
- doubles += this._count_upgrades([
- 'child labor',
- 'sweatshop',
- 'radium reactors',
- 'recombobulators',
- 'deep-bake process',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_mine = function()
- {
- var base = BASE_RATES[4];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('sugar gas' in upgrades) base += 10;
- doubles += this._count_upgrades([
- 'megadrill',
- 'ultradrill',
- 'ultimadrill',
- 'h-bomb mining',
- 'coreforge',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_shipment = function()
- {
- var base = BASE_RATES[5];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('vanilla nebulae' in upgrades) base += 30;
- doubles += this._count_upgrades([
- 'wormholes',
- 'frequent flyer',
- 'warp drive',
- 'chocolate monoliths',
- 'generation ship',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_alchemy_lab = function()
- {
- var base = BASE_RATES[6];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('antimony' in upgrades) base += 100;
- doubles += this._count_upgrades([
- 'essence of dough',
- 'true chocolate',
- 'ambrosia',
- 'aqua crustulae',
- 'origin crucible',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_portal = function()
- {
- var base = BASE_RATES[7];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('ancient tablet' in upgrades) base += 1666;
- doubles += this._count_upgrades([
- 'insane oatling workers',
- 'soul bond',
- 'sanity dance',
- 'brane transplant',
- 'deity-sized portals',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_time_machine = function()
- {
- var base = BASE_RATES[8];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('flux capacitors' in upgrades) base += 9876;
- doubles += this._count_upgrades([
- 'time paradox resolver',
- 'quantum conundrum',
- 'causality enforcer',
- 'yestermorrow comparators',
- 'far future enactment',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_antimatter_condenser = function()
- {
- var base = BASE_RATES[9];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('sugar bosons' in upgrades) base += 99999;
- doubles += this._count_upgrades([
- 'string theory',
- 'large macaron collider',
- 'big bang bake',
- 'reverse cyclotrons',
- 'nanocosmics',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype.rate_prism = function()
- {
- var base = BASE_RATES[10];
- var doubles = 0;
- var upgrades = this._upgrades;
- if ('gem polish' in upgrades) base += 1000000;
- doubles += this._count_upgrades([
- '9th color',
- 'chocolate light',
- 'grainbow',
- 'pure cosmic light',
- 'glow-in-the-dark',
- ]);
- return compute_rate(base, doubles);
- }
- Game.prototype._count_upgrades = function(names)
- {
- var sum = 0;
- var upgrades = this._upgrades;
- for (var i = 0; i < names.length; i++)
- if (names[i] in upgrades)
- sum++;
- return sum;
- }
- function time_for_one(cookies, cps, a)
- {
- var need_a = a[2] - cookies;
- return need_a<0 ? 0 : need_a/cps;
- }
- function time_for_both(cookies, cps, a, b)
- {
- var need_a;
- var need_b;
- var time;
- // I'm not sure if I should take into account how many cookies are
- // currently being had
- cookies = 0;
- need_a = a[2] - cookies;
- if (need_a < 0) {
- cookies = -need_a;
- need_a = 0;
- time = 0;
- } else {
- cookies = 0;
- time = need_a / cps;
- }
- need_b = b[2] - cookies;
- if (need_b >= 0)
- time += need_b / a[3];
- return time;
- }
- function compare_time(cookies, cps, lhs, rhs)
- {
- var time_lhs;
- var time_rhs;
- time_lhs = time_for_both(cookies, cps, lhs, rhs);
- time_rhs = time_for_both(cookies, cps, rhs, lhs);
- return time_lhs - time_rhs;
- }
- function sorted_suggestions(cookies, cps, suggestions)
- {
- function cmp(a, b) {
- return compare_time(cookies, cps, a, b);
- }
- var copy = suggestions.slice(0);
- copy.sort(cmp);
- return copy;
- }
- function verify_transitive(cookies, cps, options)
- {
- var left, right;
- var i, j;
- var transitive = true;
- for (i = 0; i < options.length - 1; i++) {
- left = options[i];
- for (j = i + 1; j < options.length; j++) {
- right = options[j];
- if (compare_time(cookies, cps, left, right) > 0) {
- transitive = false;
- break;
- }
- }
- if (!transitive) break;
- }
- var optimal = true;
- left = options[0];
- for (i = 1; i < options.length; i++) {
- if (compare_time(cookies, cps, left, right) > 0) {
- optimal = false;
- break;
- }
- }
- if (transitive && optimal)
- console.info('transitive', transitive, 'optimal', optimal);
- else
- console.error('transitive', transitive, 'optimal', optimal);
- }
- function sets_equal(lhs, rhs)
- {
- var sz_lhs = 0;
- var sz_rhs = 0;
- for (var key in lhs) {
- if (!(key in rhs)) return false;
- sz_lhs++;
- }
- for (var key in rhs)
- sz_rhs++;
- return sz_lhs == sz_rhs;
- }
- function Simulation(options)
- {
- this.constructor = Simulation;
- var real = null;
- var game = null;
- if (options) {
- if (options.game != null)
- game = options.game;
- if (options.real != null)
- real = options.real;
- }
- if (game == null)
- game = new Game;
- if (real == null)
- real = real_game();
- this._game = game;
- this._real = real;
- this._last_cps = null;
- }
- Simulation.prototype = {};
- Simulation.prototype.game = function()
- {
- return this._game;
- }
- Simulation.prototype.refresh_from_real = function()
- {
- var i;
- var important = false;
- var key;
- var game = this._game;
- var real = this._real;
- var real_available = {};
- for (i = 0; i < real.UpgradesInStore.length; i++) {
- // TODO it wouldn't hurt if this removed
- var name;
- var upgrade = real.UpgradesInStore[i];
- name = upgrade.name.replace(/\/.*/, '').
- replace('é', 'e').toLowerCase();
- real_available[name] = null;
- }
- if (!sets_equal(game.available_upgrades(), real_available)) {
- important = true;
- game.available_upgrades(real_available);
- }
- game.clicks(real.cookieClicks);
- game.cookie_total(real.cookiesEarned);
- game.cookies(real.cookies);
- for (key in real.Objects) {
- var building = real.Objects[key];
- var id = building.id;
- var amt = building.amount;
- if (game.count(id) != amt) {
- game.count(id, amt);
- important = true;
- }
- }
- game.golden_cookies(real.goldenClicks);
- if (game.heavenly_chips() !=
- game.heavenly_chips(real.prestige['Heavenly chips']))
- // not likely :)
- important = true;
- if (game.milk() != game.milk(real.AchievementsOwned * .04))
- important = true;
- if (game.santa_level() != real.santaLevel) {
- game.santa_level(real.santaLevel);
- important = true;
- }
- var real_upgrades = {};
- for (key in real.Upgrades) {
- var name;
- var upgrade = real.Upgrades[key];
- if (upgrade.constructor != real.Upgrade) continue;
- if (upgrade.bought) {
- name = upgrade.name.replace(/\/.*/, '').
- replace('é', 'e').toLowerCase();
- real_upgrades[name] = null;
- }
- }
- if (!sets_equal(game.upgrades(), real_upgrades)) {
- important = true;
- game.upgrades(real_upgrades);
- }
- return important;
- }
- Simulation.prototype.make_suggestions = function()
- {
- var cps;
- var mouse_cps;
- var options;
- var game = this._game;
- var upgrades = game.upgrades();
- var available = game.available_upgrades();
- cps = game.total_cps();
- if (cps != this._last_cps) {
- console.info('CPS is now', cps * Math.pow(10, -12), 'trillion');
- this._last_cps = cps;
- }
- mouse_cps = game.rate_mouse(cps) * 5;
- cps += mouse_cps;
- options = [];
- for (var i = 0; i < BASE_COSTS.length; i++) {
- var cost = game.building_cost(i);
- var new_cps;
- var new_mouse_cps;
- game.purchase(i);
- new_cps = game.total_cps();
- new_mouse_cps = game.rate_mouse(new_cps) * 5;
- new_cps += new_mouse_cps;
- game.purchase_undo(i);
- options.push(['b', i, cost, new_cps]);
- }
- var upgrade_mult = 1;
- if ('toy workshop' in upgrades) upgrade_mult *= .95;
- if ('santa\'s dominion' in upgrades) upgrade_mult *= .98;
- for (var upgrade in available) {
- var cost = UPGRADE_COST[upgrade];
- if (cost == null) continue;
- cost *= upgrade_mult;
- var new_cps;
- var new_mouse_cps;
- game.upgrade(upgrade);
- new_cps = game.total_cps();
- new_mouse_cps = game.rate_mouse(new_cps) * 5;
- new_cps += new_mouse_cps;
- game.upgrade_undo(upgrade);
- options.push(['u', upgrade, cost, new_cps]);
- }
- if (isNaN(game.total_cps())) {
- alert('critical wizard failure!');
- }
- var choice;
- var non_heavenly_choice;
- var clicks = game.clicks();
- var cookie_total = game.cookie_total();
- var cookies = game.cookies();
- options = sorted_suggestions(cookies, cps, options);
- verify_transitive(cookies, cps, options);
- for (var i = 0; i < options.length; i++) {
- if (options[i][0] == 'b')
- options[i] = { type: 'building', id: options[i][1] };
- else
- options[i] = { type: 'upgrade', id: options[i][1] };
- }
- return options;
- }
- Simulation.prototype.update_ui = function()
- {
- var important = this.refresh_from_real();
- var suggestions;
- if (important) {
- this._last_suggestions = suggestions =
- this.make_suggestions();
- console.info('new suggestions!',
- suggestions[0], suggestions[1], suggestions.slice(2));
- } else {
- // just refresh the suggestions; sometimes cookie clicker
- // likes to remove my suggestions, i think
- suggestions = this._last_suggestions;
- // this shouldn't happen
- if (!suggestions) return;
- }
- this._clear_suggestions();
- for (var i = 0; i < 3; i++) {
- var color;
- switch (i) {
- case 0:
- color = 'rgb(0, 255, 0)';
- break;
- case 1:
- color = 'rgb(255, 127, 0)';
- break;
- default:
- color = 'rgb(255, 0, 0)';
- }
- var overlay = document.createElement('span');
- overlay.className = 'suggestion';
- overlay.style.display = 'block';
- overlay.style.height = '25px';
- overlay.style.width = '40px';
- overlay.style.backgroundColor = color;
- overlay.style.position = 'relative';
- overlay.style.left = '20px';
- overlay.style.top = '20px';
- overlay.style.fontSize = '1.5em';
- overlay.style.fontWeight = 'bold';
- overlay.appendChild(document.createTextNode('[' + (i+1) + ']'));
- var node = this._find_node(suggestions[i]);
- node.appendChild(overlay);
- }
- }
- Simulation.prototype._find_node = function(suggestion)
- {
- if (suggestion.type == 'building') {
- var buildings = document.getElementsByClassName(
- 'product');
- return buildings[suggestion.id];
- } else {
- var upgrades = document.getElementById('upgrades').
- getElementsByClassName('upgrade');
- for (var i = 0; i < upgrades.length; i++) {
- var id;
- var m;
- var name;
- var onclick = upgrades[i].onclick;
- if (!onclick) continue;
- m = /UpgradesById\[(\d+)\]/.exec(
- onclick.toString());
- if (!m) continue;
- id = Number(m[1]);
- name = this._real.UpgradesById[id].name.
- replace(/\/.*/, '').
- replace('é', 'e').
- toLowerCase();
- if (name == suggestion.id)
- return upgrades[i];
- }
- }
- return null;
- }
- Simulation.prototype._clear_suggestions = function ()
- {
- var overlays = document.getElementsByClassName('suggestion');
- for (var i = overlays.length-1; i >= 0; i--) {
- var overlay = overlays[i];
- overlay.parentNode.removeChild(overlay);
- }
- }
- window.Simulation = Simulation;
- function begin(simulation)
- {
- simulation.update_ui();
- setTimeout(function () { begin(simulation) }, 100);
- }
- function wait_and_begin()
- {
- var real = real_game();
- if (real && real.cookiesEarned) {
- simulation = new Simulation({ real: real });
- setTimeout(function () { begin(simulation) }, 100);
- } else
- setTimeout(wait_and_begin, 1000);
- }
- var simulation;
- wait_and_begin();
- var secret = window.secret = {};
- secret.best_wrinklers = function ()
- {
- var game = real_game();
- var mult = Math.pow(10, -12);
- var wrinklers = game.wrinklers.
- map(function(w,i){ return { sucked: w.sucked * mult, id: i } }).
- filter(function(w){ return w.sucked > 0 });
- wrinklers.sort(function(a,b){ return b.sucked - a.sucked });
- return wrinklers;
- }
- secret.best_wrinklers_str = function ()
- {
- function fmt(w)
- {
- return '[' + w.id + ']=' + w.sucked.toFixed(2);
- }
- return this.best_wrinklers().map(fmt).join(', ');
- }
- secret.total_cookies = function ()
- {
- return this.total_cookies_raw() * Math.pow(10, -15);
- }
- secret.total_cookies_raw = function ()
- {
- var game = real_game();
- return this.wrinkler_cookies() + game.cookies;
- }
- secret.wrinkler_cookies = function ()
- {
- var game = real_game();
- var sucked = 0;
- for (var i = 0; i < game.wrinklers.length; i++)
- sucked += game.wrinklers[i].sucked;
- return sucked * 1.1;
- }
- secret.should_squish = function ()
- {
- function rates()
- {
- var res = [];
- for (var i = 0; i < 10; i++)
- res.push(1 - .05*i + .055*i*i);
- return res;
- }
- function times()
- {
- var res = [];
- for (var i = 1; i <= 10; i++)
- res.push(10000 / (30 * i));
- return res;
- }
- function cookies_forgone(rate_0, rate_1)
- {
- var r = rates();
- var t = times();
- var sum_after = 0;
- var total_time = 0;
- for (var i = 0; i < 10; i++) {
- sum_after += r[i] * t[i];
- total_time += t[i];
- }
- var sum_before = 6 * rate_0 * total_time;
- sum_after *= rate_1;
- return sum_before - sum_after;
- }
- function available(costs, cookies)
- {
- var cost = costs[costs.length-1];
- var bought = 0;
- while (cookies > cost) {
- cookies -= cost;
- bought++;
- }
- return bought;
- }
- var game = real_game();
- if (game == null) return false;
- var simulation = new Simulation({ real: game });
- simulation.refresh_from_real();
- // C_l = cookies lost by squishing wrinklers
- // T_e = time to break even
- //
- // T_p = time to earn P_c cookies with all wrinklers
- // T_p = C_p / (R_0 * 6)
- //
- // T_e = time to break even
- // T_e = (R_1 - R_0) / C_p + T_w
- // rate before prisms
- var rate_0 = simulation.game().total_cps();
- var costs = simulation.game().costs();
- var total_cookies = this.total_cookies_raw();
- var prisms = available(costs, total_cookies);
- if (!prisms)
- return false;
- while (prisms--)
- simulation.game().purchase(costs.length-1);
- // rate after prisms
- var rate_1 = simulation.game().total_cps();
- var squish_cost = cookies_forgone(rate_0, rate_1);
- var time_recover = Math.sqrt(2 * squish_cost / (rate_1 - rate_0));
- // how many cookies could i gain right now in that recovery time?
- var recovery_cookies = 6 * rate_0 * time_recover;
- return total_cookies > recovery_cookies;
- }
- var should_squish = false;
- setInterval(function () {
- var should = secret.should_squish();
- if (should && !should_squish)
- console.info("SQUISH SQUISH SQUISH");
- should_squish = should;
- }, 10000);
- function Autoclicker()
- {
- this._interval = null;
- this._thread = null;
- this._game = real_game();
- }
- Autoclicker.prototype = {};
- Autoclicker.prototype.enable = function (interval)
- {
- if (!interval) return;
- if (this._thread) this.disable();
- var self = this;
- this._interval = interval;
- this._thread = setInterval(function(){ self._click() }, interval);
- }
- Autoclicker.prototype.disable = function ()
- {
- if (this._thread) {
- clearInterval(this._thread);
- this._thread = null;
- this._interval = null;
- }
- }
- Autoclicker.prototype._click = function ()
- {
- var game = this._game;
- if (game.seasonPopup.life) {
- game.seasonPopup.click();
- } else if (game.goldenCookie.life) {
- game.goldenCookie.click();
- } else {
- game.ClickCookie();
- }
- }
- secret.autoclicker = new Autoclicker();
- })();
- }
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.appendChild(document.createTextNode(
- Secret_cookie_wizard.toString() + '\nSecret_cookie_wizard();\n'));
- document.body.appendChild(script);
Add Comment
Please, Sign In to add comment