SHARE
TWEET

Untitled

a guest Sep 21st, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //customizable variables;
  2.  
  3. ////////////////////////////////
  4. //
  5. var stopLoss = 0;
  6. var bonusPercentRequired = 1.1;
  7. var BonusPredictionErrorThreshold = 0.2;
  8. var cashout = 300;
  9. var skipGamesWhereMaxBetIsOver = 2000000;
  10.  
  11. var minBetSizeDivider = 30;
  12. var maxBetSizeDivider = 50;
  13.  
  14. //var minBetSizeDivider = 350;
  15. //var maxBetSizeDivider = 550;
  16.  
  17. ////////////////////////////////
  18.  
  19. var bets=[];
  20. var highestBetUser=null;
  21. var highestBetAmount=0;
  22. var ManualTarget='';
  23. var People={};
  24. var TotalRecorderdUsers=0;
  25. var NewUsersAddedThisRound=0;
  26. var TotalPlayersLastGame=0;
  27. var TotalPlayersPlaying=0;
  28. var sumaveragebetamount=0;
  29. var gameBonus=0;
  30. var largestBet=0;
  31. var Sumofbets=0;
  32. var AverageBetSize=0;
  33. var IncreaseArray={}
  34. var ActualBonusSum=0;
  35. var betSize=5;
  36. var basebet=5;
  37. var HighestBonusRecorded=0;
  38. var cashedout=false;
  39. var betPlaced=false;
  40. var ActualgameBeta=0;
  41. var TotalBonusEarned=0;
  42. var emergencycashout=false;
  43. var WonAmt=0;
  44. var LostAmt=0;
  45. var HighestBetCount=0;
  46. var HighestBetUsers=[];
  47. var lastgamestatus='';
  48. var difference=0;
  49. var lostcount=0;
  50.  
  51. var crashedat=0;
  52.  
  53. var highestBetUser=null;
  54. var highestBetAmount=0;
  55. var lost=0;
  56.  
  57. var PendingCashoutsValue=0;//so lets call the sum of all the bets that have not cashed out pending Cashouts
  58.  
  59. var ThisGamesUserInfo=[];
  60. var CashedOutUsers=[];
  61. var cashedoutat=0;
  62. var ExpectedBonus=0;
  63.  
  64. var dontAdd=false;
  65.  
  66. engine.on('player_bet',function (data){
  67.      
  68.      TotalPlayersPlaying++;
  69.      dontAdd=false;
  70.      var target = data.username;
  71.        
  72.       if(target == engine.getUsername()){
  73.           console.log("our bet confirmed");
  74.        } else{
  75.  
  76.                     //console.log(GetAverageBetAmount(target));
  77.  
  78.         //if we have the user in our object,sum their bets.
  79.         //Sum the average bet amount for each user to get this games total expected value in bits
  80.         if(target in People){
  81.         sumaveragebetamount+=GetAverageBetAmount(target);
  82.         }
  83.          }
  84.  
  85.     if((sumaveragebetamount/100) >= HighestBonusRecorded){
  86.     HighestBonusRecorded = sumaveragebetamount/100;
  87.     }
  88.  
  89.     if(TotalPlayersPlaying >= TotalPlayersLastGame-7){
  90.     console.clear();
  91.     var gameBonus = (sumaveragebetamount)/100;
  92.     var gameBeta = gameBonus/(highestBetAmount*100);
  93.            
  94.     var estimatedbonus = (betSize*100)*gameBeta;
  95.     //console.log("[Prediction-GameValue] " + numberWithCommas(parseInt(sumaveragebetamount)));
  96.     //console.log("[GameBeta]" + gameBeta);
  97.     console.log("[Prediction-HighestBet] " + numberWithCommas(parseInt(highestBetAmount)) +
  98.                             //   " [Prediction-Bonus-Pot] " + numberWithCommas(parseInt(gameBonus)) +
  99.                                " [Estimated Bonus In Bits] " + parseFloat(estimatedbonus).toFixed(2) +
  100.                                " [Required to bet] " + parseFloat((bonusPercentRequired / 100) * betSize).toFixed(2));
  101.          
  102.     if(highestBetAmount < skipGamesWhereMaxBetIsOver){
  103.         betSize = highestBetAmount / getRandomInt(minBetSizeDivider,maxBetSizeDivider);
  104.         console.log("Bet " + betSize + " bits cash out at " + cashout);
  105.          
  106.                  if(betPlaced != true && (estimatedbonus >= (bonusPercentRequired / 100) * betSize)){
  107.                    
  108.                             engine.placeBet(Math.round(betSize)*100,cashout,false);
  109.                             console.log("bet placed for " + betSize + " bits cash out at"+cashout);
  110.                             betPlaced=true;
  111.                 }else{
  112.                     console.log("[Skipping Game] Not enough bonus.");
  113.                 }
  114.  
  115.      }else{
  116.         console.log("[Skipped Game] highestBetAmount is too great (skipGamesWhereMaxBetIsOver)");
  117.        
  118.     }
  119.     }
  120. });
  121.  
  122. engine.on('game_started',function (data){
  123.              cashedout = false;
  124.              emergencycashout = false;
  125.         cashedOutUsersCount = 0;
  126.         CashedOutUsers = [];
  127.         RemaindingUsers = [];
  128.         HighestBetUsers = [];
  129.         ThisGamesUserInfo = data;
  130.        
  131.         //console.log("[GAME-STARTED]")
  132.         GetTheHighestBetAmount(data);
  133.         console.log("[GAME-STARTED] - Users betting the same betting amount " + HighestBetCount + " [User(S)] " + highestBetUser );
  134.         //console.log("Highest Bet Users Array Below");
  135.         //console.log(highestBetUser);
  136.                    CleanUpvars();
  137.  
  138.                   var GameValueBits = CalculateGamesActualValueInBits(data);
  139.                   pendingCashoutsValue = GameValueBits;
  140.        
  141.         //console.log("[CHECK!]" + pendingCashoutsValue);
  142.         gameBonus = GameValueBits / 100;
  143.         var gameBeta=gameBonus/(highestBetAmount*100);
  144.         ActualgameBeta = gameBeta;
  145.         ExpectedBonus=((betSize*100)) * gameBeta;
  146.         //console.log("[ACTUAL-GameValue]  " + numberWithCommas(parseInt(GameValueBits)));
  147.         console.log(   "[ACTUAL-HighestBet] " + numberWithCommas(parseInt(highestBetAmount)) +
  148.                                       " [ACTUAL-BonusAmount] " + numberWithCommas(parseInt(gameBonus)) +
  149.                                       " [Expected Bonus] " + parseFloat(ExpectedBonus).toFixed(2));
  150.              
  151.             // if(ExpectedBonus < (1.6 / 100) * betSize){
  152.                  
  153.         if(ExpectedBonus < ((bonusPercentRequired - BonusPredictionErrorThreshold) / 100) * betSize){
  154.             if(betPlaced == true){
  155.                     engine.cashOut();
  156.                     console.log("[Cashing Out Early] Prediction wrong.");
  157.                     dontAdd=true;
  158.                              }
  159.                 }
  160.        
  161.         ActualBonusSum = gameBonus;
  162.         CreateUpdateUserHistory(data);
  163.         console.log("Won " + WonAmt + " Lost " + LostAmt);
  164.        
  165. //People array has now been populated with all the bets that the user has made.
  166.  
  167. //loop through all the players that are playing this game and sum their average bet amount in an attempt to determine the games value.
  168.  
  169. sumaveragebetamount=0;
  170. Sumofbets=0;
  171.  
  172. });
  173.  
  174. var tempBonusPot = 0;
  175. var cashedOutUsersCount = 0;
  176. var FinalUserBonusObject ={};
  177. var CurrentPayout = 0;
  178. var HighestBetUserCashedOut = false;
  179.  
  180. engine.on('cashed_out',function (data){
  181.          
  182.     cashedOutUsersCount++;
  183.  
  184.          var user = data.username;
  185.     var index = HighestBetUsers.indexOf(user);
  186.     if(index >- 1){
  187.         HighestBetUsers.splice(index,1);
  188.         console.log("A highest better cashed out, highest betters remainding -> " + HighestBetUsers);
  189.          }
  190.  
  191.          if(user == highestBetUser){
  192.             HighestBetUserCashedOut = true;
  193.         }
  194.  
  195.     CashedOutUsers[CashedOutUsers.length]={
  196.                                             name:user,
  197.                                             bet:ThisGamesUserInfo[user].bet,
  198.                                             bonus:ThisGamesUserInfo[user].bet*ActualgameBeta
  199.                                              };
  200.    
  201.     //console.clear();
  202.     //console.log('LastCashoutbet'+CashedOutUsers[CashedOutUsers.length-1].bet);
  203.     var i = CashedOutUsers.length;
  204.  
  205.     var UsersBonus=0;
  206.     var TempBonusSum = ActualBonusSum;
  207.     //console.log("[BonusTotal]"+ActualBonusSum);
  208.     var thisbet=0;
  209.    
  210.     do{
  211.           i--;
  212.           thisbet=CashedOutUsers[i].bet;
  213.          
  214.           if(thisbet>0){
  215.                       UsersBonus=thisbet*ActualgameBeta;
  216.                       TempBonusSum-=UsersBonus;
  217.                     }
  218.     //console.log('[USER]'+CashedOutUsers[i].name+"[BET]"+CashedOutUsers[i].bet+"[BONUS]"+UsersBonus+"[ReminingBonus]"+TempBonusSum);
  219.          
  220.     //console.log("[ReminingBonus] " + TempBonusSum + " [Original] " + ActualBonusSum);
  221.     }while(CashedOutUsers > 0);
  222.     //console.log("[ReminingBonus] " + TempBonusSum + " [Original] " + ActualBonusSum);
  223.  
  224.     if(emergencycashout == false && betPlaced == true){
  225.     //if(TempBonusSum < ExpectedBonus && HighestBetUsers.length <= 0){
  226.     if(HighestBetUsers.length <= 0 && TempBonusSum < ExpectedBonus && betPlaced == true){
  227.        
  228.                             console.log("[Highest Better CashedOut] Attempting Bonus Steal!")
  229.                             emergencycashout=true;
  230.                             setTimeout(function (){engine.cashOut();},10);
  231.            
  232.     }
  233.            
  234.     if(TempBonusSum < ExpectedBonus && betPlaced == true){
  235.                             console.log("[Optimum bonus Amount] Attempting Bonus Steal!")
  236.                             emergencycashout=true;
  237.                             setTimeout(function (){engine.cashOut();},10);
  238.            
  239.     }
  240.  
  241.  
  242.     var remaindingUsers = document.getElementsByClassName("user-playing").length;
  243.     if(remaindingUsers <= 10 && betPlaced==true){
  244.             if(engine.getCurrentPayout()> 1.3){
  245.                 console.log("Emergency Cashout not enough users playing!!!!!")
  246.                 emergencycashout=true;
  247.                 engine.cashOut();
  248.                 }
  249.     }
  250.     }
  251.  
  252.  
  253.     if(user == engine.getUsername()){
  254.     cashedoutat=data.stopped_at;
  255.     cashedout=true;
  256.     }
  257.  
  258.     });
  259.  
  260. var won = 0;
  261. var max = 20;
  262.  
  263. engine.on('game_crash',function (data){
  264.    
  265.     HighestBetUserCashedOut = false;
  266.     HighestBetCount = 0;
  267.     betPlaced = false;
  268.    
  269. var balance = engine.getBalance() / 100;
  270.     console.log("balance is " + balance);
  271.     if(balance - betSize <= stopLoss){
  272.             engine.stop();
  273.             console.log("Safety stop loss triggered");
  274.             betSize=0;
  275.        
  276.     }
  277.     if(engine.lastGamePlay()== "LOST"){
  278.                         lastgamestatus = "LOST";
  279.                         }else if(engine.lastGamePlay()== "WON"){
  280.                         lastgamestatus = "WON";
  281.                         }  
  282.    
  283.                 if(lastgamestatus == "LOST"){
  284.                     LostAmt += betSize;
  285.                     difference += betSize;
  286.                     //betSize = calcBet(LostAmt,cashout);
  287.                    
  288.                     console.log("BetSize calculated to " + betSize);
  289.                     lostcount++;
  290.                        
  291.            
  292.                 }else if(lastgamestatus == "WON"){
  293.                    
  294.                 var wonamtcalc = betSize*(cashedoutat / 100);
  295.                         wonamtcalc = wonamtcalc - betSize;
  296.                        
  297.                         if(LostAmt>0){
  298.                             difference -= wonamtcalc;
  299.                             WonAmt += wonamtcalc;
  300.                            
  301.                                
  302.                             if(WonAmt>=LostAmt){
  303.                                 WonAmt = 0;
  304.                                 LostAmt = 0;
  305.                                 betSize = basebet;
  306.                                 basebet += 0.25;
  307.                                 lostcount = 0;
  308.                                 minBetSizeDivider-=1;
  309.                                 minBetSizeDivider-=1;
  310.                             }
  311.                         }else{
  312.                               betSize = basebet;
  313.                         }
  314.                 }else{
  315.                     betSize=5;
  316.                 }
  317.                
  318.     console.log("[PLAYED]["+engine.lastGamePlay()+"][LOSS_AMT] " + LostAmt + " [WON_AMT] " + WonAmt + " [Differnce] " + difference);
  319.  
  320.     console.log("[WonAmt] " + WonAmt + " [Lost Amt] " + LostAmt);
  321.          remaindingUsers=0;
  322.  
  323.          crashedat = data.game_crash;
  324.          console.log("[GAME-CRASHED]" + crashedat);
  325.           ActualBonusSum = 0;
  326.  
  327. var lastbonus = data.bonuses;
  328. var ourbonus = parseFloat(lastbonus[engine.getUsername()] / 100);
  329.         console.log("OurBonus " + ourbonus);
  330.         if(LostAmt > 0 && ourbonus > 0){
  331.             WonAmt += ourbonus;
  332.         }
  333.  
  334. for(var key in lastbonus){
  335. lastbonus[key] = lastbonus[key]/100;
  336. ActualBonusSum += lastbonus[key];
  337. }
  338.  
  339. if(emergencycashout == true){
  340. console.log("EMERGENCY CASHOUT");
  341. }
  342. //console.log(lastbonus);
  343. //console.log("[CONFIRM]ActualBonusSumwas"+numberWithCommas(parseInt(ActualBonusSum)));
  344.  
  345. });
  346.  
  347.  
  348. function  CleanUpvars(){
  349.     NewUsersAddedThisRound=0;
  350.     TotalPlayersLastGame=0;
  351.     //TotalPlayersPlaying=0;
  352.     gameBonus=0;
  353.     //console.clear();
  354. }
  355.  
  356. //Get the average bet amount for the user that is passed to this function
  357. function GetAverageBetAmount(user){
  358.  
  359.     Sumofbets = 0;
  360.     Averagebetincrease = 0;
  361.     averagebetdecrease = 0;
  362.     AverageBetSize = 0;
  363.     var userbetcount = Object.keys(People[user]).length;
  364.  
  365.     //loop through the bets the user has made
  366.     for(i=0;i<userbetcount;i++){
  367.  
  368.     //Sumallthebets-
  369.         if(People[user][i]>0){
  370.               Sumofbets+=People[user][i];
  371.         }
  372.     }
  373.  
  374.     //calculatethemeanaveragebetsizeforthisuserinbits
  375.     AverageBetSize=Sumofbets/userbetcount;
  376.  
  377.     return AverageBetSize;
  378. }
  379.  
  380. function CreateUpdateUserHistory(data){
  381.  
  382. //TODO be able to set to history to last N bets.
  383.  
  384. //Loop through the data from bustabit
  385. var i = 0;
  386. for(i = 0; i < Object.keys(data).length; i++){
  387.  
  388. //Check that the user is already in our object
  389. if(data[Object.keys(data)[i]].username in People){
  390. //The userisinourobject,findthelenngthoftheobject,incrementitandaddthebettotheendofthelist
  391. People[data[Object.keys(data)[i]].username][Object.keys(People[data[Object.keys(data)[i]].username]).length]=data[Object.keys(data)[i]].bet/100;
  392. }else{
  393. //Theuserisnotinourobjectlist,initaliseanewobjectwiththeusernameasthekey
  394. People[data[Object.keys(data)[i]].username]={};
  395.  
  396. //addthebetamountdividedby100tothenewlyinitiatedusernameobject
  397. People[data[Object.keys(data)[i]].username][Object.keys(People[data[Object.keys(data)[i]].username]).length]=data[Object.keys(data)[i]].bet/100;
  398.  
  399. NewUsersAddedThisRound++;
  400. }
  401.  
  402. }
  403. TotalPlayersLastGame=i;
  404.  
  405. //console.log(People);
  406. //console.log('LastPlayerCount'+TotalPlayersLastGame);
  407. //console.log('ThisPlayerCount'+TotalPlayersPlaying);
  408. //console.log('TotalRecordedusers'+Object.keys(People).length);
  409. //console.log('Newusersaddedthisround'+NewUsersAddedThisRound);
  410.  
  411. }
  412.  
  413. //Post game starting
  414. function CalculateGamesActualValueInBits(data){
  415.     var ActualGameValue=0;
  416.    
  417.     for(i=0;i<Object.keys(data).length;i++){
  418.             ActualGameValue+=data[Object.keys(data)[i]].bet/100;
  419.     }
  420.  
  421.         return ActualGameValue;
  422. }
  423.  
  424. function GetTheHighestBetAmount(data){
  425.  
  426.         bets=[];//Resetbets
  427.         for(var i=0;i<Object.keys(data).length;i++){
  428.         bets.push(data[Object.keys(data)[i]].bet);//Getallbets
  429. }
  430.  
  431. for(var i=0;i<Object.keys(data).length;i++){
  432.   if(data[Object.keys(data)[i]].bet==bets.max()){
  433.         HighestBetCount++;
  434.         highestBetUser=data[Object.keys(data)[i]].username;
  435.         highestBetAmount=data[Object.keys(data)[i]].bet/100;
  436.         HighestBetUsers.push(highestBetUser);
  437.      }
  438. }
  439.  
  440. }
  441.  
  442. function numberWithCommas(x){
  443.  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");
  444. }
  445.  
  446. function calcBet(LostAmt,cashout){
  447.     var bet=0;
  448.     var lost;
  449.      if(lostcount >= 2){
  450.         lost = lostcount;
  451.     }else{
  452.         lost = 2;
  453.     }
  454.     do{ bet++;
  455.         var wonamtcalc=bet*(cashout/100);
  456.             wonamtcalc=wonamtcalc-bet;
  457.        
  458. }while(wonamtcalc<=LostAmt/lost);
  459.            
  460. return bet;
  461. }
  462.  
  463.  
  464. //Someuselessfunction :
  465. Array.prototype.max=function (){
  466.  return Math.max.apply(null,this);
  467. };
  468.  
  469. function getRandomInt(min,max){
  470.  return Math.floor(Math.random()*(max-min+1))+min;
  471. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top