Skip to content

Instantly share code, notes, and snippets.

@dsetzer
dsetzer / diceBetSimulate.js
Last active May 10, 2020 13:28
Replaces the bet function with one that provides authentic results at no cost.
this.bet = (value, target, balance) => {
return new Promise((resolve, reject) => {
if (value % 100 != 0) return reject("bet size must be evenly divisible by 100");
if (value < 100) return reject("bet size must be at least 100 (= 1 bit)");
if (target < 1.01 || target > 1e6) return reject("target multiplier must be between 1.01 and 1,000,000");
if (balance && balance < value) return reject("insufficient balance"); else if(!balance) balance = 0;
let id = (++this.fid || (this.fid = 0, 0)), timestamp = new Date().toDateString();
let multiplier = Math.round(Math.min(Math.max(1, (0.99 / Math.random())), 1e6) * 1e2) / 1e2;
if(multiplier < target) { balance -= value; } else { balance += value * (target - 1); }
return resolve({id, timestamp, value, target, multiplier, balance, bankroll: Infinity});
@dsetzer
dsetzer / ProbRunMulti.js
Last active June 10, 2020 05:21
Iterative run streak probability. [Possibly incorrect, if any math genius sees a flaw please let me know!]
// Probability of 1,2,3,...s or more streaks of r or more consecutive heads in n tosses
// of a coin having probability p of heads. Returns s values.
//
// P(j, i) = P(j, i - 1) + [P(j-1, i-r-1) - P(j, i-r-1)] * (1-p)p^r, for i > j*(r+1) - 1
//
// P(j, i) = p^(jr) * (1-p)^(j-1), for i = j*(r+1) - 1
//
// P(j, i) = 0, for i < j*(r+1) - 1
//
// P(0, i-r-1) = 1
@dsetzer
dsetzer / ProbRun.js
Last active November 8, 2021 18:26
Iterative run probability
// Probability of a r or more consecutive heads in n tosses
// of a coin having probability p of heads
// P(i) = P(i-1) + [1 - P(i-r-1)] * (1-p)p^r, for i > r
// P(r) = p^r
// P(i) = 0, for i < r
// where i is the flip.
// P is implemented as a circular array prob of size 0:r.
function ProbRun(n, r, p) {
let prob = [r], iter, last, i, j;
let c = (1 - p) * Math.pow(p, r);
/**
* BustabitAudio class
*/
(function () {
window.BustabitAudio = function () {
this.audio = {
won: new Audio("https://www.soundjay.com/misc/small-bell-ring-01a.mp3"),
lost: new Audio("http://www.freesfx.co.uk/rx2/mp3s/5/16873_1461333020.mp3")
};
this.audio.won.volume = 0.5;
var config = {
};
/*
~~~~~~ Krampus v11 final ~~~~~~
~~ gamblebot for Bustabit.com
~ a fork of CorpseKey v8-prealpha
~~ by MathWins aka Gambletron5000 aka Neti
CHANGABLE SETTING(s) NOT TESTED, BEWARE CHANGING
@dsetzer
dsetzer / result_dumper.js
Created April 26, 2020 04:17
Converts bustabit script simulator into a roll generator. Just set the ending hash and number of games.
var results = [];
engine.on('GAME_ENDED', function() {
results.push(engine.history.first().bust);
dumpResults(results);
})
var dumpResults = (function() {
'use strict';
var timeWindow = 100;
var timeout;
@dsetzer
dsetzer / oscars-v2-universal.js
Last active May 7, 2020 17:30
Proof of concept Oscar's Grind script fully functional universal compatibility playable on both bustabit & bustadice as well as simulators no modification needed.
var config = {
i: { type: 'noop', label: 'Oscar\'s Grind V2 Universal'},
a: { type: 'balance', label: 'Unit Size', value: 1000 },
c: { type: 'number', label: 'Bet Speed', value: 100 }
};
Object.entries(config).forEach(c=>window[c[0]]=c[1].value);
var dice = (()=>{try{engine==true;return !1;}catch(e){return !0;}})();
var sleep = t => new Promise(r => setTimeout(r, t)), b=1.98, d=a, e=0;
var round = b => Math.max(100, Math.round(b / 100) * 100);
var next = r => {r<b?e-=d:(e+=d,e<a&&(d=e+d+a>a?a-e:d+a),e>=a&&(e=0,d=a))};
@dsetzer
dsetzer / speed-test.js
Last active March 18, 2020 01:06
Testing async throughput in bustadice
let betCount = 0;
let totalOut = 0;
let totalIn = 0;
let queueSize = 200
let queue = new Array(queueSize);
let running = true;
const doResult = async function (context, result) {
totalIn++;
context.log(`Current Bets IN/OUT ${totalIn}/${totalOut} | Total Bets ${betCount}`);
}
@dsetzer
dsetzer / climb3-v1.5-dice.js
Last active August 17, 2020 06:03
Upgrade from climb-v2 script with more customization, compounding, and halving feature for bustadice.
var config = {
baseBet: { label: 'Base Bet', type: 'balance', value: 1000 },
minPayout: { label: 'Target Min', type: 'multiplier', value: 1.08 },
maxPayout: { label: 'Target Max', type: 'multiplier', value: 50.00 },
divPayout: { label: 'Target Div', type: 'multiplier', value: 0.80 },
compRate: { label: 'Compound %', type: 'multiplier', value: 0.02 },
compStep: { label: 'Compound At', type: 'multiplier', value: 1.10 },
betSpeed: { label: 'Bet Speed', type: 'multiplier', value: 100 }
};
Object.entries(config).forEach((c) => window[c[0]] = c[1].value);
@dsetzer
dsetzer / bab-sniper-v1.js
Last active March 9, 2024 23:08
some bustabit automatic sniper scripts I made a long time ago
var config = {};
var StartingBet = 50000; //(INTEGER) Initial bet in satoshis. (100 * 100 = 100 bits = 10,000 satoshi)
var AutoCashout = 2000; //(INTEGER) Will Cashout at 20x if the highest bet didn't cashed out yet.
var IncreaseOnLoss = 1.5; //(FLOAT) Will increase +1.30x of the last bet if lost.
var simulate = true;
var simWager = 0;
var simCashed = 0;
var simBalance = 5000 * 100;