Skip to content

Instantly share code, notes, and snippets.

@dsetzer
dsetzer / default-martingale-sim.js
Created July 15, 2021 23:07
default martingale script from bustabit converted to bustadice with added sim mode.
var config = {
baseBet: { value: 100, type: 'balance', label: 'Base Bet' },
payout: { value: 2, type: 'multiplier', label: 'Target Payout' },
stop: { value: 1e8, type: 'balance', label: 'Stop if bet >' },
delay: { value: 100, type: 'number', label: 'Bet Speed' },
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' },
@dsetzer
dsetzer / round-prec.js
Last active April 14, 2021 07:58
Rounding with precision
// Arrow functions
const round = (num, prec) => (prec = 10 ** prec, Math.round(num * prec) / prec);
const roundUp = (num, prec) => (prec = 10 ** prec, Math.ceil(num * prec) / prec);
const roundDown = (num, prec) => (prec = 10 ** prec, Math.floor(num * prec) / prec);
// Classic functions
function round(num, prec) {
prec = Math.pow(10, prec);
return Math.round(num * prec) / prec;
}
@dsetzer
dsetzer / bab_to_ether-dice.js
Created March 21, 2021 22:36
Script wrapper for running bustabit scripts on ether-dice. This expects the bustabit script to be standard format where bets are placed at GAME_STARTING event. Scripts with everything in GAME_ENDED will skip endlessly. Also don't expect any Ruzli scripts to work, it's a miracle those run to begin with.
engine.bet=function(e,n){this.nextBet={value:e,target:n}},engine.getState=(()=>{}),engine.cashOut=(()=>{});const gameResultFromHash=()=>{},SHA256=()=>{};engine.history={first(){let e=engine.nextResult;if(e||(e=engine.getLastGamePlayed),e){let n={id:e.id,hash:e.hash,bust:e.crash};return["NOT_PLAYED","SKIPPED"].includes(engine.getLastGamePlay)||(n.wager=e.wager,e.cashout<=e.crash&&(n.cashedAt=e.cashout)),n}return{id:0,hash:"none",bust:0,wager:0,cashedAt:0}}};const log=console.log,stop=engine.stop,userInfo={get uname(){},get balance(){return engine.getBalance}};engine.on("script_started",()=>{setTimeout(async()=>{for(;;)engine.nextBet=null,engine.nextResult=null,await engine.emit("GAME_STARTING"),null!==engine.nextBet?(engine.emit("BET_PLACED",{uname:"temp",wager:engine.nextBet.value,payout:engine.nextBet.target}),engine.nextResult=await engine.placeBet(engine.nextBet.value,engine.nextBet.target)):engine.nextResult=await engine.skip(),engine.emit("GAME_STARTED"),"WON"===engine.getLastGamePlay&&engine.emit("CASHE
@dsetzer
dsetzer / results-verifier.js
Created February 9, 2021 23:09
Result verifier adapted for use inside of a bustadice script.
var config = {};
(function (I) {
function w(c, a, d) {
var l = 0, b = [], g = 0, f, n, k, e, h, q, y, p, m = !1, t = [], r = [], u, z = !1; d = d || {}; f = d.encoding || "UTF8"; u = d.numRounds || 1; if (u !== parseInt(u, 10) || 1 > u) throw Error("numRounds must a integer >= 1"); if (0 === c.lastIndexOf("SHA-", 0)) if (q = function (b, a) { return A(b, a, c) }, y = function (b, a, l, f) {
var g, e; if ("SHA-224" === c || "SHA-256" === c) g = (a + 65 >>> 9 << 4) + 15, e = 16; else throw Error("Unexpected error in SHA-2 implementation"); for (; b.length <= g;)b.push(0); b[ a >>> 5 ] |= 128 << 24 - a % 32; a = a + l; b[ g ] = a & 4294967295;
b[ g - 1 ] = a / 4294967296 | 0; l = b.length; for (a = 0; a < l; a += e)f = A(b.slice(a, a + e), f, c); if ("SHA-224" === c) b = [ f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ], f[ 4 ], f[ 5 ], f[ 6 ] ]; else if ("SHA-256" === c) b = f; else throw Error("Unexpected error in SHA-2 implementation"); return b
}, p = function (b) { return b.slice
@dsetzer
dsetzer / default-bab-mart-bustadice.js
Last active January 11, 2023 13:59
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' },
@dsetzer
dsetzer / LD2WD4.js
Last active October 29, 2023 15:42
Simple script I made for bustadice. It bets on 2x, doubles the bet amount on a loss and divides the bet by 4 if it's greater than 8 times the base bet otherwise by 2. It's not a set&forget script, it's risky but more profitable than plain martingale and it's manageable at a slow bet speed.
var config = {
baseBet: { type: 'balance', label: 'Base Bet', value: 128},
betSpeed: { type: 'number', label: 'Bet Speed', value: 800},
maxBet: { type: 'balance', label: 'Max Bet', value: 10000 }
}
Object.entries(config).forEach(c => window[c[0]] = c[1].value);
var s = t => new Promise(r => setTimeout(r, t));
for(let b = baseBet; ;b=Math.max(baseBet, b)){
if (b > maxBet) break;
await this.bet(Math.round(b / 100) * 100, 2).then(r => {
@dsetzer
dsetzer / bustadice-sim-mode-test.js
Last active December 4, 2020 00:45
Probability tester for my bustadice simulator. It will decide at each roll whether to skip or to bet and the game stats are referring to all games both skips/bets while play stats are referring to only the games which were bet on. It's made to test the sim mode and won't place any actual bets unless you turn off sim mode where in that case it wi…
var config = {
simMode: { type: 'checkbox', label: 'Use Sim Mode', value: true },
skipRatio: { type: 'number', label: 'Skip Perc (%)', value: 75 },
payout: { type: 'multiplier', label: 'Target Payout', value: 2 },
};
Object.entries(config).forEach(c => window[c[0]] = eval(c[1].value));
let results = [], wins = 0, loses = 0, games = 0, hits = 0, misses = 0, plays = 0;
if (simMode === true) {
var simBalance = 1000000;
@dsetzer
dsetzer / duration-game-count-v1.js
Last active October 29, 2020 21:21
Utility script for use in bustabit script simulator which outputs the number of games played within a specified duration as well as the average game count.
var config = {
duration: { type: 'number', label: 'Duration (ms)', value: (1000 * 60 * 60)} // default = 1 hour
};
// https://dsetzer.github.io/bustabit-script-simulator/
let games = 0, counts = config.duration.value, avgCounts = [];
engine.on('GAME_ENDED', ()=>{
games++;
if(userInfo.duration > counts){
@dsetzer
dsetzer / bab-results-script-v2.js
Created September 25, 2020 11:06
Outputs game results for specified numer of games, with option to save as a csv file.
var config = {
span: { label: 'Previous Games', type: 'number', value: '100' },
outh: { label: 'Include Hashes', type: 'checkbox', value: false },
ocsv: { label: 'Download CSV', type: 'checkbox', value: true}
};
Object.entries(config).forEach((c) => window[c[0]] = c[1].value);
let hashes = new Map(), lastGame = engine.history.first();
let currentId = lastGame.id, currentHash = lastGame.hash;
let games = new Array();
function downloadString(text, fileName) {
@dsetzer
dsetzer / nteract_npm_install.js
Created September 24, 2020 15:44
npm helper function for nodejs notebooks in nteract
function npm(command){
child_process.exec(`npm ${command}`, (error, stdout, stderr) => {
console.log(stdout);
console.log(stderr);
if (error !== null) console.log(`exec error: ${error}`);
});
}