Bustabit Script_1.14 chance!


SUBMITTED BY: BeNdeR

DATE: Feb. 6, 2018, 7:44 p.m.

FORMAT: Text only

SIZE: 8.9 kB

HITS: 6376

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

comments powered by Disqus