Skip to content

Instantly share code, notes, and snippets.

@ruzli
Last active September 1, 2018 20:52
Show Gist options
  • Save ruzli/8d2cffcdcbdc88d882aab78f14309883 to your computer and use it in GitHub Desktop.
Save ruzli/8d2cffcdcbdc88d882aab78f14309883 to your computer and use it in GitHub Desktop.
const baseMultiplier = 1.08;
const lossMultiplier = 1.2;
const difference = 15400;
const maxStreak = 7;
const divisionToBackup = 1;
const stopLoss = 2000;
const maxProfit = 10000;
let lossStreak = 0;
let currentBet = 0;
let currentMultiplier = 0;
let self = this;
while (true) {
if (this.balance / 100 <= stopLoss){
await this.stop()
}
if (this.balance / 100 >= maxProfit){
await this.stop()
}
await calculateBet(this.balance);
const { multiplier } = await this.bet(currentBet, currentMultiplier);
if ((lossStreak === 0 && multiplier < baseMultiplier) || (lossStreak > 0 && multiplier < lossMultiplier)) { // loss
lossStreak++;
} else { // win
lossStreak = 0;
}
}
async function calculateBet(balance) {
if (lossStreak >= maxStreak) {
self.log(`reset because of ${lossStreak} lose in a row`);
lossStreak = 0;
}
if (lossStreak >= 2) {
await refreshSeed()
}
if (lossStreak === 0) {
gong()
currentBet = Math.floor(balance / difference / divisionToBackup / 100) * 100;
currentMultiplier = baseMultiplier;
} else if (lossStreak === 1) {
currentBet *= 5;
currentMultiplier = lossMultiplier;
} else if (lossStreak > 1) {
currentBet *= 5;
currentMultiplier = lossMultiplier;
} else if (lossStreak == 4){
currentBet *= 5;
currentMultiplier = lossMultiplier;
}
}
async function refreshSeed() {
const clientSeed = await generateClientSeed();
// request a new server seed using a random client seed
const { server_seed_hash } = await self.newSeedPair();
// set the client seed
await self.setClientSeed(clientSeed);
}
async function gong() {
const audio = new Audio("https://bustadice.com/5bb187b7ef764e76fb519939f77288c1.mp3")
audio.play()
return new Promise(resolve => audio.onended = resolve)
}
async function generateClientSeed() {
let text = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (let i = 0; i < 16; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment