Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1. var config = {
  2. wager: {
  3. value: 2500,
  4. type: 'balance',
  5. label: 'Base bet'
  6. },
  7. payout: {
  8. value: 1.57,
  9. type: 'multiplier',
  10. label: 'Dont touch'
  11. },
  12. betMax: {
  13. value: 500000,
  14. type: 'balance',
  15. label: 'Max Bet'
  16. },
  17. stopMin: {
  18. value: 25000000,
  19. type: 'balance',
  20. label: 'Stop when BR <'
  21. },
  22. stopMax: {
  23. value: 75000000,
  24. type: 'balance',
  25. label: 'Stop when BR >'
  26. }
  27. // limit_script_balance: {
  28. // value: 100000,
  29. // type: 'balance',
  30. // label: 'Maximum lose'
  31. // }
  32. };
  33. // https://mtihc.github.io/bustabit-script-simulator/
  34. let wantedProfitInBits = config.wager.value / 100;
  35. let netProfit = 0;
  36. let baseList = [];
  37. let currentGamesPlayed = 0;
  38. let maxBet = 0;
  39. let balanceNeeded = 0;
  40. let wins = 0;
  41. let loses = 0;
  42. let currentlyPlaying = true;
  43. let SPLIT_INTO = 3;
  44. var MAX_LOSE = 0;
  45. var SESSION_NET_PROFIT = 0;
  46. var SESSION_MAX_BALANCE_NEEDED = 0;
  47. var ALL_GAMES = [];
  48. var SESSION_TIMES_ENTERED = 0;
  49. addLast50();
  50. var SMALL_SESSION_NET_PROFIT = 0;
  51. // generateLastNGames(engine.history.first().hash, 100);
  52.  
  53. function addLast50() {
  54. var LATEST_50_GAMES = engine.history.toArray();
  55. // logTime(`LATEST_50 length ${LATEST_50_GAMES.length}`)
  56. for (let i = 0; i <= LATEST_50_GAMES.length - 1; i++) {
  57. ALL_GAMES.unshift(LATEST_50_GAMES[i].bust);
  58. }
  59. ALL_GAMES.push(engine.history.first().bust)
  60. for (var i = 0; i < ALL_GAMES.length - 1; i++) {
  61. // logTime(`id ${i} ${ALL_GAMES[i]}`);
  62. }
  63. }
  64.  
  65. function getLastNWinPercentage(n, targetPayout) {
  66. let wins = 0;
  67. let loses = 0;
  68. let elements_used = 0
  69. for (let i = ALL_GAMES.length - 1; i > -1 && i > ALL_GAMES.length - 1 - n; i--) {
  70. elements_used++;
  71. if (ALL_GAMES[i] < targetPayout) {
  72. loses++;
  73. } else {
  74. wins++;
  75. }
  76. }
  77. let percentage = (wins / elements_used) * 100
  78. logTime(`L${elements_used} wins: ${percentage} %`);
  79. return percentage;
  80. }
  81.  
  82.  
  83. initScript();
  84.  
  85.  
  86. function getCurrentBetLightGuide() {
  87. let currentMultiplier = 0;
  88. let currentBet = null;
  89. if (netProfit >= 0 && currentGamesPlayed > 0) {
  90. return currentBet;
  91. }
  92. if (baseList.length >= 2) {
  93. currentMultiplier = baseList[0] + baseList[baseList.length - 1];
  94. currentBet = (currentMultiplier * config.wager.value);
  95. } else if (baseList.length === 1) {
  96. currentMultiplier = baseList[0];
  97. currentBet = (currentMultiplier * config.wager.value) * 2;
  98. } else {
  99. currentMultiplier = null;
  100. }
  101. return currentBet;
  102. }
  103.  
  104. function initScript() {
  105.  
  106. logTime(`Starting in game ${engine.history.first().id}`);
  107. // Want to earn: ` + wantedProfitInBits + ' bits. Splliting into: ' + SPLIT_INTO);
  108. SESSION_TIMES_ENTERED += 1;
  109. // let wanted_statistics = [800, 700, 600, 500, 400, 300, 200, 150, 100, 50, 40, 30, 20, 10];
  110. // wanted_statistics.forEach(function (element) {
  111. // getLastNWinPercentage(element, 2);
  112. // })
  113. logTime('------------------------------------------------')
  114. // TO DO: Uncomment
  115. // for (let i = 1; i <= SPLIT_INTO; i++) {
  116. // baseList.push(Math.round(wantedProfitInBits / SPLIT_INTO) * 100)
  117. // }
  118. baseList = [1, 2, 3];
  119. netProfit = 0;
  120. currentGamesPlayed = 0;
  121. maxBet = 0;
  122. balanceNeeded = 0;
  123. wins = 0;
  124. loses = 0;
  125. currentlyPlaying = true;
  126. SMALL_SESSION_NET_PROFIT = 0;
  127. }
  128.  
  129. // Try to bet immediately when script starts
  130. if (engine.gameState === "GAME_STARTING") {
  131. makeBet();
  132. }
  133.  
  134. engine.on('GAME_STARTING', onGameStarted);
  135. engine.on('GAME_ENDED', onGameEnded);
  136.  
  137. function onGameStarted() {
  138. while (true)
  139.  
  140. if(userInfo.balance > config.stopMax.value || userInfo.balance < config.stopMin.value)
  141. {
  142. stop(`Stopping script due to balance being either too high or too low...`);
  143. if (getCurrentBetLightGuide > betMax)
  144. {
  145. stop('Stopping script due to bet being too high...')
  146. }
  147.  
  148. if (!currentlyPlaying) {
  149. initScript();
  150. }
  151. let currentBet = getCurrentBetLightGuide();
  152.  
  153. if (!currentBet) {
  154. currentlyPlaying = false;
  155. printEndStatus();
  156. // engine.on('GAME_STARTING', function(){});
  157. initScript();
  158. }
  159. makeBet();
  160. }
  161.  
  162. function onGameEnded() {
  163. ALL_GAMES.push(engine.history.first().bust);
  164. let lastGame = engine.history.first();
  165. if (!lastGame.wager) {
  166. return;
  167. }
  168. let lastBet = getCurrentBetLightGuide();
  169.  
  170. if (lastGame.cashedAt) {
  171. let profit = Math.round(((lastBet * config.payout.value) - lastBet) / 100);
  172. netProfit += profit;
  173. SESSION_NET_PROFIT += profit;
  174. SMALL_SESSION_NET_PROFIT += profit
  175. logTime(`Won ${profit} bits`);
  176. if (baseList.length > 1) {
  177. baseList.splice(baseList.length - 1, 1);
  178. }
  179. baseList.splice(0, 1);
  180. wins += 1;
  181. } else {
  182. var lost = lastBet / 100;
  183. logTime(`Lost ${lost} bits`);
  184. netProfit -= lost;
  185. SESSION_NET_PROFIT -= lost;
  186. baseList.push(lastBet / config.wager.value);
  187. loses += 1;
  188. }
  189. currentGamesPlayed += 1;
  190. // logTime(`Net profit: ${netProfit} Current bet: ${getCurrentBetLightGuide() / 100}`);
  191. let currentBalanceNeeded = netProfit + ((getCurrentBetLightGuide() / 100) * -1);
  192. if (currentBalanceNeeded < balanceNeeded) {
  193. balanceNeeded = currentBalanceNeeded;
  194. }
  195.  
  196. if (currentBalanceNeeded < SESSION_MAX_BALANCE_NEEDED) {
  197. SESSION_MAX_BALANCE_NEEDED = currentBalanceNeeded;
  198. }
  199.  
  200. logTime('Net profit: ' + netProfit + ' bits. Left to play: ' + baseList.length);
  201. }
  202.  
  203. function printEndStatus() {
  204. logTime(`Game ended id: ${engine.history.first().id}. Played: ` + currentGamesPlayed + ' Net profit: ' + netProfit + ' bits. Balance needed: ' + balanceNeeded * -1 + ' bits Max bet: ' + maxBet / 100 + ' bits. Wins: ' + (wins / (wins + loses) * 100) + ' % Loses: ' + (loses / (wins + loses) * 100) + ' %');
  205. logTime(`SESSION NET PROFIT ${SESSION_NET_PROFIT} bits, SESSION MAX BALANCE NEEDED ${SESSION_MAX_BALANCE_NEEDED} bits, SESSION TIMES ENTERED ${SESSION_TIMES_ENTERED}`)
  206. }
  207.  
  208. function makeBet() {
  209. let currentBet = getCurrentBetLightGuide();
  210. if (!currentBet) {
  211. printEndStatus();
  212. return;
  213. }
  214. engine.bet(currentBet, config.payout.value);
  215. if (currentBet > maxBet) {
  216. maxBet = currentBet;
  217. }
  218. logTime('betting ' + Math.round(currentBet / 100) + ' on ' + config.payout.value + ' x');
  219. }
  220.  
  221. function logTime(msg) {
  222. let today = new Date();
  223. let calendarDate = `${today.getDate()}-${today.getMonth() + 1}-${today.getFullYear()}`;
  224. let now = `${today.getHours()}:${today.getMinutes()}:${today.getSeconds()}`;
  225. log(`${now} ${msg}`);
  226. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement