[Admin]

Cookie Clicker Automator

Click here for BUGS and task list. / Click here for other information.

Begin Automation
The following code can be copied and pasted into your browser's Javascript console to begin the automation. A more compact version of this code without whitespace or documentation can be found here. If you are unfamiliar with Javascript you may find it easier to use the Bookmarklet process instead.

// The automator function is triggered every 62 milliseconds using the // setInterval method. The value returned by this method is assigned to the // ccAutomator variable to allow the automator to be disabled using the // clearInterval method, rather than only by leaving or refreshing the page. var ccAutomator = setInterval(function () { // If values associated with the game are not found, or the version of the // game is not as expected, the function is terminated and removed with a // user-visible status message. if (typeof Game !== 'object' || Game.version !== 1.0465) { clearInterval(ccAutomator); alert('This function was designed for Cookie Clicker v.1.0465, and can only run on a page where that version of the game is running.'); return; } // Always clicks golden cookies. if (Game.goldenCookie.life > 0) { Game.goldenCookie.click(); return; } // Using "Confessor's Algorithm" for building and upgrade purchases. // Confessor's Algorithm selects the least-expensive unlocked and unpurchased // upgrade, then purchases units of each unlocked building, starting with the // greatest available cookies-per-second generator, until the purchase price // of all buildings is greater than or equal to that of the selected upgrade, // before purchasing the upgrade itself. // To exactly match my strategy when playing manually the script should always // select the first upgrade visible in the upgrade panel of the store. From my // observations this is usually but not necessarily always the case when two // or more upgrades share the same exact price. if (arguments.callee.selectedUpgrade === undefined) { for (i = 0; i < Game.UpgradesById.length; i++) { if (!Game.UpgradesById[i].unlocked) continue; if (Game.UpgradesById[i].bought) continue; // Automatic selection and purchase of these upgrades leads to a closed // gameplay loop. Hence, they may only be purchased manually. if (Game.UpgradesById[i].name === 'Elder Pledge' || Game.UpgradesById[i].name === 'Elder Convenant') continue; if (arguments.callee.selectedUpgrade === undefined || Game.UpgradesById[i].getPrice() < Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice()) arguments.callee.selectedUpgrade = i; } } if (arguments.callee.selectedBuilding === undefined) { for (i = 0; i < Game.ObjectsById.length; i++) { if (Game.ObjectsById[i].locked) continue; // If no upgrade was selected, as can happen at the beginning of a new // game among other circumstances, my strategy simply selects the least // expensive building as a stopgap. if (arguments.callee.selectedUpgrade === undefined) { if (arguments.callee.selectedBuilding === undefined || Game.ObjectsById[i].getPrice() < Game.ObjectsById[arguments.callee.selectedBuilding].getPrice()) arguments.callee.selectedBuilding = i; continue; } if (Game.ObjectsById[i].getPrice() < Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice()) arguments.callee.selectedBuilding = i; } } if (arguments.callee.selectedBuilding !== undefined && Game.cookies >= Game.ObjectsById[arguments.callee.selectedBuilding].getPrice()) { Game.ObjectsById[arguments.callee.selectedBuilding].buy(); if (arguments.callee.selectedUpgrade === undefined || Game.ObjectsById[arguments.callee.selectedBuilding].getPrice() >= Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice()) arguments.callee.selectedBuilding = undefined; return; } if (arguments.callee.selectedUpgrade !== undefined && Game.cookies >= Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice()) { // An integer value of 1 is passed to the buy method to bypass any // confirmation dialogs that would impede purchase, such as that for the // 'One mind' research upgrade. Game.UpgradesById[arguments.callee.selectedUpgrade].buy(1); // In my current iteration of this strategy, upgrade selection is only // released after the upgrade is purchased. This can lead to unnecessary // delays in progression when, for example, a building purchase or some // other intervening process (like Bingo Center research) unlocks an upgrade // less expensive than the one currently selected. arguments.callee.selectedUpgrade = undefined; arguments.callee.selectedBuilding = undefined; return; } // Clicks the big cookie whenever no other action was taken. Game.ClickCookie(); }, 62);
The following code can be copied and pasted into your browser's Javascript console to begin the automation. If you are unfamiliar with Javascript you may find it easier to use the Bookmarklet process instead.

var ccAutomator = setInterval(function () {if (typeof Game !== 'object' || Game.version !== 1.0465) {clearInterval(ccAutomator);alert('This function was designed for Cookie Clicker v.1.0465, and can only run on a page where that version of the game is running.');return;}if (Game.goldenCookie.life > 0) {Game.goldenCookie.click();return;}if (arguments.callee.selectedUpgrade === undefined) {for (i = 0; i < Game.UpgradesById.length; i++) {if (!Game.UpgradesById[i].unlocked)continue;if (Game.UpgradesById[i].bought)continue;if (Game.UpgradesById[i].name === 'Elder Pledge' || Game.UpgradesById[i].name === 'Elder Convenant')continue;if (arguments.callee.selectedUpgrade === undefined || Game.UpgradesById[i].getPrice() < Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice())arguments.callee.selectedUpgrade = i;}}if (arguments.callee.selectedBuilding === undefined) {for (i = 0; i < Game.ObjectsById.length; i++) {if (Game.ObjectsById[i].locked)continue;if (arguments.callee.selectedUpgrade === undefined) {if (arguments.callee.selectedBuilding === undefined || Game.ObjectsById[i].getPrice() < Game.ObjectsById[arguments.callee.selectedBuilding].getPrice())arguments.callee.selectedBuilding = i;continue;}if (Game.ObjectsById[i].getPrice() < Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice())arguments.callee.selectedBuilding = i;}}if (arguments.callee.selectedBuilding !== undefined && Game.cookies >= Game.ObjectsById[arguments.callee.selectedBuilding].getPrice()) {Game.ObjectsById[arguments.callee.selectedBuilding].buy();if (arguments.callee.selectedUpgrade === undefined || Game.ObjectsById[arguments.callee.selectedBuilding].getPrice() >= Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice())arguments.callee.selectedBuilding = undefined;return;}if (arguments.callee.selectedUpgrade !== undefined && Game.cookies >= Game.UpgradesById[arguments.callee.selectedUpgrade].getPrice()) {Game.UpgradesById[arguments.callee.selectedUpgrade].buy(1);arguments.callee.selectedUpgrade = undefined;arguments.callee.selectedBuilding = undefined;return;}Game.ClickCookie();}, 62);
Drag the following link to your browser's bookmark bar to add it to your bookmarks. Then, click the bookmark while playing Cookie Clicker to begin the automation.

CC Automator Begin





End Automation
The following code can be copied and pasted into your browser's Javascript console to end the automation. If you are unfamiliar with Javascript you may find it easier to use the Bookmarklet process instead.

clearInterval(ccAutomator);
Drag the following link to your browser's bookmark bar to add it to your bookmarks. Then, click the bookmark while playing Cookie Clicker to end the automation.

CC Automator End

Bugs & Task List

BUG: In Confessor's Purchase Algorithm, all attempts to exclude Elder Covenant (and perhaps Elder Pledge) from selection and automatic purchase have failed, resulting in an eventual gameplay loop.

TASK: In Confessor's Purchase Algorithm, the building selection process should soft-cap building amounts at the threshold needed to unlock all upgrades and earn all achievements.

TASK: Confessor's Purchase Algorithm should include a means of periodically reevaluating the targeted upgrade to account for intervening actions that might have unlocked a cheaper upgrade.

TASK: "Click Big Cookie" logic should include an option to cease clicking when all clicking-related achievements have been earned and upgrades unlocked.

Other Information

For many years now I've had a casual interest in developing tools for metagaming -- that is, developing tools to allow a player to auto-play a game, within specified constraints. This is, of course, superficially similar to the practice of "botting" in online games like World of Warcraft and Diablo III, but with one key difference: the only contexts I desire to thus automate are singleplayer, and the only rewards for doing so are self-satisfaction, convenience, and deeper understanding of the underlying gameplay systems.

Unfortunately, I've found that neither my skill nor ambition have been up to the task of automating any of my previous gaming obsessions, like Civilization III, various two-dimensional Final Fantasy games (via software emulation), and Bizarre Creations' score-attack shooter The Club. By virtue of its open (though not entirely transparent) Javascript API, writing an automator for
Cookie Clicker has proven to be largely within my skillset and ambition.

Note that this automator is not meant to be a cheating tool, except inasmuch as automation is itself cheating. It cannot be used to (for example) directly add large amounts of cookies to your cookie total, or increase the spawning rate of Golden Cookies. Intead, it merely strives to automate what might otherwise happen in the normal course of gameplay.

Just as the source of Cookie Clicker is freely available for perusal, so is my own. It relies so heavily on my custom framework, however, that it may prove difficult or impossible to adapt to your purposes. Also, linking to it from this page seems kind of paradoxical. If clicking on it blows up the universe, that's on you.

If you wish to congratulate or blame me for facilitating the destruction of the universe, please leave me a message using the feedback form attached to my Doonesbury Navigator project, as my general website feedback form is out of service. You can put other stuff in that message, too, like bug reports, accolades, flames, or selections from classic poetry. I'm partial to Tennyson's Lady of Shalott, and have been since I first heard portions of it recited in Kevin Sullivan's 80's TV Movie version of Anne of Green Gables. His version of Anne of Avonlea was pretty good, too, if I remember correctly. Still haven't seen The Continuing Story, though, and probably never will. If it doesn't live up to the high standards of its forebears (as I've heard), I'm afraid it will color my perception of the entire series.

I refused to watch Serenity for the longest time, too, even after reading a summary that spoiled the key plot points of the film. I just loved the characters of Wash and Shepherd Book so much that didn't think I could bear to see 'em die onscreen. I thought I would rather just pretend they were still flying around in that fictional universe.

Finally, have you tried eating maple-glazed bacon jerky? It's a goddamned revelation, I tell you! I mean, it's not like a box of Teuscher chocolates, or a serving of authentic Quebec poutine, but, y'know, if you're stuck in [Censored Location], the cultural ass-crack of these United States, you can't really get much better.

God, I'm tired. And no, I am not high.