Skip to content

Instantly share code, notes, and snippets.

@dsetzer
Last active January 15, 2023 14:07
Show Gist options
  • Save dsetzer/5a21f142479e276a9abcc8c8d2df7fed to your computer and use it in GitHub Desktop.
Save dsetzer/5a21f142479e276a9abcc8c8d2df7fed to your computer and use it in GitHub Desktop.
climb3-v1.5 script for dice with included sim mode.
var config = {
baseBet: { label: 'Base Bet', type: 'balance', value: 1000 },
minPayout: { label: 'Target Min', type: 'multiplier', value: 1.08 },
maxPayout: { label: 'Target Max', type: 'multiplier', value: 50.00 },
divPayout: { label: 'Target Div', type: 'multiplier', value: 0.80 },
compRate: { label: 'Compound %', type: 'multiplier', value: 0.02 },
compStep: { label: 'Compound At', type: 'multiplier', value: 1.10 },
betSpeed: { label: 'Bet Speed', type: 'multiplier', value: 100 },
simMode: { label: 'Sim Mode', type: 'checkbox', value: true },
simBal: { label: 'Sim Balance', type: 'balance', value: 1000000 }
};
Object.entries(config).forEach((c) => window[c[0]] = c[1].value);
let currentBet = baseBet, currentPayout = minPayout, lastPayout, baseMulti = 1.005, betMulti = 1.006, origBal = this.balance, gameNum = 1;
let startBal = this.balance, lastBal = startBal, nextBal = startBal * compStep, comp = 0;
const sleep = (ms) => { return new Promise(r => setTimeout(r, ms)); }
if (simMode) {
var simBalance = simBal;
this.balance = simBalance;
origBal = 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;
await sleep(betSpeed);
let result = { id: id, timestamp: timestamp, value: value, target: target, multiplier: multiplier, balance: this.balance, bankroll: Infinity };
return resolve(result);
}).catch((r) => { throw new Error(r); });
}
}
for (; ;) {
let logMsg = `[#${gameNum}]Bet ${Math.round((currentBet + comp) / 100).toFixed(2)} bits @ ${currentPayout.toFixed(2)}x. `;
const result = await this.bet(Math.round((currentBet + comp) / 100) * 100, currentPayout);
logMsg += `Rolled ${result.multiplier}x and `;
if (result.multiplier < currentPayout) {
logMsg += `lost ${(result.value / 100).toFixed(2)} bits wager. `;
if (currentPayout >= maxPayout) {
lastPayout = currentPayout, currentPayout *= (1 - divPayout);
currentBet *= (lastPayout / (currentPayout - 1));
} else { currentPayout += baseMulti, currentBet *= betMulti; }
} else {
logMsg += `won ${(result.value * (result.target - 1) / 100).toFixed(2)} bits profit. `;
currentPayout = minPayout, currentBet = baseBet;
if (this.balance >= nextBal) {
comp = 0, nextBal = (lastBal * compStep)
} else { comp = (this.balance - lastBal) * compRate, lastBal = this.balance; }
}
logMsg += `(Balance: ${(this.balance / 100).toFixed(2)}, Profit: ${((this.balance - origBal) / 100).toFixed(2)} bits)`;
this.log(logMsg); gameNum++;
await sleep(betSpeed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment