Advertisement
Guest User

Untitled

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