Skip to content

Instantly share code, notes, and snippets.

@thaolt
Last active October 11, 2022 23:49
Show Gist options
  • Save thaolt/74cf9e4f191ffd66e475113d45af2bdf to your computer and use it in GitHub Desktop.
Save thaolt/74cf9e4f191ffd66e475113d45af2bdf to your computer and use it in GitHub Desktop.
const maxes = [4,4,5,5,5,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,9,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,41,41,41,41,41,42,42,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,44,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,66,66,66,66,66,66,66,66,66,66,66,66,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,81,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,88,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,91,91,91,91,91,91,91,91,91,92,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,107,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120];
var config = {
riskBankroll: { label: "risk bankroll (%)", value: '100', type: "number" },
riskLevel: { label: "risk level", value: '8', type: "number" },
};
function main()
{
const initialBankroll = currency.amount;
let streaks = Array(900).fill(0);
let streaksInit = false;
let onChase = false;
let chaseFund = 0;
let chaseLosses = 0;
let chaseStreak = 0;
let chaseMax = 0;
let chasePayout = 0;
let chaseStartBet = 0;
let chaseBet = 0;
let wagerBet = 0;
let riskLevel = config.riskLevel.value;
let currentBet = 0;
const updateStreak = function (r) {
const i = (r > 1000 ? 1000 : r) - 100;
for (let x = 0; x < 900; x++) {
if (x + 1 <= i)
streaks[x] = 0;
else
streaks[x]++;
}
}
const computeBets = function(i) {
chasePayout = (101 + i) / 100;
chaseMax = maxes[i] - streaks[i] + 1;
chaseFund = Math.floor(initialBankroll * (config.riskBankroll.value / 100));
chaseStartBet = (chaseFund/((1+(1/(chasePayout-1)))**chaseMax)/chasePayout)/(chasePayout-1);
chaseStreak = 1;
chaseLosses = 0;
chaseBet = (chaseLosses + (chaseStreak*(chaseStartBet*(chasePayout - 1))))/(chasePayout - 1);
wagerBet = (chaseStartBet * (chasePayout - 1))*50;
currentBet = wagerBet + chaseBet;
}
const resolveBet = function (pay) {
if (pay > 0) {
onChase = false;
chaseStreak = 0;
currentBet = 0;
} else {
chaseLosses += chaseBet;
chaseStreak += 1;
chaseBet = (chaseLosses + (chaseStreak*(chaseStartBet*(chasePayout - 1))))/(chasePayout - 1);
currentBet = wagerBet + chaseBet;
}
}
game.onBet = function() {
if (!streaksInit) {
streaksInit = true;
for (let i = 19; i >= 0; i--) {
updateStreak(game.history[i].crash);
}
} else {
updateStreak(game.history[0].crash);
}
if (!onChase) {
for (let i = 900; i >= 0; i--) {
if (streaks[i] >= Math.ceil(maxes[i]/riskLevel)) {
onChase = true;
computeBets(i);
break;
}
}
}
if (currentBet > 0) {
game.bet(currentBet, chasePayout).then(resolveBet);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment