var pout = 2; var minloss = 100; function debounce(func, wait, immediate) { var timeout; return function executedFunction() { var context = this; var args = arguments; var later = function() { timeout = null; if (!immediate) func.apply(context, args); }; var callNow = immediate && !timeout; clearTimeout(timeout); timeout = setTimeout(later, wait); if (callNow) func.apply(context, args); }; }; function roundUp(num, precision) { return Math.ceil(num * precision) / precision } function calculatorupdate() { var chance = parseFloat($("#tx_chance").val()).toFixed(8); var raise = parseFloat($("#tx_loss").val()).toFixed(8); var startBank = parseFloat($("#tx_bank").val()).toFixed(8); var curBank = parseFloat($("#tx_bank").val()).toFixed(8); var curBet = $("#tx_amount").val(); var odds = 0; if (chance > 0 && raise > 0 && curBank > 0 && curBet > 0) { pout = (98 / chance); $("#tx_payout").html(pout.toFixed(4)); minloss = (100 / (pout - 1) + 19); $("#tx_minLoss").html(roundUp(minloss, 10000)); var curRaise = 1 + raise / 100; var nBet = 1; var win = parseFloat(0).toFixed(8); var betSum = parseFloat(0).toFixed(8); var profit = parseFloat(0).toFixed(8); var bankPercent = 0; if ($("#results").length) $("#results").remove(); $("
#BetSum of Bets of BankBank After LossWinProfit Odds of Losing Streak
").insertAfter("#config"); while (curBank > curBet) { curBank = parseFloat(curBank - curBet).toFixed(8); if (nBet > 1) { curBet = curBet * curRaise; odds = odds * (100 - chance) / 100; } else { odds = 100 - parseInt(chance); } betSum = (parseFloat(betSum) + parseFloat(curBet)).toFixed(8); bankPercent = betSum / startBank * 100; win = parseFloat(curBet * parseFloat($("#tx_payout").html())).toFixed(8); profit = parseFloat(win - betSum).toFixed(8); var posNegClass = profit > 0 ? 'pos' : 'neg'; $('#data > tbody:last').append('' + nBet + '' + parseFloat(curBet).toFixed(8) + '' + betSum + '' + bankPercent.toFixed(3) + '' + curBank + '' + win + '' + profit + '' + odds.toLocaleString('fullwide', { useGrouping: true, maximumSignificantDigits:6}) + ''); nBet += 1; curBank = curBank - curBet; } $('#data > tbody:last').append('' + nBet + '' + parseFloat(curBet * curRaise).toFixed(8) + 'Broker Broke Your Bank'); $("#summary").html("Your strategy supports " + (nBet - 1).toString() + " Losses

A persistence of this strategy is " + ((nBet - 1) / parseFloat($("#tx_payout").html())).toFixed(1) + " (Higher is better)"); } } $("#tx_chance").keyup(debounce(calculatorupdate, 550)); $("#tx_chance").change(debounce(calculatorupdate, 550)); $("#tx_bank").keyup(debounce(calculatorupdate, 550)); $("#tx_amount").keyup(debounce(calculatorupdate, 550)); $("#tx_loss").keyup(debounce(calculatorupdate, 550));