Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › My simple algorithm to beat CookieClicker... perhaps create some competition?
New Posts  All Forums:Forum Nav:

My simple algorithm to beat CookieClicker... perhaps create some competition?

post #1 of 5
Thread Starter 
http://orteil.dashnet.org/cookieclicker/

I saw someone playing this a few weeks ago and I decided to check it out. After playing with it for a few minutes i decided to look into the source to see how they coded it. Then i started to cheat my way trough calling the functions to do this and that, just playing with the code.

Once again, i saw someone playing with this page again, and i decided to write a little bit of code to play automatically. Then i was thinking it may be fun to see who can code the best algorithm via the Highest CPS within X amount of time running.



This is my simple thing I wrote in a few minutes.
Code:
// To Run
var blahh = setInterval( 
function()
{ 
for( var i = 0 ; i < 10; i++)
{
if(Game.ObjectsById[i].amount < 5)
{
Game.ObjectsById[i].buy();
return;
}

if(i == 9)
{
Game.ObjectsById[i].buy();
}
else if(Game.ObjectsById[i+1].amount > Game.ObjectsById[i].amount *5)
{
Game.ObjectsById[i].buy();
}
}
}
,1000)

//

//To Clear the Interval
clearInterval(blahh)


You could incorporate buying upgrades with
Code:
Game.UpgradesById[ X ].buy()

In my case i clicked a bunch at the start to get ~22 cps then let my program go, but to compete, it should be with 0 clicks and set a starting value via
Code:
Game.Earn(1000)

You can check how long it has been running in minutes via
Code:
(Date.now() - Game.startDate)/1000/60

I'm at 36,104.5 CPS after 70 minutes in with 15 mill or so in the bank. Let me know if you would be interested in competing on this. It may be fun.
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
post #2 of 5
Thread Starter 
I decided to check up on it, and i noticed that the jump between Portal and Time Machine is huge as well as the Antimatter thingy.

So, i twieked the code a bit and fixed a bug within it =D. I also set my starting to 500 which i instantly bought a Farm with. I reset everything and ran this.
Code:
Game.Earn(500);
Game.ObjectsById[2].buy();
var blahh = setInterval( 
function()
{ 
var multiple = 5;
for( var i = 0 ; i < 10; i++)
{
if(i = 7)
{
multiple = 15;
}
if(i = 8)
{
multiple = 12;
}

if(Game.ObjectsById[i].amount < multiple)
{
Game.ObjectsById[i].buy();
return;
}

if(i == 9)
{
Game.ObjectsById[i].buy();
}
else if(Game.ObjectsById[i+1].amount > (Game.ObjectsById[i].amount / multiple))
{
Game.ObjectsById[i].buy();
}
}
}
,1000)

Edited by Mrzev - 10/13/13 at 4:21am
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
post #3 of 5
I'm not really sure I understand the point of that game nor this thread (competing who can cheat the most when you have access to the source code kind of seems pointless as everyone could just set the cookie value to whatever the highest number a javascript int can store).

I do have one question about your code though, why are you not indenting? If it's not a weird Huddler formatting bug, then you're getting into some pretty bad habits by failing to indent
post #4 of 5
Thread Starter 
The indent issue seems to happen when i copy it over. There are still a bunch of bugs in that code too. The if i = x should be ==.

Technically you can do Game.Earn(Number.MAX_NUMBER) and be at the max technically, but its more of who can create a more efficient algorithm that does not cheat outside the initial 500 gain from the start. The .Buy command spends your resources. If you don't have enough, it wont purchase it.

I like analyzing stuff, min\maxing everything in games. Finding the most optimal way to do whatever. In a sense, the most optimal program would need to look trough each purchase option and way out its efficiency. The next tiers are by far way more efficient than the lower tiers, but since the cost goes up each time, they will eventually start to balance out. Then there is also the time span, where Y is slightly more cost efficient than X , but by the time it takes to wait to have enough money to buy Y, X would technically have been more efficient.
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
Zev's Comp
(15 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Sandy Bridge 3.3GHz GIGABYTE GA-Z68X-UD3H-B3 LGA 1155 Intel Z68 HDM... GeForce GTX 750 Ti G.SKILL Ripjaws X Series 8GB 
Hard DriveHard DriveHard DrivePower
1TB HDD 64GB SSD (Used for SRT) 500 GB. Antec BP550 Plus 550W Continuous Power ATX12V V... 
Case
COOLER MASTER ELITE 335 RC-335-KKN1-GP Black S... 
  hide details  
Reply
post #5 of 5
It actually supports that and says "Infinity cookies" XD
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
Akiyama Mio
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6420 @ stock, 0.98v Asus P5N-E SLI Gainward GTX 460 1GB @ 800/1600/1900 2x2GB Kingston @ 800MHz 5-5-5-15 2T 
Hard DriveOptical DriveOSMonitor
WD 250GB, 320GB SATA/3, 16MB Cache, Seagate 1TB LG GSA-H62N 18x SATA Ubuntu 9.10 x86 & Win7 x86 Asus VW222U 
KeyboardPowerCase
Logitech Classic Corsair 650HX NZXT Apollo Black 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › My simple algorithm to beat CookieClicker... perhaps create some competition?