Created
January 23, 2019 17:31
-
-
Save ruzli/fb88d1cc54aa733503b0e73cd06c64b6 to your computer and use it in GitHub Desktop.
In-game Emulator
This file contains 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
/* Simulated script */ | |
var baseBet = 100 // how many satoshis to bet initially | |
var target = 25.4 // target multiplier | |
var betMultiplier = 1.05 // what to multiply the bet size by when we lose a wager | |
var balance = 50000 /* Simulated Balance */ | |
var drop_after_streak = 100 /* Drop bet size after this value. 0 to disable */ | |
var proximity = 1.0 | |
var STW = 10 | |
//*********** | |
let minProfit = -balance | |
let maxProfit = 30000 | |
let ms_interval = 0 | |
let starting_game_with_STW = true | |
//*********** | |
let lossCount = 0 | |
let rolls = 0 | |
let LS = 0 | |
let max_streak = 0 // Max known streak | |
let roll = 0 // Current streak | |
let output = "" | |
let play = false | |
let profit = 0 | |
this.log(`Balance: ${balance}.`) | |
this.log(`Target: ${target}, BaseBet: ${baseBet / 100}, multiplier: ${betMultiplier}, proximity: ${proximity}, STW: ${STW}, drop: ${drop_after_streak}`) | |
let engine = this | |
await sleep(1000) | |
if (!starting_game_with_STW){ | |
LS= STW | |
} | |
while (true) { | |
rolls++ | |
CheckStoppers() | |
if (balance < betSize(lossCount) / 100) { | |
await this.stop() | |
} else { | |
engine.clearLog() | |
if (play) { | |
output = `Rolls: ${rolls}, MaxStreak: ${max_streak}, Balance: ${Math.round(balance)}, Streak: ${roll}, STW ${LS}/${STW}, Bet: ${betSize(lossCount) / 100}, Income: ${Math.round(profit)}, PLAYING` | |
} else { | |
output = `Rolls: ${rolls}, MaxStreak: ${max_streak}, Balance: ${Math.round(balance)}, Streak: ${roll}, STW ${LS}/${STW}, Bet: ${betSize(lossCount) / 100}, Income: ${Math.round(profit)}, SKIPPING` | |
} | |
engine.log(output) | |
} | |
/* [WAGER][TARGET][OUTCOME][PROFIT] */ | |
var { multiplier } = await this.bet(100, 1.01) | |
await game_play(multiplier) | |
await sleep(ms_interval) | |
} | |
async function game_play(multiplier) { | |
if (LS >= STW) { | |
play = true | |
} else { | |
play = false | |
} | |
if (multiplier >= target) { | |
LS = 0 | |
} else { | |
LS++ | |
} | |
if (roll > max_streak) { | |
max_streak = roll | |
} | |
if (play) { | |
CheckConditions() | |
if (multiplier < target) { /* [LOSS] */ | |
await do_lose() | |
} else { /* [WON] */ | |
await do_win() | |
} | |
} | |
} | |
function CheckConditions() { | |
do_drop_max_streak() | |
do_proximity_drop() | |
} | |
function betSize(lossCount) { | |
const bet = baseBet * Math.pow(betMultiplier, lossCount) | |
return Math.round(bet / 100) * 100 | |
} | |
function do_update(multiplier) { | |
if (multiplier >= target) { | |
LS = 0 | |
} | |
if (LS >= STW) { | |
play = true | |
} else { | |
play = false | |
} | |
if (roll > max_streak) { | |
max_streak = roll | |
} | |
return | |
} | |
async function do_drop_max_streak() { | |
if (roll >= drop_after_streak && drop_after_streak != 0) { | |
lossCount = 0 | |
roll = 0 | |
LS = 0 | |
engine.log(`Drop After Streak, resetting bet to base`) | |
await sleep(500) | |
} | |
return | |
} | |
async function do_proximity_drop() { | |
if (proximity < 1.0) { | |
if (Math.min(1, (multiplier / target)) >= proximity) { | |
lossCount = 0 | |
roll = 0 | |
LS = 0 | |
engine.log(`Proximity, dropping streak`) | |
await sleep(500) | |
} | |
return | |
} | |
} | |
async function do_win() { | |
//this.log(`[WINS] ${betSize(lossCount) / 100} ${target}x ${multiplier}x Ƀ ${betSize(lossCount)*target / 100}`) | |
engine.log(`[WINS][${target} * ${betSize(lossCount) / 100} = ${Math.round((betSize(lossCount) * (target - 1)) / 100)} bits]`) | |
balance = balance + (betSize(lossCount) * target) / 100 | |
profit = profit + Math.round(((betSize(lossCount) * (target - 1)) / 100)) | |
engine.log(`${Math.round((betSize(lossCount) * target) / 100)}`) /* For parse */ | |
roll = 0 | |
LS = 0 | |
lossCount = 0 | |
await sleep(500) | |
return | |
} | |
function do_lose() { | |
balance = balance - betSize(lossCount) / 100 | |
profit = profit - betSize(lossCount) / 100 | |
//this.log(`[LOST] ${betSize(lossCount) / 100} ${target}x ${multiplier}x -Ƀ ${betSize(lossCount) / 100}`) | |
engine.log(`[LOST][-${Math.round(betSize(lossCount) / 100)}]`) | |
//engine.log(`${Math.round(betSize(lossCount) / 100)}`) /* For parse */ | |
roll++ | |
lossCount++ | |
return | |
} | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)) | |
} | |
function CheckStoppers() { | |
if (profit > maxProfit || profit - (betSize(lossCount) / 100) < minProfit) { | |
output = `Rolls: ${rolls}, MaxStreak: ${max_streak}, Balance: ${Math.round(balance)}, Streak: ${roll}, STW ${LS}/${STW}, Bet: ${betSize(lossCount) / 100}, Income: ${Math.round(profit)}, STOPPED` | |
engine.log("Triggered stop minProfit or maxProfit") | |
engine.log(output) | |
engine.stop() | |
} | |
} | |
/*var config = { | |
baseBet: { value: 100, type: 'balance', label: 'Base Bet' }, | |
target: { value: 25.4, type: 'multiplier', label: 'Target' }, | |
betMultiplier: { value: 1.05, type: 'multiplier', label: 'Base Multiplier' }, | |
balance: { value: 5000000, type: 'balance', label: 'Simulated balance' }, | |
drop_after_streak: { value: 160, type: 'text', label: 'Rolls before drop after streak' }, | |
proximity: { value: 1.0, type: 'multiplier', label: 'Proximity' }, | |
STW: { value: 20, type: 'text', label: 'Streak to wait' }, | |
minProfit: { value: -10000000, type: 'balance', label: 'minProfit' }, | |
maxProfit: { value: 10000000, type: 'balance', label: 'maxProfit' }, | |
ms_interval: { value: 0, type: 'text', label: 'Pause between rolls' }, | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment