Skip to content

Instantly share code, notes, and snippets.

@dsetzer
dsetzer / bustadice-bab-demo.js
Last active March 27, 2024 13:45
Bustabit script wrapper for use on bustadice. (proof of concept / demo! extremely minimal bustabit script API functionality)
var config = {
baseBet: { type: 'balance', label: 'Base Bet', value: 100 },
payout: { type: 'multiplier', label: 'Payout', value: 2 }
};
const dcheck = () => { try{ engine.getState() }catch(e){ return true } return false }
const emitter = {
on(name, func){this._s[name] = this._s[name] || []; this._s[name].push(func)},_s:{},
emit(name, ...args){if(!this._s[name]){return; } this._s[name].forEach(f=>f(...args))}
}
const dice = dcheck();
@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;
@dsetzer
dsetzer / bet-utils.js
Last active November 16, 2023 03:04
A few martingale oriented inverse utility functions.
/**
* Calculates the base bet from the current wager, multiplier, and streak.
*
* @param {number} wager - The current wager.
* @param {number} multi - The multiplier.
* @param {number} streak - The streak.
* @returns {number} - The calculated base bet.
*/
const getBaseBetFromCurrent = (wager, multi, streak) => (wager / (multi ** streak));
@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 / prob_using_coefficients.py
Last active August 17, 2023 16:16
Calculating probabilities with coefficients calculated from simulations
import hmac
import hashlib
import binascii
import math
from collections import Counter
from scipy.optimize import curve_fit
import numpy as np
# Number of games to simulate (10 million)
num_games_to_simulate = 10_000_000
@dsetzer
dsetzer / StreakSegment.js
Last active June 18, 2023 16:14
Function to split up an array into separate groups of W/L streaks.
/**
* Takes in an array of numbers and returns an array of streaks of numbers.
* @param {Array} results - An array of numbers.
* @param {Number} multiplier - The number that determines the streak.
* @returns {Array} - An array of streaks of numbers.
*/
function getStreaks(results, multiplier) {
let streaks = new Array();
let streak = new Array();
for (let i = 0; i < results.length; i++) {
@dsetzer
dsetzer / accurate-payout-sniper.js
Last active May 31, 2023 18:50
Modified version of the sniper script which uses the same payout as the target player bet rather than just waiting for their cashout (which causes a few ms delay)
var config = {
target: { value: '', type: 'text', label: 'User to follow' },
};
log('Script is running..');
engine.on('BET_PLACED', (bet) => {
if (bet.uname == config.target.value) {
if (userInfo.balance < 100) {
log('You have a balance under 1 bit, you can not bet');
const baseBet = 1 * 100 // how many satoshis to bet initially
const target = 1.75 // target multiplier
const betMultiplier = 3.06 // what to multiply the bet size by when we lose a wager
const MAX_BET = 2000 * 100 // maximum bet amount to stop script at (satoshis)
const MAX_GAMES = -1 // maximum number of games to play before stopping (set to -1 for unlimited)
const BET_SPEED = 500 // time between bets in (ex 500 = 500ms = 0.5s)
let lossCount = 0
this.log(`Starting martingale with a base bet of ${baseBet/100} bits.`)
@dsetzer
dsetzer / run-length-compression.js
Created May 24, 2023 02:50
RunLength Encoding (RLE) text compression using Unicode symbols
/**
* Run-Length Encoding (RLE) text compression using Unicode symbols.
*
* This algorithm compresses text by counting the number of consecutive identical
* characters in the input string and representing them in a compact format within
* the compressed string using Unicode characters. The encoded and decoded parts
* are separated by a Unicode private-use character, U+FFF0.
*
* @param {string} inputText - The text to be compressed.
* @returns {string} - The compressed text.
@dsetzer
dsetzer / mapRange.js
Created April 29, 2023 05:43
Map a value from one range to another range
/**
* Map a value from one range to another
* @param {number} value - The value to map
* @param {number} inMin - The minimum value of the input range
* @param {number} inMax - The maximum value of the input range
* @param {number} outMin - The minimum value of the output range
* @param {number} outMax - The maximum value of the output range
* @returns {number} The mapped value
*/
const mapRange = (value, inMin, inMax, outMin, outMax) => {