Skip to content

Instantly share code, notes, and snippets.

@zundra
Last active June 30, 2021 17:50
Show Gist options
  • Save zundra/9c7fdae31575db949b6bec2c16306400 to your computer and use it in GitHub Desktop.
Save zundra/9c7fdae31575db949b6bec2c16306400 to your computer and use it in GitHub Desktop.
var config = {
baseBet: { value: 100, type: "balance", label: "base bet" },
payout: { value: 2, type: "multiplier" },
stop: { value: 1e8, type: "balance", label: "stop if bet >" },
bust_threshold: { value: 2, type: "multiplier", label: "Count busts below this value and bet after <n> busts" },
bust_threshold_limit: { value: 5, type: "multiplier", label: "How many busts to track below threshold before betting" },
loss: {
value: "increase",
type: "radio",
label: "On Loss",
options: {
base: { type: "noop", label: "Return to base bet" },
increase: { value: 2, type: "multiplier", label: "Increase bet by" },
},
},
win: {
value: "base",
type: "radio",
label: "On Win",
options: {
base: { type: "noop", label: "Return to base bet" },
increase: { value: 2, type: "multiplier", label: "Increase bet by" },
},
},
};
var stateVars = {
bustCountBelowThreshold: 0
};
log("Script is running..");
var currentBet = config.baseBet.value;
// Always try to bet when script is started
//engine.bet(roundBit(currentBet), config.payout.value);
engine.on("GAME_STARTING", onGameStarted);
engine.once("GAME_STARTING", () => engine.on("GAME_ENDED", onGameEnded));
function onGameStarted() {
log("The current bust count is ", stateVars.bustCountBelowThreshold);
log("The current bust limit is ", config.bust_threshold_limit.value);
if (stateVars.bustCountBelowThreshold >= config.bust_threshold_limit.value)
{
engine.bet(roundBit(currentBet), config.payout.value);
}
}
function onGameEnded() {
var lastGame = engine.history.first();
// Count busts occurranances below a threshold value.
if (lastGame.bust <= config.bust_threshold.value)
{
stateVars.bustCountBelowThreshold++;
}
else
{
stateVars.bustCountBelowThreshold = 0;
}
if (!lastGame.wager) {
return;
}
// we won..
if (lastGame.cashedAt) {
stateVars.bustCountBelowThreshold = 0; // Reset threshold watch
if (config.win.value === "base") {
currentBet = config.baseBet.value;
} else {
console.assert(config.win.value === "increase");
currentBet *= config.win.options.increase.value;
}
log("We won, so next bet will be", currentBet / 100, "bits");
} else {
// damn, looks like we lost :(
if (config.loss.value === "base") {
currentBet = config.baseBet.value;
} else {
console.assert(config.loss.value === "increase");
currentBet *= config.loss.options.increase.value;
}
log("We lost, so next bet will be", currentBet / 100, "bits");
}
if (currentBet > config.stop.value) {
log("Was about to bet", currentBet / 100, "which triggers the stop");
engine.removeListener("GAME_STARTING", onGameStarted);
engine.removeListener("GAME_ENDED", onGameEnded);
}
}
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment