Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Last active March 31, 2023 12:22
Show Gist options
  • Save dsetzer/79907d818aedf484f3179614635d5999 to your computer and use it in GitHub Desktop.
Save dsetzer/79907d818aedf484f3179614635d5999 to your computer and use it in GitHub Desktop.
default martingale script from bustabit converted to bustadice.
const config = {
baseBet: { value: 100, type: 'balance', label: 'Base bet' },
payout: { value: 2, type: 'multiplier', label: 'Payout' },
stop: { value: 1e8, type: 'balance', label: 'Stop if bet >' },
loss: { value: 'increase', type: 'radio', label: 'On Loss', options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Increase bet by' }
}},
win: { value: 'base', type: 'radio', label: 'On Win', options: {
base: { type: 'noop', label: 'Return to base bet' },
increase: { value: 2, type: 'multiplier', label: 'Increase bet by' }
}},
delay: { value: 100, type: 'number', label: 'Bet speed' }
};
this.log('Script is running..');
var currentBet = config.baseBet.value;
for (;;) {
this.log('Placing bet, current bet is', currentBet / 100, 'bits');
const result = await this.bet(roundBit(currentBet), config.payout.value);
if (result.multiplier >= result.target) {
if (config.win.value === 'base') {
currentBet = config.baseBet.value;
} else {
console.assert(config.win.value === 'increase');
currentBet *= config.win.options.increase.value;
}
this.log('We won, so next bet will be', currentBet / 100, 'bits')
} else {
if (config.loss.value === 'base') {
currentBet = config.baseBet.value;
} else {
console.assert(config.loss.value === 'increase');
currentBet *= config.loss.options.increase.value;
}
this.log('We lost, so next bet will be', currentBet / 100, 'bits')
}
if (currentBet > config.stop.value) {
this.log('Was about to bet', currentBet, 'which triggers the stop');
break;
}
await sleep(config.delay.value);
}
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
@dsetzer
Copy link
Author

dsetzer commented Jan 8, 2023

Hi, Can you share a bustadice martingale script which stops betting immediately after the target is hit?

Like this?
https://gist.github.com/dsetzer/ce5ac47b815992a593ff0bced38735e1

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