This file contains hidden or 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
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}`); | |
}); | |
} |
This file contains hidden or 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: { 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 } |
This file contains hidden or 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
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); |
This file contains hidden or 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 = { | |
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)); |
This file contains hidden or 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
// 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. |
This file contains hidden or 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
/************* 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. |
This file contains hidden or 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
#! /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 |
This file contains hidden or 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
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}); |
This file contains hidden or 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
// 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 |
This file contains hidden or 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
// 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); |