Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. // Bustabit BlackShadow
  2. // By: BlackShadow & MartinG
  3. // Version 5
  4.  
  5. // Settings
  6. var baseBet = 5; // In bits
  7. var baseMultiplier = 3;
  8. var variableBase = false;
  9. var streakSecurity = 10;
  10. var maximumBet = 999999;
  11.  
  12. // Variables
  13. var baseSatoshi = baseBet * 100; // Calculated
  14. var currentBet = baseSatoshi;
  15. var currentMultiplier = baseMultiplier;
  16. var currentGameID = -1;
  17. var firstGame = true;
  18. var lossStreak = 0;
  19. var coolingDown = false;
  20.  
  21. var lostLast = false;
  22.  
  23. // Initialization
  24. console.log('My username is: ' + engine.getUsername());
  25. console.log('Starting balance: ' + (engine.getBalance() / 100).toFixed(2) + ' bits');
  26. var startingBalance = engine.getBalance();
  27.  
  28. if (variableBase) {
  29. console.warn('[WARN] Variable mode is enabled and not fully tested. Bot is resillient to ' + streakSecurity + '-loss streaks.');
  30. }
  31.  
  32. // On a game starting, place the bet.
  33. engine.on('game_starting', function(info) {
  34.  
  35. console.log('====== New Game ======');
  36.  
  37.  
  38. console.log('[Bot] Game #' + info.game_id);
  39. currentGameID = info.game_id;
  40.  
  41. if (coolingDown) {
  42. if (lossStreak == 0) {
  43. coolingDown = false;
  44. }
  45. else {
  46. lossStreak--;
  47. console.log('[Bot] Cooling down! Games remaining: ' + lossStreak);
  48. return;
  49. }
  50. }
  51.  
  52. if (!firstGame) { // Display data only after first game played.
  53. console.log('[Stats] Session profit: ' + ((engine.getBalance() - startingBalance) / 100).toFixed(2) + ' bits');
  54. console.log('[Stats] Profit percentage: ' + (((engine.getBalance() / startingBalance) - 1) * 100).toFixed(2) + '%');
  55. }
  56.  
  57. if (lostLast && !firstGame) {//if (engine.lastGamePlay() == 'LOST' && !firstGame) { // If last game loss:
  58. lossStreak++;
  59. var totalLosses = 0; // Total satoshi lost.
  60. var lastLoss = currentBet; // Store our last bet.
  61. while (lastLoss >= baseSatoshi) { // Until we get down to base bet, add the previous losses.
  62. totalLosses += lastLoss;
  63. lastLoss /= 2;
  64. }
  65.  
  66. if (lossStreak > streakSecurity) { // If we're on a loss streak, wait a few games!
  67. coolingDown = true;
  68. return;
  69. }
  70.  
  71. currentBet *= 2; // Then multiply base bet by 2!
  72. currentMultiplier = 1 + (totalLosses / currentBet);
  73. }
  74. else { // Otherwise if win or first game:
  75. lossStreak = 0; // If it was a win, we reset the lossStreak.
  76. if (variableBase) { // If variable bet enabled.
  77. // Variable mode resists (currently) 1 loss, by making sure you have enough to cover the base and the 2x base bet.
  78. var divider = 100;
  79. for (i = 0; i < streakSecurity; i++) {
  80. divider += (100 * Math.pow(2, (i + 1)));
  81. }
  82.  
  83. newBaseBet = Math.min(Math.max(1, Math.floor(engine.getBalance() / divider)), maximumBet * 100); // In bits
  84. newBaseSatoshi = newBaseBet * 100;
  85.  
  86. if ((newBaseBet != baseBet) || (newBaseBet == 1)) {
  87. console.log('[Bot] Variable mode has changed base bet to: ' + newBaseBet + ' bits');
  88. baseBet = newBaseBet;
  89. baseSatoshi = newBaseSatoshi;
  90. }
  91. }
  92. // Update bet.
  93. currentBet = baseSatoshi; // in Satoshi
  94. currentMultiplier = baseMultiplier;
  95. }
  96.  
  97. // Message and set first game to false to be sure.
  98. console.log('[Bot] Betting ' + (currentBet / 100) + ' bits, cashing out at ' + currentMultiplier + 'x');
  99. firstGame = false;
  100.  
  101. if (currentBet <= engine.getBalance()) { // Ensure we have enough to bet
  102. if (currentBet > (maximumBet * 100)) { // Ensure you only bet the maximum.
  103. console.warn('[Warn] Bet size exceeds maximum bet, lowering bet to ' + (maximumBet * 100) + ' bits');
  104. currentBet = maximumBet;
  105. }
  106. engine.placeBet(currentBet, Math.round(currentMultiplier * 100), false);
  107. }
  108. else { // Otherwise insufficent funds...
  109. if (engine.getBalance() < 100) {
  110. console.error('[Bot] Insufficent funds to do anything... stopping');
  111. engine.stop();
  112. }
  113. else {
  114. console.warn('[Bot] Insufficent funds to bet ' + (currentBet / 100) + ' bits.');
  115. console.warn('[Bot] Resetting to 1 bit basebet');
  116. baseBet = 1;
  117. baseSatoshi = 100;
  118. }
  119. }
  120. });
  121.  
  122. engine.on('game_started', function(data) {
  123. if (!firstGame) { console.log('[Bot] Game #' + currentGameID + ' has started!'); }
  124. currentGameData = data;
  125. });
  126.  
  127. engine.on('cashed_out', function(data) {
  128. if (data.username == engine.getUsername()) {
  129. console.log('[Bot] Successfully cashed out at ' + (data.stopped_at / 100) + 'x');
  130. }
  131. });
  132.  
  133. engine.on('game_crash', function(data) {
  134. if (!firstGame) { console.log('[Bot] Game crashed at ' + (data.game_crash / 100) + 'x'); }
  135.  
  136. /********************/
  137.  
  138. lastCrash = data.game_crash;
  139.  
  140. if (!currentGameData || !currentGameData.hasOwnProperty(engine.getUsername())) {
  141. return;
  142. };
  143.  
  144. lostLast = engine.lastGamePlay() == 'LOST';
  145.  
  146. console.log((lostLast ? "Lost" : "Won") + " this game.");
  147.  
  148.  
  149.  
  150. /********************/
  151. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement