Last active
December 21, 2019 17:49
-
-
Save ruzli/ce135ed1252dd70550e530ae20bb880e to your computer and use it in GitHub Desktop.
ported martingale from bab to bad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = { | |
baseBet: { value: 100, type: 'balance', label: 'base bet' }, | |
payout: { value: 2, type: 'multiplier' }, | |
whenToStop: { type: "number", label: "Stop in %, if balance <", value: 0 }, | |
stop: { value: 1e8, type: 'balance', label: 'stop if bet >' }, | |
multiply: { type: 'checkbox', label: 'Do Multiply? (Add on uncheck)', value: true }, | |
loss: { | |
value: 'base', type: 'radio', label: 'On Loss', | |
options: { | |
base: { type: 'noop', label: 'Return to base bet' }, | |
increase: { value: 2, type: 'multiplier', label: 'Increase bet by' }, | |
listing: { value: '120, 250, 550, 1200, 2700, 5500, 11000, 20000', type: 'text', label: 'Listing' }, | |
stop: { type: 'noop', label: 'Stop on hitting lose', value: false }, | |
} | |
}, | |
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' }, | |
listing: { value: '1, 2, 3, 5, 7, 10, 15, 20', type: 'text', label: 'Listing' }, | |
stop: { type: 'noop', label: 'Stop on hitting wins', value: false }, | |
} | |
} | |
}; | |
this.log('Script is running..'); | |
var lossCount = 0 | |
var winCount = 0 | |
var lock_balance = (this.balance / 100) * (config.whenToStop.value / 100) /* Lock balance specified in config in percent before script start */ | |
var currentBet = config.baseBet.value; | |
var lossList = [] | |
var winList = [] | |
function importFromJsonList(list, newList){ | |
//lossList = []; | |
//winList = []; | |
newList = [] | |
let tempList = JSON.parse(`[${list}]`); | |
for (let i = 0, len = tempList.length; i < len; i++) { | |
//lossList.push(tempList[ i ]); | |
//winList.push(tempList[ i ]); | |
newList.push(tempList[ i ]); | |
} | |
return newList | |
}; | |
function pickList(count, list) { | |
if (count > list.length) { | |
return list[0]; | |
} else { | |
return list[count]; | |
} | |
}; | |
function pickRandom() { | |
return Math.floor(lossList.length * Math.random()); | |
}; | |
while (true) { | |
if (this.balance / 100 <= lock_balance && config.whenToStop.value != 0) { await this.stop() } | |
const { multiplier } = await this.bet(roundBit(currentBet), config.payout.value); | |
if (multiplier >= config.payout.value) { | |
winCount++ | |
if (config.win.value === 'base') currentBet = config.baseBet.value; | |
if (config.win.value === 'stop') this.stop(); | |
if (config.win.value === 'increase') { | |
console.assert(config.win.value === 'increase'); | |
if (config.multiply.value) { | |
currentBet *= config.win.options.increase.value; | |
} else if (config.multiply.value == false) { | |
currentBet += config.win.options.increase.value * 50; | |
} | |
} | |
if (config.win.value === 'listing') { | |
console.assert(config.win.value === 'listing'); | |
winList = importFromJsonList(config.win.options.listing.value, winList) | |
currentBet = pickList(winCount, winList) * 100 | |
} | |
this.log('We won, so next bet will be', Math.round(currentBet / 100), 'bits') | |
lossCount = 0; | |
} else { | |
lossCount++; | |
// damn, looks like we lost :( | |
if (config.loss.value === 'base') currentBet = config.baseBet.value; | |
if (config.loss.value === 'stop') this.stop(); | |
if (config.loss.value === 'increase') { | |
console.assert(config.loss.value === 'increase'); | |
if (config.multiply.value) { | |
currentBet *= config.loss.options.increase.value; | |
} else if (config.multiply.value == false) { | |
currentBet += config.loss.options.increase.value * 50; | |
} | |
} | |
if (config.loss.value === 'listing') { | |
console.assert(config.loss.value === 'listing'); | |
lossList = importFromJsonList(config.loss.options.listing.value, lossList) | |
currentBet = pickList(lossCount, lossList) * 100 | |
} | |
this.log('We lost, so next bet will be', Math.round(currentBet / 100), 'bits') | |
winCount = 0 | |
} | |
if (currentBet > config.stop.value) { | |
this.log('Was about to bet', Math.round(currentBet / 100), 'which triggers the stop'); | |
await this.stop() | |
} | |
if (currentBet < config.baseBet.value) { | |
currentBet = config.baseBet.value | |
} | |
} | |
function roundBit(bet) { return Math.max(100, Math.round(bet / 100) * 100); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment