Skip to content

Instantly share code, notes, and snippets.

@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}`);
});
}
@dsetzer
dsetzer / climb3-v1.5-sim-dice.js
Last active January 15, 2023 14:07
climb3-v1.5 script for dice with included sim mode.
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 },
simMode: { label: 'Sim Mode', type: 'checkbox', value: true },
simBal: { label: 'Sim Balance', type: 'balance', value: 1000000 }
@dsetzer
dsetzer / cartesian-combos.js
Created July 31, 2020 19:39
Generate all possible parameter combinations using cartesian product.
function cartesian(...args) {
let r = [], max = args.length - 1;
let step = (arr, i) => {
for (let j = 0, l = args[i].length; j < l; j++) {
let a = arr.slice(0);
a.push(args[i][j]);
if (i === max) r.push(a); else step(a, i + 1);
}
}
step([], 0);
@dsetzer
dsetzer / bab-results-script.js
Created July 15, 2020 18:00
Generates previous games from within the script.
var config = {
span: { label: 'Previous Games', type: 'number', value: '100' },
outh: { label: 'Print Hashes', type: 'checkbox', value: false }
};
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;
for(let i = currentId, result, len = currentId - span; i >= len; i--){
hashes.set(i, String(currentHash));
currentHash = SHA256((currentHash));
@dsetzer
dsetzer / decimalExpansion.js
Created July 13, 2020 17:24
decimal expansion function
// borrowed from jQuery 1.7.2
var isNumeric = function(val){
return !isNaN(parseFloat(val)) && isFinite(val);
};
/**
* @author Larry Battle <http://bateru.com/news/contact-me>
* @date May 16, 2012
* @license MIT and GPLv3
*/
//decimalExpansion returns a string representation of a divided by b to a fixed length.
@dsetzer
dsetzer / bustadice-sim-mode.js
Last active October 30, 2020 20:41
Sim mode for bustadice based on my previous diceBetSimulate gist but easier to drop into a script and instructions.
/************* INSTRUCTIONS *************
Place it into a script right below the config section at the top and it will replace
the bet/skip function with mock functions which don't interact with the server.
A few points to note:
1. Latency won't exist with these, and results are returned almost instantly, this
could cause the browser to freeze up or make the script unobservable unless the
script includes a sleep or bet delay function. For convenience there's one included
but disabled by default, just enable the SIM_MODE_SLEEP setting.
#! /usr/bin/env python3
## NAME: duration.py
## USAGE: From shell prompt: python3 duration.py
## or within interactive python3 environment, import filename
## REQUIRED ARGUMENTS: none
## OPTIONS: none
## DESCRIPTION: Experiment to measure duration
## of random walk of n steps done k times each,
## starting from each value from ruin to victory,
## continuing until reaching either ruin or victory