Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Last active January 11, 2023 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsetzer/2248aab56db4b5049560cfab87e90cc3 to your computer and use it in GitHub Desktop.
Save dsetzer/2248aab56db4b5049560cfab87e90cc3 to your computer and use it in GitHub Desktop.
Bustadice's default martingale script is less configurable than bustabit's so I made a bustadice version out of it. (this is for use on bustadice).
var config = {
baseBet: { value: 100, type: 'balance', label: 'base bet' },
stopBet: { value: 1e8, type: 'balance', label: 'stop if bet >' },
basePayout: { value: 2, type: 'multiplier' },
stopPayout: {value: 20,type: 'multiplier',label: 'stop if payout >'},
lossBet: {
value: 'increase', type: 'radio', label: 'Bet On Loss',
options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Multiply bet by' },
}
},
winBet: {
value: 'base', type: 'radio', label: 'Bet On Win',
options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Multiply bet by' },
}
},
lossPayout: {
value: 'increase', type: 'radio', label: 'Payout On Loss',
options: {
base: { type: 'noop', label: 'Return to base payout' },
increase: { value: 2, type: 'number', label: 'Increase payout by' },
}
},
winPayout: {
value: 'base', type: 'radio', label: 'Payout On Win',
options: {
base: { type: 'noop', label: 'Return to base payout' },
increase: { value: 2, type: 'number', label: 'Increase payout by' },
}
},
delay: { value: 100, type: 'number', label: 'Bet Speed' }
};
this.log('Script is running..');
var currentBet = config.baseBet.value;
var currentPayout = config.basePayout.value;
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
for(;;){
const result = await this.bet(roundBit(currentBet), currentPayout);
if (result.multiplier >= result.target) {
if (config.winBet.value === 'base') {
currentBet = config.baseBet.value;
} else {
console.assert(config.winBet.value === 'increase');
currentBet *= config.winBet.options.increase.value;
}
if (config.winPayout.value === 'base') {
currentPayout = config.basePayout.value;
} else {
console.assert(config.winPayout.value === 'increase');
currentPayout += config.winPayout.options.increase.value;
}
this.log('We won, so next bet will be', currentBet/100, 'bits @ ', currentPayout + 'x')
} else {
// damn, looks like we lost :(
if (config.lossBet.value === 'base') {
currentBet = config.baseBet.value;
} else {
console.assert(config.lossBet.value === 'increase');
currentBet *= config.lossBet.options.increase.value;
}
if (config.lossPayout.value === 'base') {
currentPayout = config.basePayout.value;
} else {
console.assert(config.lossPayout.value === 'increase');
currentPayout += config.lossPayout.options.increase.value;
}
this.log('We lost, so next bet will be', currentBet/100, 'bits @ ', currentPayout + 'x');
}
if (currentBet >= config.stopBet.value) {
this.log('Was about to bet', currentBet, 'which triggers the stop');
break;
}else if (currentPayout >= config.stopPayout.value) {
this.log('Was about to bet', currentPayout+'x', 'which triggers the stop');
break;
}
await sleep(config.delay.value);
}
@owersite
Copy link

owersite commented Feb 12, 2021

Great work <3
edit: not working.

@dsetzer
Copy link
Author

dsetzer commented Feb 12, 2021

Great work <3
edit: not working.

Appears to be working perfectly for me.. If you want to be more specific about the issue, I can check it out =]
image

@unboxwealth
Copy link

Hi,

Would u like help with a bustadice martingale script which '+ bits' feature instead of 'x bits'

It won't be called martingale. For the same target adding bets after loss or win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment