Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fingersAdd=0
- var mouseMult=0
- var totMilkMult=1
- var totBuildMult=1
- var totClickMult=1
- var numberOfObjects=Object.keys(Game.Objects).length
- var baseClickingStrength=1
- var objAmountList=[]
- var objOwnedList=[]
- var bestOwnedList=[]
- var highestClickPow=0
- var skipBuilding=[]
- var sellTimeLoss=0.2
- var staticTimeLoss=2
- var clickSpeed=15
- var templeList=[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
- var skipExtraList=[0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1]
- var toWTRebuyList=[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1]
- FindOptimal=function(skip, spendable) {
- //kinda does the whole process kinda stuff thing
- return ReformatBuildingList(GetBuildings(FindGodzamokable(skip),spendable))
- };
- CalculateClickGain=function() {
- //returns how much total you would gain from clicking with godzamok
- //uses the global lists objAmountList and objOwnedList to see how many buildings are sold to godzamok
- var numSold=0
- var amountSold=0
- for (var obj in objOwnedList) {if (!objOwnedList[obj]) {numSold++; amountSold+=objAmountList[obj]}}
- var clickPow=(1+0.01*amountSold)*CalculateClickStrength()*clickSpeed*(10-staticTimeLoss-(sellTimeLoss*numSold));
- return clickPow
- };
- BinaryLoop=function(i) {
- //takes how many more recursions it should do as input
- //calculates whether the combination is the best combination on the deepest recursion (normally 0)
- //each time the function is called, it checks all combinations of deeper recursions for itself being 0 or 1, making it count in binary
- for (var flip=0; flip<2; flip++) {
- for (var nextIter=i-1; nextIter>=0; nextIter--) {if (!skipBuilding[nextIter]) {break}}
- if (nextIter>=0) {BinaryLoop(nextIter)} else {
- var clickPow=CalculateClickGain()
- if (clickPow>highestClickPow) {
- highestClickPow=clickPow;
- bestOwnedList=[...objOwnedList];
- };
- };
- if (objOwnedList[i]!=flip) {objOwnedList[i]=flip; Game.ObjectsById[i].amount=flip?objAmountList[i]:0};
- };
- };
- FindGodzamokable=function(skip) {
- //takes an input of a list of 0s and 1s, where 1 indicates that the building should not be sold to godzamok ever
- //returns the list of buildings that should be sold to godzamok
- //finds and prints buildings that should be sold to godzamok, as well as making the bestOwnedList list reflect those buildings
- //skipping more buildings makes the function significantly faster
- //templeList can be used to skip only temples, making a thorough search
- //calls the recursive function BinaryLoop to check every single combination of non-skipped buildings
- InitMouseVars();
- InitCpSVars();
- objAmountList=[]
- objOwnedList=[]
- skipBuilding=[]
- bestOwnedList=[]
- highestClickPow=0
- for (var i = 0; i < numberOfObjects; i++) {
- objAmountList.push(Game.ObjectsById[i].amount)
- objOwnedList.push(1)
- if (skip) {if (skip[i]==1) {skipBuilding.push(1)} else {skipBuilding.push(0)}};
- };
- iterLength=-1;
- for (var i=numberOfObjects-1; i>=0; i--) {if (!skipBuilding[i]) {iterLength=i; break}}
- if (iterLength>=0) BinaryLoop(iterLength)
- for (var i = 0; i < numberOfObjects; i++) {
- if (bestOwnedList[i]==0) console.log(Game.ObjectsById[i].name)
- };
- console.log(bestOwnedList, highestClickPow);
- return bestOwnedList
- };
- GetBuildings=function(objList, spendable, rebuy) {
- //takes the list of buildings sold to godzamok, cookies, and a boolean for whether you're rebuying as input
- //bestOwnedList from FindGodzamokable can be used for objList
- //Makes the building count optimal and changes the objAmountList to reflect that, and returns objAmountList
- InitMouseVars();
- InitCpSVars();
- if (!spendable) spendable=Game.cookies;
- var clickPow=0
- var vList=[]
- objAmountList=[]
- objOwnedList=[...objList]
- for (var i = 0; i < numberOfObjects; i++) {
- Game.ObjectsById[i].amount=0
- Game.ObjectsById[i].price=Game.ObjectsById[i].getPrice()
- objAmountList.push(Game.ObjectsById[i].amount)
- };
- for (var i=0; i<9999; i++) {
- for (var obj = 0; obj < numberOfObjects; obj++) {
- var me=Game.ObjectsById[obj];
- clickPow=CalculateClickGain();
- if (objOwnedList[obj]) me.amount++;
- objAmountList[obj]++;
- vList[obj]=(CalculateClickGain()-clickPow)/me.price;
- if (objOwnedList[obj]) me.amount--;
- objAmountList[obj]--;
- };
- var bestObj=vList.indexOf(Math.max(...vList))
- var me=Game.ObjectsById[bestObj]
- var cost=me.price
- var bulkCost=me.bulkPrice
- if (bulkCost<(spendable/1000)) {spendable-=bulkCost; objAmountList[bestObj]+=100}
- else if (cost<spendable) {spendable-=cost; objAmountList[bestObj]++}
- else {me.price=me.getPrice(); break}
- me.amount=objAmountList[bestObj]
- me.price=me.getPrice()
- me.bulkPrice=me.getSumPrice(100)
- if (!objOwnedList[bestObj] && !rebuy) {me.amount=0};
- };
- var buildCount=0
- for (var obj = 0; obj < numberOfObjects; obj++) {
- Game.ObjectsById[obj].amount=objAmountList[obj];
- Game.ObjectsById[obj].amount--;
- Game.ObjectsById[obj].buyFree(1);
- buildCount+=Game.ObjectsById[obj].amount
- };
- Game.BuildingsOwned=buildCount
- return objAmountList
- };
- ReformatBuildingList=function(aList) {
- //takes a building amount list as inputs to reformat it to a relative list, which is used in CCCEM
- //returns the reformated list
- rList=[]
- for (var obj = 1; obj < numberOfObjects; obj++) {
- rList.push(aList[obj]-aList[obj-1])
- };
- return rList
- };
- InitMouseVars=function()
- {
- //code copied from https://orteil.dashnet.org/cookieclicker/main.js
- //changed to make variables permanent rather than calculated every time
- fingersAdd=0
- mouseMult=0
- if (Game.Has('Thousand fingers')) fingersAdd+= 0.1;
- if (Game.Has('Million fingers')) fingersAdd*= 5;
- if (Game.Has('Billion fingers')) fingersAdd*= 10;
- if (Game.Has('Trillion fingers')) fingersAdd*= 20;
- if (Game.Has('Quadrillion fingers')) fingersAdd*= 20;
- if (Game.Has('Quintillion fingers')) fingersAdd*= 20;
- if (Game.Has('Sextillion fingers')) fingersAdd*= 20;
- if (Game.Has('Septillion fingers')) fingersAdd*= 20;
- if (Game.Has('Octillion fingers')) fingersAdd*= 20;
- if (Game.Has('Nonillion fingers')) fingersAdd*= 20;
- if (Game.Has('Decillion fingers')) fingersAdd*= 20;
- if (Game.Has('Undecillion fingers')) fingersAdd*= 20;
- if (Game.Has('Unshackled cursors')) fingersAdd*= 25;
- var num=0;
- for (var i in Game.Objects) {num+=Game.Objects[i].amount;}
- num-=Game.Objects['Cursor'].amount;
- fingersAdd=fingersAdd*num;
- if (Game.Has('Plastic mouse')) mouseMult+=0.01;
- if (Game.Has('Iron mouse')) mouseMult+=0.01;
- if (Game.Has('Titanium mouse')) mouseMult+=0.01;
- if (Game.Has('Adamantium mouse')) mouseMult+=0.01;
- if (Game.Has('Unobtainium mouse')) mouseMult+=0.01;
- if (Game.Has('Eludium mouse')) mouseMult+=0.01;
- if (Game.Has('Wishalloy mouse')) mouseMult+=0.01;
- if (Game.Has('Fantasteel mouse')) mouseMult+=0.01;
- if (Game.Has('Nevercrack mouse')) mouseMult+=0.01;
- if (Game.Has('Armythril mouse')) mouseMult+=0.01;
- if (Game.Has('Technobsidian mouse')) mouseMult+=0.01;
- if (Game.Has('Plasmarble mouse')) mouseMult+=0.01;
- if (Game.Has('Miraculite mouse')) mouseMult+=0.01;
- if (Game.Has('Aetherice mouse')) mouseMult+=0.01;
- if (Game.Has('Omniplast mouse')) mouseMult+=0.01;
- if (Game.Has('Fortune #104')) mouseMult+=0.01;
- if (Game.Has('Santa\'s helpers')) totClickMult*=1.1;
- if (Game.Has('Cookie egg')) totClickMult*=1.1;
- if (Game.Has('Halo gloves')) totClickMult*=1.1;
- if (Game.Has('Dragon claw')) totClickMult*=1.03;
- if (Game.Has('Aura gloves'))
- {
- totClickMult*=1+0.05*Math.min(Game.Objects['Cursor'].level,Game.Has('Luminous gloves')?20:10);
- }
- totClickMult*=Game.eff('click');
- if (Game.hasGod)
- {
- var godLvl=Game.hasGod('labor');
- if (godLvl==1) totClickMult*=1.15;
- else if (godLvl==2) totClickMult*=1.1;
- else if (godLvl==3) totClickMult*=1.05;
- }
- for (var i in Game.buffs)
- {
- if (typeof Game.buffs[i].multClick != 'undefined') totClickMult*=Game.buffs[i].multClick;
- }
- totClickMult*=1+Game.auraMult('Dragon Cursor')*0.05;
- baseClickingStrength*=Math.pow(2,Game.Has('Reinforced index finger')+Game.Has('Carpal tunnel prevention cream')+Game.Has('Ambidextrous'))
- return
- }
- InitCpSVars=function()
- {
- //code copied from https://orteil.dashnet.org/cookieclicker/main.js
- //changed to make variables permanent rather than calculated every time
- numberOfObjects=Object.keys(Game.Objects).length
- totMilkMult=1
- totBuildMult=1
- if (Game.hasGod)
- {
- var godLvl=Game.hasGod('decadence');
- if (godLvl==1) totBuildMult*=0.93;
- else if (godLvl==2) totBuildMult*=0.95;
- else if (godLvl==3) totBuildMult*=0.98;
- var godLvl=Game.hasGod('industry');
- if (godLvl==1) totBuildMult*=1.1;
- else if (godLvl==2) totBuildMult*=1.06;
- else if (godLvl==3) totBuildMult*=1.03;
- var godLvl=Game.hasGod('labor');
- if (godLvl==1) totBuildMult*=0.97;
- else if (godLvl==2) totBuildMult*=0.98;
- else if (godLvl==3) totBuildMult*=0.99;
- }
- Game.milkProgress=Game.AchievementsOwned/25;
- if (Game.Has('Santa\'s milk and cookies')) totMilkMult*=1.05;
- totMilkMult*=1+Game.auraMult('Breath of Milk')*0.05;
- if (Game.hasGod)
- {
- var godLvl=Game.hasGod('mother');
- if (godLvl==1) totMilkMult*=1.1;
- else if (godLvl==2) totMilkMult*=1.05;
- else if (godLvl==3) totMilkMult*=1.03;
- }
- totMilkMult*=Game.eff('milk');
- }
- CalculateClickStrength=function() {
- //returns how much you gain from 1 click, mostly only recalculating the things that change. Seems optimized enough for now
- Game.cookiesPs=0
- for (var i in Game.Objects) {
- var me=Game.Objects[i];
- me.storedCps=me.cps(me);
- if (Game.ascensionMode!=1) me.storedCps*=(1+me.level*0.01)*totBuildMult;
- if (me.id==1 && Game.Has('Milkhelp® lactose intolerance relief tablets')) me.storedCps*=1+0.05*Game.milkProgress*totMilkMult;
- me.storedTotalCps=me.amount*me.storedCps;
- Game.cookiesPs+=me.storedTotalCps;
- }
- if (Game.Has('"egg"')) {Game.cookiesPs+=9;Game.cookiesPsByType['"egg"']=9;}//"egg"
- Game.cookiesPs*=Game.globalCpsMult;
- var out=totClickMult*(Game.cookiesPs*mouseMult+baseClickingStrength+fingersAdd)
- return out
- };
- InitMouseVars();
- InitCpSVars();
Advertisement
Add Comment
Please, Sign In to add comment