View difference between Paste ID: ue673jmJ and wEVtXVSM
SHOW: | | - or go back to the newest paste.
1
var baseBet = 6;
2
var baseMultiplier = 1.33;
3
var variableBase = false;
4
var streakSecurity = 3;
5
var maximumBet = 999999999;
6
7
var pauseThreshold = 20;
8
var continueThreshold = 2;
9
10
var pauseAfterNLosses = 3;   
11
var pauseForMGames = 7;
12
13
pauseThreshold = Math.round(pauseThreshold * 100);
14
continueThreshold = Math.round(continueThreshold * 100);
15
16
var baseSatoshi = baseBet * 100;
17
var currentBet = baseSatoshi;
18
var currentMultiplier = baseMultiplier;
19
var currentGameID = -1;
20
var firstGame = true;
21
var lossStreak = 0;
22
var coolingDown = false;
23
24
var lostLast = false;
25
26
var currentGameData;
27
var lastCrash = (continueThreshold + pauseThreshold)/3;
28
var paused = false;
29
var pauseLossStreak = 0;
30
var pausedFor = 0;
31
32
console.log('====== BustaBit Bot ======');
33
console.log('My username is: ' + engine.getUsername());
34
console.log('Starting balance: ' + (engine.getBalance() / 100).toFixed(3) + ' bits');
35
var startingBalance = engine.getBalance();
36
37
if (variableBase) {
38
      console.warn('[WARN] Variable mode is enabled and not fully tested. Bot is resillient to ' + streakSecurity + '-loss streaks.');
39
}
40
41
engine.on('game_starting', function(info) {
42
	
43
      console.log('====== New Game ======');
44
	  
45
		if(lastCrash >= pauseThreshold) {
46
			paused = true;
47
			console.log("Pausing Betting");
48
			return;
49
		}
50
		
51
		if(paused) {
52
			if(lastCrash >= continueThreshold) {
53
				console.log("Continuing Betting");
54
				lastCrash = (continueThreshold + pauseThreshold)/3;
55
				paused = false;
56
			} else {
57
				console.log("Betting Is Paused");
58
				return;
59
			}
60
		}
61
	  
62
		if(pausedFor > 0) {1
63
		   pausedFor++;
64
		   if(pausedFor <= pauseForMGames) {
65
			   console.log("Paused " + pausedFor + " of " + pauseForMGames + " games");
66
			   return;
67
		   } else {
68
			   console.log("Resuming");
69
			   pausedFor = 0;
70
			   pauseLossStreak = 0;
71
		   }
72
		} 
73
		
74
		if(pauseLossStreak >= pauseAfterNLosses) {
75
			console.log("Pausing for 1 of " + pauseForMGames + " games");
76
			pausedFor = 1;
77
			return;
78
		}
79
	
80
      console.log('[Bot] Game #' + info.game_id);
81
      currentGameID = info.game_id;
82
83
      if (coolingDown) {     
84
      if (lossStreak == 0) {
85
      coolingDown = false;
86
      }
87
      else {
88
      lossStreak--;
89
      console.log('[Bot] Cooling down! Games remaining: ' + lossStreak);
90
      return;
91
      }
92
      }
93
94
      if (!firstGame) {
95
      console.log('[Stats] Session profit: ' + ((engine.getBalance() - startingBalance) / 100).toFixed(3) + ' bits');
96
      console.log('[Stats] Profit percentage: ' + (((engine.getBalance() / startingBalance) - 1) * 100).toFixed(3) + '%');
97
      }
98
99
      if (lostLast && !firstGame) {//if (engine.lastGamePlay() == 'LOST' && !firstGame) { // If last game loss:
100
      lossStreak++;
101
      var totalLosses = 0;
102
      var lastLoss = currentBet;
103
      while (lastLoss >= baseSatoshi) {
104
      totalLosses += lastLoss;
105
      lastLoss /= 3;
106
      }
107
108
      if (lossStreak > streakSecurity) {
109
      coolingDown = true;
110
      return;
111
      }
112
113
      currentBet *= 3;
114
      currentMultiplier = 1 + (totalLosses / currentBet);
115
      }
116
      else {
117
      lossStreak = 0;
118
      if (variableBase) {
119
      var divider = 100;
120
      for (i = 0; i < streakSecurity; i++) {
121
      divider += (100 * Math.pow(3, (i + 1)));
122
      }
123
124
      newBaseBet = Math.min(Math.max(1, Math.floor(engine.getBalance() / divider)), maximumBet * 100);
125
      newBaseSatoshi = newBaseBet * 100;
126
127
      if ((newBaseBet != baseBet) || (newBaseBet == 1)) {
128
      console.log('[Bot] Variable mode has changed base bet to: ' + newBaseBet + ' bits');
129
      baseBet = newBaseBet;
130
      baseSatoshi = newBaseSatoshi;
131
      }
132
      }
133
      // Update bet.
134
      currentBet = baseSatoshi;
135
      currentMultiplier = baseMultiplier;
136
      }
137
138
      console.log('[Bot] Betting ' + (currentBet / 100) + ' bits, cashing out at ' + currentMultiplier + 'x');
139
      firstGame = false;
140
141
      if (currentBet <= engine.getBalance()) {
142
      if (currentBet > (maximumBet * 100)) {
143
      console.warn('[Warn] Bet size exceeds maximum bet, lowering bet to ' + (maximumBet * 100) + ' bits');
144
      currentBet = maximumBet;
145
      }
146
      engine.placeBet(currentBet, Math.round(currentMultiplier * 100), false);
147
      }
148
      else {
149
      if (engine.getBalance() < 100) {
150
      console.error('[Bot] Insufficent funds to do anything... stopping');
151
      engine.stop();
152
      }
153
      else {
154
      console.warn('[Bot] Insufficent funds to bet ' + (currentBet / 100) + ' bits.');
155
      console.warn('[Bot] Resetting to 1 bit basebet');
156
      baseBet = 1;
157
      baseSatoshi = 100;
158
      }
159
      }
160
});
161
162
engine.on('game_started', function(data) {
163
    if (!firstGame) { console.log('[Bot] Game #' + currentGameID + ' has started!'); }
164
	currentGameData = data;
165
});
166
167
engine.on('cashed_out', function(data) {
168
    if (data.username == engine.getUsername()) {      
169
      console.log('[Bot] Successfully cashed out at ' + (data.stopped_at / 100) + 'x');
170
      }
171
});
172
173
engine.on('game_crash', function(data) {
174
    if (!firstGame) { console.log('[Bot] Game crashed at ' + (data.game_crash / 100) + 'x'); }
175
	
176
	lastCrash = data.game_crash;
177
		
178
	if (!currentGameData || !currentGameData.hasOwnProperty(engine.getUsername())) {
179
        return;
180
    };
181
	
182
	lostLast = engine.lastGamePlay() == 'LOST';
183
	
184
	console.log((lostLast ? "Lost" : "Won") + " this game.");
185
	
186
	if(!lostLast) {
187
		pauseLossStreak = 0;
188
	} else {
189
		pauseLossStreak++;
190
	}
191
});