Yet another Bustabit script for easy passive bitcoin earning!


SUBMITTED BY: staceyjones90

DATE: Oct. 30, 2016, 1:33 p.m.

FORMAT: Text only

SIZE: 8.9 kB

HITS: 1049

  1. /* StaceyJones90's Bustabit script
  2. * Version 1.0
  3. * Description: This script has a starting cashout of 1.13x and a loss multiplier of 4x
  4. * On loss streaks, it uses a progressive cashout amount for better recovery
  5. */
  6. // TODO
  7. // check return code of bet for "GAME_IN_PROGRESS"
  8. // add timer (setTimeout)
  9. // include bonuses in profit (not possible in sim mode)
  10. // calculate profit per hour and per day
  11. // add stop when balance = x option
  12. /*
  13. * User Settings
  14. */
  15. var streakSecurity = 4; // Number of loss streaks you want to be safe for
  16. var risk = 0.5; // Fraction of your bankroll you'll lose if a loss streak of streakSecurity + 1 occurs
  17. // Range: 0.01 - 1 || Higher = more risk/reward, lower = less risk/reward
  18. // Recommend range: 0.25 - 0.75
  19. var restartOnMaxLossStreak = true; // (true/false) If true, bot will reinitialize baseBet and cashout amount
  20. // when a loss streak of streakSecurity + 1 occurs, otherwise it'll just stop
  21. // NOTE: if risk = 1, restarting may not be possible
  22. var simulation = false; // (true/false) Setting this to true will make the bot to simulate a betting run
  23. // If you've changed any of the user settings, it's always recommended to test...
  24. // ...your changes by letting the bot run in simulator mode for a bit
  25. var simMsg = simulation ? '(SIMULATION) ' : ''; // This will appear in the console logs when running in simulator mode
  26. /*
  27. * Initialize global settings and counters (don't touch at all)
  28. */
  29. var firstGame = true,
  30. numWins = 0,
  31. numLosses = 0,
  32. maxWinStreak = 0,
  33. maxLossStreak = 0,
  34. currentWinStreak = 0,
  35. currentLossStreak = 0,
  36. totalSatoshiProfit = 0,
  37. currentGameID = -1,
  38. currentCashout = 0,
  39. currentBitBet = 0,
  40. currentSatoshiBet = 0,
  41. roundedSatoshiBet = 0,
  42. lastResult = 'NOT_PLAYED'; // NOT_PLAYED, WON, LOST
  43. var startingBalance = engine.getBalance(); // in satoshi
  44. /*
  45. * Initialize game settings (don't touch unless you know what you're doing)
  46. */
  47. var baseCashout = 1.13;
  48. var lossMultiplier = 4; // Increase base bet by this factor on loss
  49. var cashoutAmounts =
  50. [baseCashout, 1.25, 1.31, 1.33, 1.33]; // Cashout amount for current game are determined by...
  51. // ...indexing cashoutAmounts with currentLossTreak
  52. // NOTE: Length must be equal to streakSecurity + 1
  53. var riskFactor = 0;
  54. for (var i = 0; i <= streakSecurity; i++) // need to sum all of the bet multipliers to...
  55. { // ...determine what the bankroll is divided by
  56. riskFactor += Math.pow(lossMultiplier, i);
  57. };
  58. /*
  59. * Helper function to calculate the bet amount
  60. * based on current balance and user settings
  61. */
  62. function calcBaseBet()
  63. {
  64. var currentBal = engine.getBalance();
  65. return (risk * currentBal) / riskFactor;
  66. }
  67. // Calculate initialBaseBet (in satoshi) based on the user settings
  68. var initialBaseBet = calcBaseBet();
  69. console.log('========================== EngiNerds\'s BustaBit Bot ==========================');
  70. console.log('My username is: ' + engine.getUsername());
  71. console.log('Starting balance: ' + (startingBalance/100).toFixed(2) + ' bits');
  72. console.log('Risk Tolerance: ' + (risk * 100).toFixed(2) + '%');
  73. console.log('Inital base bet: ' + Math.round(initialBaseBet/100) + ' bits (real value ' + (initialBaseBet/100).toFixed(2) + ')');
  74. if (simulation) { console.log('=========================== SIMULATION MODE ENABLED =========================='); };
  75. engine.on('game_starting', function(data)
  76. {
  77. if (!firstGame) // Display stats only after first game played
  78. {
  79. console.log('==============================');
  80. console.log('[Stats] Session Profit: ' + (totalSatoshiProfit/100).toFixed(2) + ' bits');
  81. console.log('[Stats] Profit Percentage: ' + ((((totalSatoshiProfit + startingBalance) / startingBalance) - 1) * 100).toFixed(3) + '%');
  82. console.log('[Stats] Total Wins: ' + numWins + ' | Total Losses: ' + numLosses);
  83. console.log('[Stats] Max Win Streak: ' + maxWinStreak + ' | Max Loss Streak: ' + maxLossStreak);
  84. }
  85. else
  86. {
  87. firstGame = false;
  88. }
  89. currentGameID = data.game_id;
  90. console.log('=========== New Game ===========');
  91. console.log(simMsg + '[Bot] Game #' + currentGameID);
  92. if (lastResult === 'LOST' && !firstGame) // The stupid game crashed before we could cash out
  93. {
  94. if (currentLossStreak <= streakSecurity) // We lost, but it's okay, we've got it covered
  95. {
  96. currentSatoshiBet *= 4;
  97. currentCashout = cashoutAmounts[currentLossStreak];
  98. }
  99. else // *sigh* We were hoping this wouldn't happen, but it is gambling after all...
  100. {
  101. if (restartOnMaxLossStreak) // start betting over again with recalculated base bet
  102. {
  103. currentSatoshiBet = calcBaseBet();
  104. currentCashout = baseCashout;
  105. currentLossStreak = 0;
  106. console.warn(simMsg + '[Bot] Streak security surpassed, reinitializing bet amount to ' + Math.round(currentSatoshiBet/100));
  107. }
  108. else // Stop betting for now to lick our wounds
  109. {
  110. console.warn(simMsg + '[Bot] Betting stopped after streak security was surpassed');
  111. engine.stop();
  112. }
  113. }
  114. }
  115. else if (firstGame) // Let's get this show on the road
  116. {
  117. currentSatoshiBet = initialBaseBet;
  118. currentCashout = baseCashout;
  119. }
  120. else // Sweet, we won! Adjust the bet based on our balance
  121. {
  122. currentSatoshiBet = calcBaseBet();
  123. currentCashout = baseCashout;
  124. }
  125. currentBitBet = Math.round(currentSatoshiBet/100);
  126. roundedSatoshiBet = Math.round(currentBitBet * 100);
  127. if (currentBitBet > 0)
  128. {
  129. console.log(simMsg + '[Bot] Betting ' + currentBitBet + ' bits, cashing out at ' + currentCashout + 'x');
  130. }
  131. else
  132. {
  133. console.warn(simMsg + '[Bot] Base bet rounds to 0. Balance considered too low to continue.');
  134. engine.stop();
  135. }
  136. if (!simulation)
  137. {
  138. if (currentSatoshiBet <= engine.getBalance()) // Ensure we have enough to bet
  139. {
  140. engine.placeBet(roundedSatoshiBet, Math.round(currentCashout * 100), false);
  141. }
  142. else if (!simulation) // Whoops, we ran out of money
  143. {
  144. console.warn(simMsg + '[Bot] Insufficent funds to continue betting...stopping');
  145. engine.stop();
  146. }
  147. }
  148. });
  149. engine.on('cashed_out', function(data)
  150. {
  151. if (data.username === engine.getUsername())
  152. {
  153. var lastProfit = (roundedSatoshiBet * (data.stopped_at/100)) - roundedSatoshiBet;
  154. console.log('[Bot] Successfully cashed out at ' + (data.stopped_at/100) + 'x (+' + (lastProfit/100).toFixed(2) + ')');
  155. // Update global counters for win
  156. lastResult = 'WON';
  157. numWins++;
  158. currentWinStreak++;
  159. currentLossStreak = 0;
  160. totalSatoshiProfit += lastProfit;
  161. maxWinStreak = (currentWinStreak > maxWinStreak) ? currentWinStreak : maxWinStreak;
  162. }
  163. });
  164. engine.on('game_crash', function(data)
  165. {
  166. if (data.game_crash < (currentCashout * 100) && !firstGame)
  167. {
  168. console.log(simMsg + '[Bot] Game crashed at ' + (data.game_crash/100) + 'x (-' + currentBitBet + ')');
  169. // Update global counters for loss
  170. lastResult = 'LOST';
  171. numLosses++;
  172. currentLossStreak++;
  173. currentWinStreak = 0;
  174. totalSatoshiProfit -= roundedSatoshiBet;
  175. maxLossStreak = (currentLossStreak > maxLossStreak) ? currentLossStreak : maxLossStreak;
  176. }
  177. else if (data.game_crash >= (currentCashout * 100) && simulation && !firstGame)
  178. {
  179. var lastProfit = (roundedSatoshiBet * currentCashout) - roundedSatoshiBet;
  180. console.log(simMsg + '[Bot] Successfully cashed out at ' + currentCashout + 'x (+' + (lastProfit/100).toFixed(2) + ')');
  181. // Update global counters for win
  182. lastResult = 'WON';
  183. numWins++;
  184. currentWinStreak++;
  185. currentLossStreak = 0;
  186. totalSatoshiProfit += lastProfit;
  187. maxWinStreak = (currentWinStreak > maxWinStreak) ? currentWinStreak : maxWinStreak;
  188. }
  189. });

comments powered by Disqus