Skip to content

Instantly share code, notes, and snippets.

@kaeverens
Last active October 7, 2020 19:18
Show Gist options
  • Save kaeverens/edf8f2c928dd8c0c2732b3117d351360 to your computer and use it in GitHub Desktop.
Save kaeverens/edf8f2c928dd8c0c2732b3117d351360 to your computer and use it in GitHub Desktop.
script to play DecisionProblem's Paperclip game. stick into web inspector, then call makeDecision() to start it going
// https://www.decisionproblem.com/paperclips/index2.html
function makeDecision() {
var pp_step=window.pp_step||0;
clipClick(1);
var lastUnsold=window.lastUnsold||0, qtot=0;
if (unsoldClips>avgSales*2.1 && margin>0.01 && unsoldClips>lastUnsold) lowerPrice();
else if (unsoldClips<avgSales*2 && unsoldClips<=lastUnsold) raisePrice();
window.lastUnsold=unsoldClips;
if (!btnMakeClipper.disabled && funds>clipperCost+wireCost && document.querySelector('#megaClipperDiv').style.display=='none') makeClipper();
if (!btnMakeMegaClipper.disabled && funds>megaClipperCost+wireCost) makeMegaClipper();
if (!btnExpandMarketing.disabled) buyAds();
var projBtn=document.querySelector('#projectListTop button:not([disabled])');
if (!btnAddMem.disabled && !projBtn) {
addMem();
console.log('add memory');
}
if (!btnAddProc.disabled) {
addProc();
console.log('add processing');
}
if (projBtn) projBtn.click();
var lastDeposit=window.lastDeposit||0;
var lastWithdraw=window.lastWithdraw||1;
if (pp_step%2==1 && bankroll>lastWithdraw) {
window.lastWithdraw=bankroll;
console.log('withdraw', bankroll);
investWithdraw();
}
if (!btnBuyWire.disabled) {
if (wire<2000) {
btnBuyWire.click();
}
if (pp_step%2==0 && funds>lastDeposit && document.querySelector('#investmentEngine').style.display!='none') { // only deposit once other purchases are complete
console.log('deposit', funds) ;
window.lastDeposit=funds;
investDeposit();
}
}
qChips.forEach(q=>{
if (q.active) qtot+=q.value;
});
if (qtot>0) btnQcomputeElement.click();
if (operations>=memory*1000) {
if (document.querySelector('#tournamentManagement').style.display!='none') {
if (!btnNewTournament.disabled) btnNewTournament.click();
}
}
stratPickerElement.value=document.querySelector('#stratPicker option:last-child').value;
btnRunTournament.click();
btnImproveInvestments.click();
window.pp_step=pp_step+1;
setTimeout(makeDecision, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment