-
-
Save dsetzer/cd844cc475b906efda5a6b3e1738c521 to your computer and use it in GitHub Desktop.
/************* 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. | |
2. Proper logging is required in the script otherwise this is pointless, since bets | |
won't appear in your history, or chart, and your balance won't change at all, this | |
is also included but again disabled by default, just enable the SIM_MODE_LOGS setting. | |
3. This is minimal, and merely replaces the bet and skip functions, the rest of the | |
api functions are untouched and will behave like they normally would. And also to be | |
clear these is not the exact same algorithm used in the game, but it does provide | |
the same probabilities and has been tested to ensure the median is correctly 1.98x. | |
/*****************************************/ | |
const SIM_MODE_ENABLE = true; | |
const SIM_MODE_BALANCE = 1000000; // Satoshis | |
const SIM_MODE_SLEEP = false; | |
const SIM_MODE_LOGS = false; | |
/*****************************************/ | |
if (SIM_MODE_ENABLE) { | |
var simBalance = SIM_MODE_BALANCE; | |
var sleep = ms => new Promise(r => setTimeout(r, ms)); | |
this.balance = simBalance; | |
this.bet = (value, target) => { | |
if (this.balance !== simBalance) this.balance = simBalance; | |
return new Promise(async (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 (this.balance && this.balance < value) return reject("insufficient balance"); else if (!this.balance) this.balance = 0; | |
let id = (++this.fid || (this.fid = 0, 0)), timestamp = new Date().toDateString(); | |
let multiplier = Math.round(Math.max(1, (0.99 / Math.random())) * 1e2) / 1e2; | |
if (multiplier < target) { this.balance -= value; } else { this.balance += value * (target - 1); } | |
simBalance = this.balance; | |
if (SIM_MODE_SLEEP) await sleep(100); | |
let result = { id: id, timestamp: timestamp, value: value, target: target, multiplier: multiplier, balance: this.balance, bankroll: Infinity }; | |
if (SIM_MODE_LOGS) await this.log(JSON.stringify(result)); | |
return resolve(result); | |
}).catch((r) => { throw new Error(r); }); | |
} | |
this.skip = () => { | |
return new Promise(async (resolve, reject) => { | |
let id = (++this.fid || (this.fid = 0, 0)), timestamp = new Date().toDateString(); | |
let multiplier = Math.round(Math.max(1, (0.99 / Math.random())) * 1e2) / 1e2; | |
if (SIM_MODE_SLEEP) await sleep(100); | |
let result = { id: id, timestamp: timestamp, multiplier: multiplier, balance: this.balance, bankroll: Infinity }; | |
if (SIM_MODE_LOGS) await this.log(JSON.stringify(result)); | |
return resolve(result) | |
}); | |
} | |
} |
.can you tell, how similar is it to the outcome, that is given out by a seed in dice. is it same , or is there any difference.
I mean if i use this simulations data to analyze the original, or test a script how much. can i trust those results
It's been tested for a large number of games and stabilizes at the expected 1.98x median and even though results are generated in a different way it uses the exact same probabilities as bustadice and bustabit and I've made a test script which takes additional statistics on the probabilities and outputs them which might make it a little easier to visualize and verify it here
---------------------------------------------
Games: 2065, Skips: 500, Plays: 1565 [75.79%], Median: 1.98
Game Stats (Hits: 1024 (49.59%), Misses: 1041 (50.41%), Expected: 49.50%/50.50%)
Play Stats (Wins: 775 (49.52%), Loses: 790 (50.48%), Expected: 49.50%/50.50%)
---------------------------------------------
Short answer is yes, the results this gives are the same as the real ones.
you are right about the median.... you are also right about, it being not similar in the way payout is decided..... i tested, my script with it many times the simulation gave me mostly 8 or 9 wins out of 10 games, but when tested on the real dice the win rate is a little low and mostly takes more rolls to reach the desired outcome [ i am not talking about the speed of bets].
But the sim mode is really useful in figuring out any mistakes in my own script before making an actual play and thank you for that.
One more thing i wanted to add was if you could add a function, which could also allow a seed change it would be much cool.... the script is really good as it is, so thanks again
.can you tell, how similar is it to the outcome, that is given out by a seed in dice. is it same , or is there any difference.
I mean if i use this simulations data to analyze the original, or test a script how much. can i trust those results