Skip to content

Instantly share code, notes, and snippets.

@dsetzer

dsetzer/bab-sniper-v1.js

Last active Apr 2, 2021
Embed
What would you like to do?
some bustabit automatic sniper scripts I made a long time ago
var config = {};
var StartingBet = 50000; //(INTEGER) Initial bet in satoshis. (100 * 100 = 100 bits = 10,000 satoshi)
var AutoCashout = 2000; //(INTEGER) Will Cashout at 20x if the highest bet didn't cashed out yet.
var IncreaseOnLoss = 1.5; //(FLOAT) Will increase +1.30x of the last bet if lost.
var simulate = true;
var simWager = 0;
var simCashed = 0;
var simBalance = 5000 * 100;
so
//--------> EDIT OVER THIS LINE <--------
var currentBet = StartingBet;
var lastBet = currentBet;
var currentPayout = AutoCashout;
var bans = [];
var targets = {};
var bets = [];
var highestBetUser = null;
engine.on('GAME_STARTING', function(info) {
log("Locking target...");
engine.bet(currentBet, currentPayout);
simBalance -= currentBet;
simWager = currentBet;
simCashed = currentPayout;
});
engine.on('GAME_STARTED', function() {
//bets = []; // Reset bets
var max = 0;
for(var i in bets) {
var bet = bets[i];
if(bet.wager > max){
max = bet.wager
highestBetUser = bet.uname; // Get the highest one!
}
}
log("Target acquired! ("+highestBetUser+":"+targets[highestBetUser].score+")");
});
engine.on('GAME_ENDED', function(data) {
var lastGame = engine.history.first();
if ((simulate && !simWager) && !lastGame.wager) {
return;
}
if ((simulate && simWager && simCashed <= lastGame.bust) || lastGame.cashedAt) {
simBalance += simulate ? (simWager * simCashed) : 0;
log('We won, so next bet will be', currentBet/100, 'bits');
currentBet = StartingBet;
}else{
currentBet = roundBit(lastBet * IncreaseOnLoss);
log('We lost, so next bet will be', currentBet/100, 'bits');
}
lastBet = currentBet;
bets = [];
targets[highestBetUser].score--;
if(targets[highestBetUser].score <= -2){
bans.push(highestBetUser);
log("Blacklisting target ("+highestBetUser+")");
currentBet = StartingBet
}
});
engine.on('BET_PLACED', function(bet) {
if(!targets[bet.uname]){
targets[bet.uname] = {score: 0};
}
if(targets[bet.uname].score > -2){
bets.push(bet);
}
});
engine.on('CASHED_OUT', function(bet) {
if(bet.uname == highestBetUser){
//setTimeout(function(){ engine.cashOut(); }, 1000);
if(simulate){
simBalance += simWager * (bet.cashedAt + 0.015);
simCashed = bet.cashedAt + 0.015;
log("Simulated Cashout at "+parseFloat(bet.cashedAt+0.015).toFixed(2)+"x : Balance: ", simBalance/100);
}else{
engine.cashOut();
log("Target hit!");
}
targets[highestBetUser].score += 2;
}
});
function roundBit(bet){
return Math.round(bet / 100) * 100;
}
// Some use less function:
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
var config = {};
var baseBet = 300 * 100; // (INTEGER) Initial bet in satoshis. (100 * 100 = 100 bits = 10,000 satoshi)
var basePayout = 5; // (INTEGER) Will Cashout at 20x if the highest bet didn't cashed out yet.
var betMultiplier = 0.8; // (FLOAT) Will increase +1.30x of the last bet if lost.
// --------> EDIT OVER THIS LINE <--------
var currentBet = baseBet;
var recovering = false;
var lastBet = currentBet;
var currentPayout = basePayout;
var targets = {};
var target = null;
var ignored = ['l0rd0s4n', 'jasonvs', 'Zommau', '125okbitcoin', 'minting', '19kvz79', 'dillonmoak1'];
var placedBet = false;
var cashedOut = false;
var scoreStats = { gamesPlayed: 0, gamesWaited: 0, gamesWon: 0, gamesLost: 0, sinceWon: 0, sinceLost: 0, score: 0 };
var bankStats = { startBal: 0, highBal: 0, lowBal: 0, curBal: 0, totalWagered: 0, totalProfit: 0, totalLoss: 0 };
var sumLosses = 0;
bankStats.curBal = userInfo.balance;
bankStats.startBal = bankStats.curBal;
bankStats.highBal = bankStats.curBal;
bankStats.lowBal = bankStats.curBal;
var debug = 2;
engine.on('GAME_STARTING', function (info) {
placedBet = false;
cashedOut = false;
target = null;
setTimeout(placeBet, 3000);
});
function placeBet() {
target = findBestTarget(recovering);
if (target && targets[target]) {
let rec = (sumLosses / targets[target].avgCashout) / 1.8;
let inc = (1 + Math.min(2, Math.max(0, (targets[target].depend + targets[target].sinceLost) * 0.0125)));
if (scoreStats.sinceLost > 0) {
currentBet = roundBit(baseBet + rec);
} else {
currentBet = roundBit((baseBet * Math.pow(betMultiplier, scoreStats.sinceWon)) + rec);
}
if (debug > 0) {
log(`[DEBUG] Bet sized at (${currentBet / 100} base * ${inc} inc) + ${rec / 100} rec`);
}
if (!placedBet) {
log("Acquired target (" + target + " SC: " + targets[target].score + " AVC: " + targets[target].avgCashout + ". Placing bet of ", currentBet / 100, "bits.");
engine.bet(roundBit(currentBet * 1), basePayout);
placedBet = true;
}
}
}
function findBestTarget(safe) {
let c = {
high: { uname: null, max: 0 },
wagered: { uname: null, max: 0 },
profit: { uname: null, max: 0 },
worth: { uname: null, max: 0 },
score: { uname: null, max: 0 },
won: { uname: null, max: 0 },
since: { uname: null, max: 0 },
depend: { uname: null, max: 0 }
};
let vld = [];
for (let u in targets) {
if (targets.hasOwnProperty(u)) {
let t = targets[u];
if (ignored.contains(u) || t.ban > 0 || !t.bet) {
continue;
} else if (safe && (t.won < t.lost || t.sinceWon > 0 || t.profit < t.loss || (t.won + t.lost) < 1)) {
continue;
} else if (!safe && (t.won < t.lost && t.sinceWon > 1) || t.profit < t.loss || t.worth < 100) {
continue;
}
vld.push(u);
if (t.bet.wager > c.high.max) {
c.high.uname = u;
c.high.max = t.bet.wager;
}
if (t.profit > c.profit.max) {
c.profit.uname = u;
c.profit.max = t.profit;
}
if (t.worth > c.worth.max) {
c.worth.uname = u;
c.worth.max = t.worth;
}
if (t.score > c.score.max) {
c.score.uname = u;
c.score.max = t.score;
}
if (t.won > c.won.max) {
c.won.uname = u;
c.won.max = t.won;
}
if (t.sinceLost > c.since.max) {
c.since.uname = u;
c.since.max = t.sinceLost;
}
if (t.depend > c.depend.max) {
c.depend.uname = u;
c.depend.max = t.depend;
}
}
}
if (debug) {
let highstr = `\nHigh:${c.high.uname}[${c.high.max}]`;
let worthstr = `\nWorth: ${c.worth.uname}[${c.worth.max}]`;
let profitstr = `\nProfit: ${c.profit.uname}[${c.profit.max}]`;
let scorestr = `\nScore: ${c.score.uname}[${c.score.max}]`;
let wonstr = `\nWon: ${c.won.uname}[${c.won.max}]`;
let sincestr = `\nSince: ${c.since.uname}[${c.since.max}]`;
let dependstr = `\nDepend: ${c.depend.uname}[${c.depend.max}]`;
if (debug > 0) {
log("[DEBUG] Candidates" + highstr + worthstr + profitstr + scorestr + wonstr + sincestr + dependstr + "");
}
}
let tgt = null;
let cnd = [c.high.uname, c.worth.uname, c.profit.uname, c.score.uname, c.won.uname, c.since.uname, c.depend.uname];
let pts = 0;
for (let v = 0; v < vld.length; v++) {
let u = vld[v];
let t = targets[u];
if (t.score < 2 || t.sinceWon > 2) {
if (debug > 2) { log(`[DEBUG] ${u} NVLD (S${t.score}:P${t.profit}:L${t.loss}:W${t.wagered}:WL${t.won}-${t.lost}:SL${t.sinceLost}:D${t.depend})`); }
continue;
} else {
// let val = Math.min(4, Math.round(t.worth / 100));
let qual = [c.score.uname, c.since.uname, c.depend.uname].count(u);
let val = Math.min(2, qual);
let valstr = `VScore +${val}(Q)`;
if (t.bet.wager < 10000) {
val--;
valstr += "-1Bw";
}
if (!safe && t.bet.payout < 1.11) {
val--;
valstr += "-1Bp)";
}
let qual2 = [c.high.uname, c.worth.uname, c.profit.uname, c.won.uname].count(u);
if (u == c.profit.uname && qual > 0) {
val++;
valstr += "+1(Pr)"
}
if (u == c.high.uname && qual > 0) {
val++;
valstr += "+1(Hi)";
}
if (u == c.worth.uname && qual > 0) {
if (t.sinceLost > 2 || t.depend > 2) {
val += 2;
valstr += "+2(Wo)";
} else {
val++;
valstr += "+1(Wo)";
}
}
// if (u == c.since.uname && c.since.max > 1){
// val += 2;
// valstr += "+2(Si)";
// }else if (t.sinceLost > 2) {
// val++;
// valstr += "+1(Si";
// }
//
// if (t.bet.wager > 50) {
// val++;
// valstr += "+1(Wa)";
// }
// if(t.bet.payout >= 1.5){
// val += 3;
// }else if (t.bet.payout >= 1.2) {
// val += 2;
// }
if (t.avgCashout >= 2) {
val--;
valstr += "-1(AvgC)";
} else if (t.avgCashout > 1.3) {
val += 2;
valstr += "+2(AvgC)";
} else if (t.avgCashout > 1.1) {
val++;
valstr += "+1(AvgC)";
}
// if (t.depend > 1) {
// val++;
// valstr += "+1(D)";
// }
if (debug) {
if (debug > 1) { log(`[DEBUG] ${u} (Value Score: ${val} = ${valstr})`); }
}
if (val > pts) {
tgt = u;
pts = val;
}
}
}
return tgt;
}
engine.on('GAME_STARTED', function () {
if (debug > 0) {
log("Setup " + newEntries + " new targets");
let padding = Array(8).join(' ');
log("--------------- Round Info ---------------");
log("Start Bal : " + pad(padding, bankStats.startBal/100) + " | Current Bal : " + pad(padding, bankStats.curBal/100) + "");
log("Low Bal : " + pad(padding, bankStats.lowBal/100) + " | High Bal : " + pad(padding, bankStats.highBal/100) + "");
log("Games Played : " + pad(padding, scoreStats.gamesPlayed) + " | Games Skipped : " + pad(padding, scoreStats.gamesWaited) + "");
log("Games Won : " + pad(padding, scoreStats.gamesWon) + " | Games Lost : " + pad(padding, scoreStats.gamesLost) + "");
log("Profit : " + pad(padding, (bankStats.totalProfit-bankStats.totalLoss)/100) + " | Wagered : " + pad(padding, bankStats.totalWagered/100) + "");
//log("Wagered : " + pad(padding, bankStats.totalWagered/100) + " |");
// log("Avg Wager : "+pad(padding, avg | Avg Cashout : xxxxxxx bits");
}
});
engine.on('GAME_ENDED', function (data) {
newEntries = 0;
var lastGame = engine.history.first();
for (let uname in targets) {
if (targets.hasOwnProperty(uname)) {
if (targets[uname].bet) {
targets[uname].lastSeen = Date.now();
if (targets[uname].cashed) {
targets[uname].won++;
targets[uname].sinceLost++;
targets[uname].sinceWon = 0;
if (targets[uname].worth >= 100) {
targets[uname].score++;
}
} else {
targets[uname].lost++;
targets[uname].sinceWon++;
targets[uname].sinceLost = 0;
if (targets[uname].worth >= 100) {
targets[uname].score--;
}
targets[uname].loss += targets[uname].bet.wager;
if (targets[uname].score < -1) {
if (targets[uname].score < Math.min(0, (0 - (5 - targets[uname].bans)))) {
targets[uname].bans++;
targets[uname].ban += Math.pow(targets[uname].bans, 4) * 5;
if (debug > 2) { log("Excluding (Name: " + uname + ", Score: " + targets[uname].score + ", Worth: " + targets[uname].worth + ") for " + targets[uname].ban + " turns."); }
}
}
}
targets[uname].bet = null;
targets[uname].cashed = false;
}else{
if(Date.now() - targets[uname].lastSeen > (1000 * (60 * 30))){
targets[uname] = null;
delete targets[uname];
log(`Removing ${uname} from targets for inactivity.`);
}
}
}
}
if (lastGame.wager) {
lastBet = currentBet;
bankStats.totalWagered += lastGame.wager;
bankStats.curBal = userInfo.balance;
if (lastGame.cashedAt) {
scoreStats.score++;
scoreStats.gamesWon++;
scoreStats.sinceWon = 0;
scoreStats.sinceLost++;
let profit = (lastGame.wager * lastGame.cashedAt) - lastGame.wager;
bankStats.totalProfit += profit;
if (sumLosses > 0) {
sumLosses -= profit;
if (sumLosses < 0) {
sumLosses = 0;
}
}
if (target && targets[target]) {
targets[target].depend++;
}
log('We won, next min bet at', currentBet / 100, 'bits : Balance: ', userInfo.balance / 100);
} else {
scoreStats.score--;
scoreStats.gamesLost++;
scoreStats.sinceLost = 0;
scoreStats.sinceWon++;
bankStats.totalLoss += lastGame.wager;
sumLosses += lastGame.wager * targets[target].avgCashout;
if (target && targets[target]) {
// targets[target].ban += 1;
targets[target].depend--;
}
log('We lost, next min bet at', currentBet / 100, 'bits : Balance: ', userInfo.balance / 100);
}
let date = new Date(Date.now()).toLocaleString('en-GB').split(', ');
log(`[GAME SESSION #${engine.gameId} RESULT] - Bet: ${scoreStats.gamesPlayed} | Date: ${date[0]} | Time: ${date[1]} | Wager: ${Math.round(lastGame.wager/100)||0} | Payout: ${lastGame.cashedAt.toFixed(2)||0}| Outcome: ${lastGame.bust} | Result: ${lastGame.cashedAt?'W':'L'} | Target: ${target}`);
if (bankStats.highBal < bankStats.curBal) {
bankStats.highBal = bankStats.curBal;
}
if (bankStats.lowBal > bankStats.curBal) {
bankStats.lowBal = bankStats.curBal;
}
scoreStats.gamesPlayed++;
} else {
scoreStats.gamesWaited++;
}
log("Current Balance:", userInfo.balance / 100, "bits");
for (var u in targets) {
if (targets.hasOwnProperty(u)) {
// if(targets[u].won + targets[u].lost >= 10){
// log(`Clearing out stale target (${u})`);
// targets[u] = null;
// }else{
if (targets[u].history.length > 10) {
let temp = targets[u].history.mean();
targets[u].history = [temp];
}
if (targets[u].cashouts.length > 10) {
let temp = targets[u].cashouts.mean();
targets[u].cashouts = [temp];
}
// }
}
}
});
engine.on('BET_PLACED', function (bet) {
if (bet.uname == userInfo.uname) {
bankStats.totalwagered += bet.wager;
bankStats.curBal = userInfo.balance;
if (bankStats.lowBal > bankStats.curBal) {
bankStats.lowBal = bankStats.curBal;
}
return;
}
if (!targets[bet.uname]) {
if (ignored.contains(bet.uname)) {
return;
}
targets[bet.uname] = {
bet: bet,
cashed: false,
score: 0,
won: 0,
lost: 0,
sinceWon: 0,
sinceLost: 0,
ban: 0,
bans: 0,
depend: 0,
worth: 0,
wagered: 0,
profit: 0,
loss: 0,
history: [],
avgCashout: 0,
cashouts: []
};
targets[bet.uname].history.push(((bet.wager * bet.payout) / bet.wager));
newEntries++;
} else {
targets[bet.uname].bet = bet;
targets[bet.uname].wagered += bet.wager;
}
});
let newEntries = 0;
engine.on('CASHED_OUT', function (bet) {
if (bet.uname == userInfo.uname) {
cashedOut = true;
return;
}
if (targets[bet.uname]) {
if (bet.uname == target && engine.getCurrentBet()) {
log("Target hit at " + parseFloat(bet.cashedAt).toFixed(2) + "x : (Name: " + target + ", Score: " + (targets[target].score + 1) + ", Worth: " + targets[target].worth + ")");
engine.cashOut();
// log(`Cashing out at ${bet.cashedAt}x balance is ${userInfo.balance/100} bits.`);
}
targets[bet.uname].cashed = true;
targets[bet.uname].cashouts.push(bet.cashedAt);
targets[bet.uname].avgCashout = targets[bet.uname].cashouts.mean();
targets[bet.uname].history.push(Math.round((bet.wager * bet.cashedAt) / bet.wager) * 100);
targets[bet.uname].worth = targets[bet.uname].history.mean();
targets[bet.uname].profit += (bet.wager * bet.cashedAt) - bet.wager;
}
});
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
Array.prototype.contains = function (item) {
for (var i in this) {
if (this[i] == item) return true;
}
return false;
}
Array.prototype.max = function () {
return Math.max.apply(null, this);
}
Array.prototype.count = function (item) {
var count = 0;
for (var i = 0; i < this.length; i++) {
if (this[i] === item) {
count++;
}
}
return count;
}
// function count(arr) {
// if(arr){
// if(arr.length >= 1){
// return arr.reduce((prev, curr) => (prev[curr] = ++prev[curr] || 1, prev), {});
// }
// }
// return null;
// }
Array.prototype.mean = function () {
if (this.length >= 1) {
var sum = 0;
for (var i = 0; i < this.length; i++) {
sum += this[i];
}
return (sum / this.length);
}
return -1;
}
Array.prototype.mode = function () {
var modeMap = {};
var maxEl = this[0],
maxCount = 1;
for (var i = 0; i < this.length; i++) {
var el = this[i];
if (modeMap[el] == null) {
modeMap[el] = 1;
} else {
modeMap[el]++;
}
if (modeMap[el] > maxCount) {
maxEl = el;
maxCount = modeMap[el];
}
}
if (maxCount == 1) {
return -1;
}
return maxEl;
}
function pad(pad, str, padLeft) {
if (typeof str === 'undefined')
return pad;
if (padLeft) {
return (pad + str).slice(-pad.length);
} else {
return (str + pad).substring(0, pad.length);
}
}
var config = {};
var baseBet = 100 * 100; //(INTEGER) Initial bet in satoshis. (100 * 100 = 100 bits = 10,000 satoshi)
var basePayout = 1.59; //(INTEGER) Will Cashout at 20x if the highest bet didn't cashed out yet.
var betMultiplier = 0.7; //(FLOAT) Will increase +1.30x of the last bet if lost.
//--------> EDIT OVER THIS LINE <--------
var currentBet = baseBet;
var lastBet = currentBet;
var currentPayout = basePayout;
var targets = {};
var target = null;
var ignored = ['l0rd0s4n', 'jasonvs', 'Zommau', '125okbitcoin', 'minting', '19kvz79', 'dillonmoak1'];
var placedBet = false;
var cashedOut = false;
var skipsLeft = 0;
var recovering = false;
var scoreStats = {
gamesPlayed: 0,
gamesWaited: 0,
gamesWon: 0,
gamesLost: 0,
sinceWon: 0,
sinceLost: 0,
score: 0
};
var bankStats = {
startBal: 0,
highBal: 0,
lowBal: 0,
curBal: 0,
totalWagered: 0,
totalProfit: 0,
totalLoss: 0
};
var sumLosses = 0;
bankStats.curBal = userInfo.balance;
bankStats.startBal = bankStats.curBal;
bankStats.highBal = bankStats.curBal;
bankStats.lowBal = bankStats.curBal;
var debug = 2;
engine.on('GAME_STARTING', function (info) {
placedBet = false;
cashedOut = false;
target = null;
setTimeout(placeBet, 3000);
});
function placeBet() {
if (skipsLeft > 0) {
return;
}
if (scoreStats.sinceWon > 3) {
scoreStats.sinceWon = 0;
skipsLeft += 10;
log("Detected losing streak. Skipping 3 games");
return;
}
if (bankStats.curBal < bankStats.startBal || (bankStats.curBal / bankStats.highBal) < 0.8) {
recovering = true;
} else {
recovering = false;
}
if (bankStats.curBal >= (bankStats.startBal * 3)) {
bankStats.startBal += (bankStats.curBal - bankStats.startBal) / 2;
}
target = findBestTarget(recovering);
if (target && targets[target]) {
let rec = ((sumLosses * 0.33) / targets[target].avgCashout);
let inc = (1 + Math.max(0, targets[target].sinceLost * 0.01125));
if (scoreStats.sinceLost > 0) {
currentBet = roundBit(baseBet + rec);
} else {
currentBet = roundBit((baseBet * Math.pow(betMultiplier, scoreStats.sinceWon)) + rec);
}
if (debug > 0) {
log(`[DEBUG] Bet sized at (${currentBet/100} base * ${inc} inc) + ${rec/100} rec`);
}
if (!placedBet) {
log("Acquired target (" + target + " SC: " + targets[target].score + " AVC: " + targets[target].avgCashout + ". Placing bet of ", currentBet / 100, "bits.");
engine.bet(roundBit(currentBet * inc), targets[target].avgCashout);
placedBet = true;
}
}
}
function findBestTarget(safe) {
let c = {
high: {
uname: null,
max: 0
},
profit: {
uname: null,
max: 0
},
worth: {
uname: null,
max: 0
},
score: {
uname: null,
max: 0
},
won: {
uname: null,
max: 0
},
since: {
uname: null,
max: 0
},
depend: {
uname: null,
max: 0
}
};
let vld = [];
for (let u in targets) {
if (targets.hasOwnProperty(u)) {
let t = targets[u];
if (ignored.contains(u) || t.ban > 0 || !t.bet || t.worth < 50) {
continue;
} else if (safe && (t.won < t.lost || t.score < 0 || t.sinceWon > 0 || (t.won + t.lost) < 6 || t.profit < (t.loss * 1.5))) {
continue;
} else if (!safe && (t.won < t.lost || (t.score < -2 && t.sinceWon > 2) || (t.won + t.lost) < 3 || t.profit < (t.loss * 1.1))) {
continue;
}
vld.push(u);
if (t.bet.wager > c.high.max) {
c.high.uname = u;
c.high.max = t.bet.wager;
}
if (t.profit > c.profit.max) {
c.profit.uname = u;
c.profit.max = t.profit;
}
if (t.worth > c.worth.max) {
c.worth.uname = u;
c.worth.max = t.worth;
}
if (t.score > c.score.max) {
c.score.uname = u;
c.score.max = t.score;
}
if (t.won > c.won.max) {
c.won.uname = u;
c.won.max = t.won;
}
if (t.sinceLost > c.since.max) {
c.since.uname = u;
c.since.max = t.sinceLost;
}
if (t.depend > c.depend.max) {
c.depend.uname = u;
c.depend.max = t.depend;
}
}
}
if (debug) {
let highstr = `High:${c.high.uname}[${c.high.max}]`;
let worthstr = `, Worth: ${c.worth.uname}[${c.worth.max}]`;
let profitstr = `, Profit: ${c.profit.uname}[${c.profit.max}]`;
let scorestr = `, Score: ${c.score.uname}[${c.score.max}]`;
let wonstr = `, Won: ${c.won.uname}[${c.won.max}]`;
let sincestr = `, Since: ${c.since.uname}[${c.since.max}]`;
let dependstr = `, Depend: ${c.depend.uname}[${c.depend.max}]`;
if (debug > 0) {
log("[DEBUG] Candidates: " + highstr + worthstr + profitstr + scorestr + wonstr + sincestr + dependstr + "");
}
}
let tgt = null;
let cnd = [c.high.uname, c.worth.uname, c.profit.uname, c.score.uname, c.won.uname, c.since.uname, c.depend.uname];
let pts = 0;
for (let v = 0; v < vld.length; v++) {
let u = vld[v];
let t = targets[u];
if (t.score < 2 || t.sinceWon > 2) {
if (debug > 2) {
log(`[DEBUG] ${u} NVLD (S${t.score}:P${t.profit}:L${t.loss}:W${t.wagered}:WL${t.won}-${t.lost}:SL${t.sinceLost}:D${t.depend})`);
}
continue;
} else {
let qual = (t.score + t.sinceLost + Math.floor(t.worth / 100)) + ([c.score.uname, c.since.uname, c.depend.uname].count(u) * 2);
let val = Math.min(5, qual);
let valstr = `VScore +${val}(Q)`;
if (t.bet.wager < 10000) {
val--;
valstr += "-1Bw(" + t.bet.wager + ")";
}
if ((!safe && t.avgCashout < 1.12) || (safe && t.avgCashout < 1.03)) {
val--;
valstr += "-1Ac(" + t.avgCashout + ")";
} else if ((!safe && t.avgCashout > 3.5) || (safe && t.avgCashout > 1.8)) {
val -= 2;
valstr += "-2Ac(" + t.avgCashout + ")";
} else if (t.sinceLost > 1) {
val++;
valstr += "+1Ac(" + t.avgCashout + ")";
}
let qual2 = [c.high.uname, c.worth.uname, c.profit.uname, c.won.uname].count(u);
let pl = t.profit + t.loss;
if ((!safe && (t.profit / pl) > 0.66) || (safe && (t.profit / pl) > 0.33)) {
val++;
valstr += "+1Pl";
}
if (u == c.profit.uname && qual > 0) {
val++;
valstr += "+1(Pr)"
}
if (u == c.high.uname && qual > 0) {
val++;
valstr += "+1(Hi)";
}
if (u == c.worth.uname && qual > 0) {
if (t.sinceLost > 2 || t.depend > 2) {
val += 2;
valstr += "+2(Wo)";
} else {
val++;
valstr += "+1(Wo)";
}
}
// if (u == c.since.uname && c.since.max > 1){
// val += 2;
// valstr += "+2(Si)";
// }else if (t.sinceLost > 2) {
// val++;
// valstr += "+1(Si";
// }
//
// if (t.bet.wager > 50) {
// val++;
// valstr += "+1(Wa)";
// }
// if(t.bet.payout >= 1.5){
// val += 3;
// }else if (t.bet.payout >= 1.2) {
// val += 2;
// }
//
// if(t.avgCashout >= 2){
// val--;
// valstr += "-1(AvgC)";
// }else if(t.avgCashout > 1.3){
// val += 2;
// valstr += "+2(AvgC)";
// }else if (t.avgCashout > 1.1) {
// val++;
// valstr += "+1(AvgC)";
// }
// if (t.depend > 1) {
// val++;
// valstr += "+1(D)";
// }
if (debug) {
if (debug > 1) {
log(`[DEBUG] ${u} (Value Score: ${val} = ${valstr})`);
}
}
if (val > pts) {
tgt = u;
pts = val;
}
}
}
return tgt;
}
engine.on('GAME_STARTED', function () {
if (debug > 2) {
let padding = Array(8).join(' ');
log("--------------- Round Info ---------------");
log("Start Bal : " + pad(padding, bankStats.startBal) + " | Current Bal : " + pad(padding, bankStats.curBal) + "");
log("Low Bal : " + pad(padding, bankStats.lowBal) + " | High Bal : " + pad(padding, bankStats.highBal) + "");
log("Games Played : " + pad(padding, scoreStats.gamesPlayed) + " | Games Skipped : " + pad(padding, scoreStats.gamesWaited) + "");
log("Games Won : " + pad(padding, scoreStats.gamesWon) + " | Games Lost : " + pad(padding, scoreStats.gamesLost) + "");
log("Profit : " + pad(padding, bankStats.totalProfit) + " | Loss : " + pad(padding, bankStats.totalLoss) + "");
log("Wagered : " + pad(padding, bankStats.totalWagered) + " | Mode : " + pad(padding, (recovering ? 'Recovery/Safe' : 'Normal/Risky')) + "");
//log("Avg Wager : "+pad(padding, recovering)+" |") | Avg Cashout : xxxxxxx bits");
}
});
engine.on('GAME_ENDED', function (data) {
var lastGame = engine.history.first();
for (let uname in targets) {
if (targets.hasOwnProperty(uname)) {
if (targets[uname].bet) {
if (targets[uname].cashed) {
targets[uname].won++;
targets[uname].sinceLost++;
targets[uname].sinceWon = 0;
if (targets[uname].worth >= 100) {
targets[uname].score++;
}
} else {
targets[uname].lost++;
targets[uname].sinceWon++;
targets[uname].sinceLost = 0;
if (targets[uname].worth >= 100) {
targets[uname].score--;
}
targets[uname].loss += targets[uname].bet.wager;
if (targets[uname].score < -1) {
if (targets[uname].score < Math.min(0, (0 - (5 - targets[uname].bans)))) {
targets[uname].bans++;
targets[uname].ban += Math.pow(targets[uname].bans, 4) * 5;
if (debug > 2) {
log("Excluding (Name: " + uname + ", Score: " + targets[uname].score + ", Worth: " + targets[uname].worth + ") for " + targets[uname].ban + " turns.");
}
}
}
}
targets[uname].bet = null;
targets[uname].cashed = false;
}
}
}
if (skipsLeft > 0) {
skipsLeft--;
}
if (lastGame.wager) {
lastBet = currentBet;
if (lastGame.cashedAt) {
scoreStats.score++;
scoreStats.gamesWon++;
scoreStats.sinceWon = 0;
scoreStats.sinceLost++;
let profit = (lastGame.wager * lastGame.cashedAt) - lastGame.wager;
bankStats.totalProfit += profit;
bankStats.curBal = userInfo.balance;
if (bankStats.highBal < bankStats.curBal) {
bankStats.highBal = bankStats.curBal;
}
if (sumLosses > 0) {
sumLosses -= profit;
if (sumLosses < 0) {
sumLosses = 0;
}
}
if (target && targets[target]) {
targets[target].depend++;
}
log('We won, next min bet at', currentBet / 100, 'bits : Balance: ', userInfo.balance / 100);
} else {
scoreStats.score--;
scoreStats.gamesLost++;
scoreStats.sinceLost = 0;
scoreStats.sinceWon++;
bankStats.totalLoss += lastGame.wager;
sumLosses += lastGame.wager * targets[target].avgCashout;
if (target && targets[target]) {
//targets[target].ban += 1;
targets[target].depend--;
}
log('We lost, next min bet at', currentBet / 100, 'bits : Balance: ', userInfo.balance / 100);
}
scoreStats.gamesPlayed++;
} else {
scoreStats.gamesWaited++;
}
log("Current Balance:", userInfo.balance / 100, "bits");
for (var u in targets) {
if (targets.hasOwnProperty(u)) {
//if(targets[u].won + targets[u].lost >= 10){
//log(`Clearing out stale target (${u})`);
//targets[u] = null;
//}else{
if (targets[u].history.length > 3) {
let temp = targets[u].history.mean();
targets[u].history = [temp];
}
if (targets[u].cashouts.length > 2) {
let temp = targets[u].cashouts.mean();
targets[u].cashouts = [temp];
}
//}
}
}
});
engine.on('BET_PLACED', function (bet) {
if (bet.uname == userInfo.uname) {
bankStats.totalwagered += bet.wager;
bankStats.curBal = userInfo.balance;
if (bankStats.lowBal > bankStats.curBal) {
bankStats.lowBal = bankStats.curBal;
}
return;
}
if (ignored.contains(bet.uname)) {
return;
}
if (!targets[bet.uname]) {
targets[bet.uname] = {
bet: bet,
cashed: false,
score: 0,
won: 0,
lost: 0,
sinceWon: 0,
sinceLost: 0,
ban: 0,
bans: 0,
depend: 0,
worth: 0,
wagered: 0,
profit: 0,
loss: 0,
history: [],
avgCashout: 0,
cashouts: []
};
if (debug > 0) {
log("Setting up target entry for", bet.uname);
}
} else {
targets[bet.uname].bet = bet;
targets[bet.uname].wagered += bet.wager;
}
});
engine.on('CASHED_OUT', function (bet) {
if (bet.uname == userInfo.uname) {
return;
}
if (ignored.contains(bet.uname)) {
return;
}
if (targets[bet.uname]) {
if (bet.uname == target) {
log("Target hit at " + parseFloat(bet.cashedAt).toFixed(2) + "x : (Name: " + target + ", Score: " + (targets[target].score + 1) + ", Worth: " + targets[target].worth + ")");
engine.cashOut();
//log(`Cashing out at ${bet.cashedAt}x balance is ${userInfo.balance/100} bits.`);
cashedOut = true;
}
targets[bet.uname].cashed = true;
targets[bet.uname].cashouts.push(bet.cashedAt);
targets[bet.uname].avgCashout = targets[bet.uname].cashouts.mean();
targets[bet.uname].history.push(Math.round((bet.wager * bet.cashedAt) / bet.wager) * 100);
targets[bet.uname].worth = targets[bet.uname].history.mean();
targets[bet.uname].profit += (bet.wager * bet.cashedAt) - bet.wager;
}
});
function roundBit(bet) {
return Math.round(bet / 100) * 100;
}
Array.prototype.contains = function (item) {
for (var i in this) {
if (this[i] == item) return true;
}
return false;
}
Array.prototype.max = function () {
return Math.max.apply(null, this);
}
Array.prototype.count = function (item) {
var count = 0;
for (var i = 0; i < this.length; i++) {
if (this[i] === item) {
count++;
}
}
return count;
}
// function count(arr) {
// if(arr){
// if(arr.length >= 1){
// return arr.reduce((prev, curr) => (prev[curr] = ++prev[curr] || 1, prev), {});
// }
// }
// return null;
// }
Array.prototype.mean = function () {
if (this.length >= 1) {
var sum = 0;
for (var i = 0; i < this.length; i++) {
sum += this[i];
}
return (sum / this.length);
}
return -1;
}
Array.prototype.mode = function () {
var modeMap = {};
var maxEl = this[0],
maxCount = 1;
for (var i = 0; i < this.length; i++) {
var el = this[i];
if (modeMap[el] == null) {
modeMap[el] = 1;
} else {
modeMap[el]++;
}
if (modeMap[el] > maxCount) {
maxEl = el;
maxCount = modeMap[el];
}
}
if (maxCount == 1) {
return -1;
}
return maxEl;
}
function pad(pad, str, padLeft) {
if (typeof str === 'undefined') return pad;
if (padLeft) {
return (pad + str).slice(-pad.length);
} else {
return (str + pad).substring(0, pad.length);
}
}
var config = {};
var gamesPlayed = 0;
var gamesWon = 0;
var gamesLost = 0;
var gamesSkipped = 0;
var placedBet = false;
var cashedOut = false;
var lastGame = null;
var net = 0;
var totalWager = 0;
var totalProfit = 0;
var totalLoss = 0;
var recovLoss = 0;
var player = {
bal: {
start: userInfo.balance,
now: this.start,
min: this.start,
max: this.start
},
stats: {
wagered: 0,
profit: 0,
loss: 0
}
};
var players = {};
var busts = [];
var target = null;
engine.on("GAME_STARTING", onGameStarting);
engine.on("GAME_STARTED", onGameStarted);
engine.on("GAME_ENDED", onGameEnded);
engine.on("CASHED_OUT", onCashedOut);
engine.on("PLACED_BET", onPlacedBet);
function onGameStarting() {
placedBet = false;
cashedOut = false;
target = null;
for (let uname in players) {
if (players.hasOwnProperty(uname)) {
// TODO: Process players here
}
}
setTimeout(assignTargets, 4500);
}
function assignTargets() {}
function onGameStarted() {
for (let uname in players) {
if (players.hasOwnProperty(uname)) {
let p = players[uname];
}
}
}
function onGameEnded() {
lastGame = engine.history.first();
for (let uname in players) {
if (players.hasOwnProperty(uname)) {
if (players[uname].ban > 0) {
continue;
} else if (players[uname].bet) {
players[uname].lastBet = players[uname].bet;
players[uname].gamesPlayed++;
if (players[uname].cashed) {
players[uname].gamesWon++;
players[uname].sinceLost++;
players[uname].sinceWon = 0;
players[uname].data.score.push(1);
let profit = (players[uname].bet.wager * players[uname].bet.payout) - players[uname].bet.wager
players[uname].totalProfit += profit;
// TODO: consider formula (p.totalProfit + p.totalWager) / p.totalWager
let worth = ((players[uname].bet.wager + profit) / players[uname].bet.wager) * 100;
players[uname].data.worth.push((players[uname].totalProfit + players[uname].totalWager) / players[uname].totalWager);
players[uname].avgWorth = players[uname].data.worth.mean();
if (players[uname].data.worth.length > 4) {
players[uname].data.worth = players[uname].data.worth.slice(0, 9);
}
} else {
players[uname].gamesLost++;
players[uname].sinceWon++;
players[uname].sinceLost = 0;
players[uname].data.score.push(-1);
players[uname].totalLoss += players[uname].bet.wager;
}
players[uname].score = players[uname].data.score.mean();
if (players[uname].data.score.length > 20) {
players[uname].data.score = players[uname].data.score.slice(0, 19);
}
}
}
}
if (lastGame.wager) {
lastBet = currentBet;
totalWager += lastGame.wager;
if (lastGame.cashedAt) {
currentBet = baseBet;
totalWon += lastGame.wager * lastGame.cashedAt;
totalProfit = totalWon - totalWager;
if (recovLoss > 0) {
recovLoss -= lastGame.wager * lastGame.cashedAt - lastGame.wager;
if (recovLoss < 0) {
recovLoss = 0;
}
}
gamesWon++;
sinceLost++;
sinceWon = 0;
} else {
currentBet = roundBit(lastBet * betMultiplier);
totalLoss += lastGame.wager;
recovLoss += lastGame.wager;
gamesLost++;
sinceWon++;
sinceLost = 0;
}
gamesPlayed++;
} else {
gamesSkipped++;
}
logRound();
}
function onPlacedBet(bet) {
if (bet.uname == userInfo.uname) {
return;
}
if (!players[bet.uname]) {
players[bet.uname] = {
score: 0,
bet: bet,
lastBet: null,
lastPlayed: null,
ban: 0,
cashed: false,
gamesPlayed: 1,
gamesWon: 0,
gamesLost: 0,
sinceWon: 0,
sinceLost: 0,
totalWager: bet.wager,
totalProfit: 0,
totalLoss: 0,
avgWager: 0,
avgPayout: 0,
avgCashout: 0,
avgWorth: 0,
data: {
score: [],
wagers: [],
payouts: [],
cashOuts: [],
worth: []
}
};
} else {
players[bet.uname].lastBet = players[bet.uname].bet;
players[bet.uname].bet = bet;
players[bet.uname].gamesPlayed++;
players[bet.uname].totalWagered += bet.wager;
players[bet.uname].data.payouts.push(bet.payout);
players[bet.uname].avgPayout = mean(players[bet.uname].data.payouts);
players[bet.uname].data.wagers.push(bet.wager);
players[bet.uname].avgWager = mean(players[bet.uname].data.wagers);
}
}
function onCashedOut(bet) {
if (bet.uname == userInfo.uname) {
return;
} else {
if (players[bet.uname]) {}
}
}
function logRound() {
let padding = Array(8).join(' ');
log("--------------- Round Info ---------------");
log("Game Num : " + (padding, "#" + engine.gameId + " (" + player.gamesPlayed + ")") + " | Mode: ")
log("------------------------------------------");
log("Start Bal : " + (player.bal.start / 100).pad(8) + " | Current Bal : " + (player.bal.now / 100).pad(8) + "");
log("Low Bal : " + (player.bal.min / 100).pad(8) + " | High Bal : " + (player.bal.max / 100).pad(8) + "");
log("Games Played : " + gamesPlayed.pad(8) + " | Games Skipped : " + gamesSkipped.pad(8) + "");
log("Games Won : " + gamesWon.pad(8) + " | Games Lost : " + gamesLost.pad(8) + "");
log("Profit : " + (player.stats.profit / 100).pad(8) + " | Loss : " + (player.stats.loss / 100).pad(8) + "");
log("Wagered : " + (player.stats.wagered / 100).pad(8) + " | Mode : " + ((recovering ? 'Recover' : 'Normal')).pad(8) + "");
var roundStr = "Games Played: " + gamesPlayed;
var unplayedStr = "\nGames Skipped: " + gamesSkipped;
var lastStr = "\nLast Bust: " + lastGame.bust;
var cashedOutStr = "\nCashed Out: " + cashedOut;
var lastGamePlayStr = "\nLast Game: " + (lastGame.cashedAt ? "Won" : "Lost");
// Log the variables
console.log("\n\n" + botTitleStr + userNameStr + baseBetStr + roundStr + gamesWonStr + gamesLostStr + unplayedStr + lastStr + cashedOutStr + lastGamePlayStr + startBRStr + maxBRStr + minBRStr + curBRStr + netStr + "\n");
}
Array.prototype.median = function () {
if (this.length >= 1) {
let arr = this.slice().sort(function (a, b) {
return a - b;
});
if (this.length % 2 == 0) {
return (arr[this.length / 2] + this[this.length / 2 - 1]) / 2;
} else {
return this[Math.floor(this.length / 2)];
}
}
return -1;
};
Array.prototype.contains = function (item) {
return this.count(item) > 0 ? true : false;
};
Array.prototype.count = function (item) {
var count = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] === item) {
count++;
}
}
return count > -1 ? count + 1 : count;
};
Array.prototype.max = function () {
return Math.max.apply(null, this);
};
Array.prototype.mean = function () {
if (this.length >= 1) {
var sum = 0;
for (var i = 0; i < this.length; i++) {
sum += this[i];
}
return sum / this.length;
}
return -1;
};
Array.prototype.mode = function () {
var modeMap = {};
var maxEl = this[0],
maxCount = 1;
for (var i = 0; i < this.length; i++) {
var el = this[i];
if (modeMap[el] == null) {
modeMap[el] = 1;
} else {
modeMap[el]++;
}
if (modeMap[el] > maxCount) {
maxEl = el;
maxCount = modeMap[el];
}
}
if (maxCount == 1) {
return -1;
}
return maxEl;
};
Object.prototype.pad = function (padAmt, padChr = " ", padLeft = false) {
if (![String, Number].contains(typeof this)) {
console.log("Object.pad() tried to pad invalid type (" + typeof this + ")");
return this.toString();
}
let str = this.toString();
let pad = Array(padAmt).join(padChr);
if (padLeft) {
return (pad + str).slice(-pad.length);
} else {
return (str + pad).substring(0, pad.length);
}
};
Object.prototype.padLeft = function (padAmt, padChr) {
return this.pad(padAmt, padChr, true);
};
var config = {};
class Player {
constructor(uname) {
this.uname = uname;
this.lastSeen = 0;
// assets
this.totalWagered = 0;
this.totalProfit = 0;
this.totalLosses = 0;
// score
this.totalPlayed = 0;
this.totalSkipped = 0;
this.totalWon = 0;
this.totalLost = 0;
this.sinceWon = 0;
this.sinceLost = 0;
this.wagers = [];
this.cashOuts = [];
this.ROIs = [];
}
recordBet(bet) {
this.totalWagered += bet.wager;
this.wagers.unshift(bet.wager);
}
recordCashOut(bet) {
let profit = (bet.wager * bet.cashedAt) - bet.wager;
this.totalProfit += profit;
this.cashOuts.unshift(bet.cashedAt);
this.ROIs.unshift(Math.round(profit / bet.wager) * 100);
}
avgWager(numGames) {
return this.wagers.slice(0, numGames).median();
}
avgCashOut(numGames) {
return this.cashOuts.slice(0, numGames).median();
}
avgWorth(numGames) {
return this.ROIs.slice(0, numGames).median();
}
}
var players = {};
let player = new Player(userInfo.uname);
engine.on('GAME_STARTING', onGameStarting);
engine.on('GAME_ENDED', onGameEnded);
engine.on('CASHED_OUT', onCashedOut);
engine.on('BET_PLACED', onBetPlaced);
function onGameStarting() {
// do something
}
function onGameEnded() {
// do something
}
function onCashedOut(bet) {
if (players[bet.uname]) {
players[bet.uname].recordCashOut(bet);
}
}
function onBetPlaced(bet) {
if (players[bet.uname]) {
players[bet.uname] = new Player(bet.uname);
}
players[bet.uname].recordBet(bet);
}
Array.prototype.contains = function (item) {
return this.count(item) > 0;
};
Array.prototype.max = function () {
return Math.max.apply(null, this);
};
Array.prototype.count = function (item) {
var count = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] === item) {
count++;
}
}
return count > -1 ? count + 1 : count;
};
Array.prototype.mean = function () {
if (this.length >= 1) {
var sum = 0;
for (var i = 0; i < this.length; i++) {
sum += this[i];
}
return sum / this.length;
}
return -1;
};
Array.prototype.median = function () {
if (this.length >= 1) {
const arr = this.slice().sort((a, b) => { return a - b; });
if (this.length % 2 === 0) {
return (arr[this.length / 2] + this[this.length / 2 - 1]) / 2;
}
return this[Math.floor(this.length / 2)];
}
return -1;
};
Array.prototype.mode = function () {
if (this.length >= 1) {
var modeMap = {};
var maxEl = this[0],
maxCount = 1;
for (var i = 0; i < this.length; i++) {
var el = this[i];
if (modeMap[el] == null) {
modeMap[el] = 1;
} else {
modeMap[el]++;
}
if (modeMap[el] > maxCount) {
maxEl = el;
maxCount = modeMap[el];
}
}
return maxEl;
}
return this[1];
};
@emers7n

This comment has been minimized.

Copy link

@emers7n emers7n commented Feb 8, 2020

how do we get v5 to work, got wheres afk bustbit script? nice coding bro u got discord?

@emers7n

This comment has been minimized.

Copy link

@emers7n emers7n commented Feb 8, 2020

u heard of ethercrash bro its fire easy scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment