Guest User

STEEMIT 100 votes reward

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