Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Created February 25, 2019 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dsetzer/df6e77247225bdf0f10e22759e8bb09b to your computer and use it in GitHub Desktop.
Save dsetzer/df6e77247225bdf0f10e22759e8bb09b to your computer and use it in GitHub Desktop.
/* ---- SETTINGS ---- */
const baseBet = 100;
const basePayout = 1.5;
const baseMulti = 1.5;
const postBet = 2;
const maxProfit = 100000;
/* ----------------- */
let currBet = baseBet, startBal = this.balance;
let postBal = startBal, prevBal = startBal;
let maxBet = baseBet * Math.pow(baseMulti, 5);
let maxLoss = 5000, profit = 0, gameNum = 0;
function roundBit(bet){
return Math.max(100, Math.round(currBet / 100) * 100);
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
const generateClientSeed = (wordNum = 3, wordLen = 12, noNumeric, noRepeat, noReuse, a, b) => {
noNumeric = noNumeric || false, noRepeat = noRepeat || false, noReuse = noReuse || false;
let n = (!noNumeric ? "0123456789" : ""), text = "", last = "", word = "", l = "";
a = a || `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz${n}`;
b = b || `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz${n}`;
for (let w = 0; w < wordNum; w++){
word = "";
for (let i = 0; i < wordLen; i++){
do {
last = l.toLowerCase();
const set = i < wordLen / 2 ? a : b
l = set.charAt(Math.floor(Math.random() * set.length))
} while((noRepeat && l == last) || (noReuse && word.includes(l)));
word += l;
}
text += word + " ";
}
return text.trim();
}
const refreshSeed = async(context) => {
try {
await context.newSeedPair();
} catch (e) {
if (e === "Error: EXISTING_SEED_TRIPLE_UNUSED") {
await context.skip();
await context.newSeedPair();
} else {
context.log(e);
return;
}
}
let seed = generateClientSeed(1, 23);
context.log(`Set client seed to ${seed}`)
return context.setClientSeed(seed);
}
const main = async () => {
this.log(`Starting with ${maxBet/100} max bet.`)
while(true){
prevBal = this.balance;
if((profit - currBet) < -maxLoss){
this.log(`Stopping at max losses of ${profit}/${maxLoss}`);
break;
}
// if(currBet >= maxBet){
// this.log(`Stopping at max bet of ${currBet}/${maxLoss}`);
// break;
// }
const { multiplier } = await this.bet(roundBit(currBet), basePayout)
if(multiplier < basePayout){
postBal -= (currBet * postBet);
currBet *= baseMulti;
postBal += (currBet * postBet);
profit -= currBet;
}else{
profit += currBet * basePayout - currBet;
if(profit >= maxProfit){
profit = 0;
}
}
this.log(`Current bet ${currBet/100} @ ${basePayout}. Current profit ${profit/100} bits. [Bal ${this.balance}/${postBal}]`);
if(this.balance >= postBal && prevBal < postBal){
currBet = baseBet, postBal = this.balance;
maxLoss = Math.max(maxLoss, postBal - startBal);
}
gameNum++;
if(gameNum % 10 === 0){
await refreshSeed(this);
}
await sleep(800);
}
};
await main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment