Difference
1 removal
126 lines
1 addition
126 lines
// Settings
// Settings
var baseBet = 1; // In bits
var baseBet = 10; // In bits
var baseMultiplier = 1.10; // Target multiplier: 1.10 recommended
var baseMultiplier = 1.10; // Target multiplier: 1.10 recommended
var variableBase = false; // Enable variable mode (very experimental), read streakSecurity.
var variableBase = false; // Enable variable mode (very experimental), read streakSecurity.
var streakSecurity = 15; // Number of loss-streak you wanna be safe for. Increasing this massively reduces the variableBase calculated. (1-loss = 20%, 2-loss = 5%, 3-loss = 1.25% of your maximum balance). Recommended: 2+
var streakSecurity = 15; // Number of loss-streak you wanna be safe for. Increasing this massively reduces the variableBase calculated. (1-loss = 20%, 2-loss = 5%, 3-loss = 1.25% of your maximum balance). Recommended: 2+
var maximumBet = 999999; // Maximum bet the bot will do (in bits).
var maximumBet = 999999; // Maximum bet the bot will do (in bits).
// Variables - Do not touch!
// Variables - Do not touch!
var baseSatoshi = baseBet * 100; // Calculated
var baseSatoshi = baseBet * 100; // Calculated
var currentBet = baseSatoshi;
var currentBet = baseSatoshi;
var currentMultiplier = baseMultiplier;
var currentMultiplier = baseMultiplier;
var currentGameID = -1;
var currentGameID = -1;
var firstGame = true;
var firstGame = true;
var lossStreak = 0;
var lossStreak = 0;
var coolingDown = false;
var coolingDown = false;
// Initialization
// Initialization
console.log('====== Procon\'s BustaBit Bot ======');
console.log('====== Procon\'s BustaBit Bot ======');
console.log('My username is: ' + engine.getUsername());
console.log('My username is: ' + engine.getUsername());
console.log('Starting balance: ' + (engine.getBalance() / 100).toFixed(2) + ' bits');
console.log('Starting balance: ' + (engine.getBalance() / 100).toFixed(2) + ' bits');
var startingBalance = engine.getBalance();
var startingBalance = engine.getBalance();
if (variableBase) {
if (variableBase) {
console.warn('[WARN] Variable mode is enabled and not fully tested. Bot is resillient to ' + streakSecurity + '-loss streaks.');
console.warn('[WARN] Variable mode is enabled and not fully tested. Bot is resillient to ' + streakSecurity + '-loss streaks.');
}
}
// On a game starting, place the bet.
// On a game starting, place the bet.
engine.on('game_starting', function(info) {
engine.on('game_starting', function(info) {
console.log('====== New Game ======');
console.log('====== New Game ======');
console.log('[Bot] Game #' + info.game_id);
console.log('[Bot] Game #' + info.game_id);
currentGameID = info.game_id;
currentGameID = info.game_id;
if (coolingDown) {
if (coolingDown) {
if (lossStreak == 0) {
if (lossStreak == 0) {
coolingDown = false;
coolingDown = false;
}
}
else {
else {
lossStreak--;
lossStreak--;
console.log('[Bot] Cooling down! Games remaining: ' + lossStreak);
console.log('[Bot] Cooling down! Games remaining: ' + lossStreak);
return;
return;
}
}
}
}
if (!firstGame) { // Display data only after first game played.
if (!firstGame) { // Display data only after first game played.
console.log('[Stats] Session profit: ' + ((engine.getBalance() - startingBalance) / 100).toFixed(2) + ' bits');
console.log('[Stats] Session profit: ' + ((engine.getBalance() - startingBalance) / 100).toFixed(2) + ' bits');
console.log('[Stats] Profit percentage: ' + (((engine.getBalance() / startingBalance) - 1) * 100).toFixed(2) + '%');
console.log('[Stats] Profit percentage: ' + (((engine.getBalance() / startingBalance) - 1) * 100).toFixed(2) + '%');
}
}
if (engine.lastGamePlay() == 'LOST' && !firstGame) { // If last game loss:
if (engine.lastGamePlay() == 'LOST' && !firstGame) { // If last game loss:
lossStreak++;
lossStreak++;
var totalLosses = 0; // Total satoshi lost.
var totalLosses = 0; // Total satoshi lost.
var lastLoss = currentBet; // Store our last bet.
var lastLoss = currentBet; // Store our last bet.
while (lastLoss >= baseSatoshi) { // Until we get down to base bet, add the previous losses.
while (lastLoss >= baseSatoshi) { // Until we get down to base bet, add the previous losses.
totalLosses += lastLoss;
totalLosses += lastLoss;
lastLoss /= 4;
lastLoss /= 4;
}
}
if (lossStreak > streakSecurity) { // If we're on a loss streak, wait a few games!
if (lossStreak > streakSecurity) { // If we're on a loss streak, wait a few games!
coolingDown = true;
coolingDown = true;
return;
return;
}
}
currentBet *= 7; // Then multiply base bet by 4!
currentBet *= 7; // Then multiply base bet by 4!
currentMultiplier = 1.00 + (totalLosses / currentBet);
currentMultiplier = 1.00 + (totalLosses / currentBet);
}
}
else { // Otherwise if win or first game:
else { // Otherwise if win or first game:
lossStreak = 0; // If it was a win, we reset the lossStreak.
lossStreak = 0; // If it was a win, we reset the lossStreak.
if (variableBase) { // If variable bet enabled.
if (variableBase) { // If variable bet enabled.
// Variable mode resists (currently) 1 loss, by making sure you have enough to cover the base and the 4x base bet.
// Variable mode resists (currently) 1 loss, by making sure you have enough to cover the base and the 4x base bet.
var divider = 100;
var divider = 100;
for (i = 0; i < streakSecurity; i++) {
for (i = 0; i < streakSecurity; i++) {
divider += (100 * Math.pow(4, (i + 1)));
divider += (100 * Math.pow(4, (i + 1)));
}
}
newBaseBet = Math.min(Math.max(1, Math.floor(engine.getBalance() / divider)), maximumBet * 100); // In bits
newBaseBet = Math.min(Math.max(1, Math.floor(engine.getBalance() / divider)), maximumBet * 100); // In bits
newBaseSatoshi = newBaseBet * 100;
newBaseSatoshi = newBaseBet * 100;
if ((newBaseBet != baseBet) || (newBaseBet == 1)) {
if ((newBaseBet != baseBet) || (newBaseBet == 1)) {
console.log('[Bot] Variable mode has changed base bet to: ' + newBaseBet + ' bits');
console.log('[Bot] Variable mode has changed base bet to: ' + newBaseBet + ' bits');
baseBet = newBaseBet;
baseBet = newBaseBet;
baseSatoshi = newBaseSatoshi;
baseSatoshi = newBaseSatoshi;
}
}
}
}
// Update bet.
// Update bet.
currentBet = baseSatoshi; // in Satoshi
currentBet = baseSatoshi; // in Satoshi
currentMultiplier = baseMultiplier;
currentMultiplier = baseMultiplier;
}
}
// Message and set first game to false to be sure.
// Message and set first game to false to be sure.
console.log('[Bot] Betting ' + (currentBet / 100) + ' bits, cashing out at ' + currentMultiplier + 'x');
console.log('[Bot] Betting ' + (currentBet / 100) + ' bits, cashing out at ' + currentMultiplier + 'x');
firstGame = false;
firstGame = false;
if (currentBet <= engine.getBalance()) { // Ensure we have enough to bet
if (currentBet <= engine.getBalance()) { // Ensure we have enough to bet
if (currentBet > (maximumBet * 100)) { // Ensure you only bet the maximum.
if (currentBet > (maximumBet * 100)) { // Ensure you only bet the maximum.
console.warn('[Warn] Bet size exceeds maximum bet, lowering bet to ' + (maximumBet * 100) + ' bits');
console.warn('[Warn] Bet size exceeds maximum bet, lowering bet to ' + (maximumBet * 100) + ' bits');
currentBet = maximumBet;
currentBet = maximumBet;
}
}
engine.placeBet(currentBet, Math.round(currentMultiplier * 100), false);
engine.placeBet(currentBet, Math.round(currentMultiplier * 100), false);
}
}
else { // Otherwise insufficent funds...
else { // Otherwise insufficent funds...
if (engine.getBalance() < 100) {
if (engine.getBalance() < 100) {
console.error('[Bot] Insufficent funds to do anything... stopping');
console.error('[Bot] Insufficent funds to do anything... stopping');
engine.stop();
engine.stop();
}
}
else {
else {
console.warn('[Bot] Insufficent funds to bet ' + (currentBet / 100) + ' bits.');
console.warn('[Bot] Insufficent funds to bet ' + (currentBet / 100) + ' bits.');
console.warn('[Bot] Resetting to 1 bit basebet');
console.warn('[Bot] Resetting to 1 bit basebet');
baseBet = 1;
baseBet = 1;
baseSatoshi = 100;
baseSatoshi = 100;
}
}
}
}
});
});
engine.on('game_started', function(data) {
engine.on('game_started', function(data) {
if (!firstGame) { console.log('[Bot] Game #' + currentGameID + ' has started!'); }
if (!firstGame) { console.log('[Bot] Game #' + currentGameID + ' has started!'); }
});
});
engine.on('cashed_out', function(data) {
engine.on('cashed_out', function(data) {
if (data.username == engine.getUsername()) {
if (data.username == engine.getUsername()) {
console.log('[Bot] Successfully cashed out at ' + (data.stopped_at / 100) + 'x');
console.log('[Bot] Successfully cashed out at ' + (data.stopped_at / 100) + 'x');
}
}
});
});
engine.on('game_crash', function(data) {
engine.on('game_crash', function(data) {
if (!firstGame) { console.log('[Bot] Game crashed at ' + (data.game_crash / 100) + 'x'); }
if (!firstGame) { console.log('[Bot] Game crashed at ' + (data.game_crash / 100) + 'x'); }
});
});