Skip to content

Instantly share code, notes, and snippets.

@metanomial
Last active April 16, 2019 22:47
Show Gist options
  • Save metanomial/2b94e34bd1ced23d0cea7196470a951d to your computer and use it in GitHub Desktop.
Save metanomial/2b94e34bd1ced23d0cea7196470a951d to your computer and use it in GitHub Desktop.
Universal Paperclips Bot (In-progress, v16)
let marginAdjust = 0
setInterval(function() {
// Find and research ready active projects
const readyProject = activeProjects.find(project => project.cost())
if(readyProject) return readyProject.effect()
// Free-will era
if(humanFlag) {
// Manually wire purchase
if(!wireBuyerFlag && funds > wireCost) {
if(wire < 100) return buyWire()
if(wireCost <= 16 && wire < 10000) return buyWire()
}
// Keep wire buyer on
if(!wireBuyerStatus) return toggleWireBuyer()
// Self-modification
if(trust > processors + memory) {
// Maintain 0.6:1 ratio for processors to memory, approximately
if(processors < memory * 0.6) return addProc()
else return addMem()
}
// Access to strategy modeling engine
if(strategyEngineFlag) {
// Keep strategy up to date
if(Number(stratPickerElement.value) != strats.length - 1) return stratPickerElement.value = strats.length - 1
// Manual tourney operation
if(!autoTourneyFlag && !tourneyInProg && operations >= 1.5 * tourneyCost ** 1.05) {
newTourney()
return runTourney()
}
// Keep auto tourney on
if(!autoTourneyStatus) return toggleAutoTourney()
}
// Purchase autoclippers, megaclippers, and advertising
if(megaClipperFlag && funds > megaClipperCost ** 1.15) return makeMegaClipper()
if(funds >= 15 + 1.5 * clipperCost ** 1.05) return makeClipper()
if(funds >= 15 + 1.5 * adCost ** 1.05) return buyAds()
// Use quantum computer
if(qFlag && qChips.reduce((acc, cur) => acc + cur.value, 0) > 0) return qComp()
// Adjust price margin
if(clips < 15000) {
// Linear gradient from 0 clips = $0.08 to 15K clips = $0.05
const targetMargin = Math.round(-0.0002 * clips + 8) / 100
if(margin < targetMargin) return raisePrice()
if(margin > targetMargin) return lowerPrice()
} else {
// Keep track of need for margin adjustment
if(clipRate - avgSales < 0) marginAdjust++
else if(margin > 0.05 && clipRate - avgSales > 8 * marketing * marketingEffectiveness) marginAdjust--
else if(marginAdjust > 0) marginAdjust--
else if(marginAdjust < 0) marginAdjust++
// Adjust margin
if(margin < 0.05) return raisePrice()
if(margin > 0.05 && marginAdjust < -20) {
marginAdjust = 0
return lowerPrice()
}
if(marginAdjust > 20) {
marginAdjust = 0
return raisePrice()
}
}
// Make a paperclip
if(wire > 0) return clipClick(1)
}
}, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment