Advertisement
billyboy123

Untitled

Dec 6th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.34 KB | None | 0 0
  1. var config = {
  2. minBet: { type: 'balance', label: 'Base Bet Min',value:100 }, // bet amount is auto adjusted up from this value, should be set 10-100 (0.10-1 bits from ui)
  3. maxBet: { type: 'balance', label:'Base Bet Max',value:2500 }, // Limits amount the script is allowed to scale base bet up to (this is NOT max bet limit)
  4. tLimit: { type: 'text', label: 'Target Count',value:20 }, // for sims 100 performs faster, for live 1000-5000 for larger target selection / accuracy.
  5. tSwap: { type: 'checkbox', label: 'Target Swaps', value: false }, // allows the script to switch between targets while already playing an existing target.
  6. minTar: { type: 'multiplier', label: 'Min Target', value: 3}, // lowest allowed target, low balance may require lower value if it's not playing much..
  7. maxTar: { type: 'multiplier', label: 'Max Target', value: 15}, // max allowed target, values too high can cause long streaks / waste target slots waiting.
  8. calcPr: { type: 'text', label: 'Precision', value: "1e18" }, // 1e4 to 1e10 is ideal, larger value increases accuracy but may play fewer games.
  9. betAdj: { type: 'multiplier', label: 'Bet Mult Adj', value: 1.02 }, // Adjusts the on-loss multiplier. default: 1.0, use <1.0 to reduce, 0 for flat bet example.
  10. rsLimit: { type: 'text', label: 'Extend Limit', value: 1.3 }, // Limits how far beyond the expected runspan a target can play before being dropped.
  11. betScale: { type: 'text', label: 'Scale ', value: 1.03 }, // Adjusts balance increase threshold required to scale up target base bets.
  12. betSpeed: { type: 'text', label: 'Bet Speed', value: 50}, // controls the delay between placing bets (specified in milliseconds)
  13. debug: { type: 'checkbox', label: 'Debug Log', value: false} // Enables/disables the logging
  14. };
  15.  
  16. const scaleThresh = Number(config.betScale.value);
  17. const rsLimit = Number(config.rsLimit.value);
  18. const maxBet = config.maxBet.value, targetSwap = config.tSwap.value;
  19. const minTar = config.minTar.value, maxTar = config.maxTar.value, tLimit = Number(config.tLimit.value);
  20. const minBet = config.minBet.value, betAdj = config.betAdj.value, prc = Number(config.calcPr.value);
  21. //const minRun = Math.max(1, rd(Math.log(1/prc)/Math.log(1-(1/minTar)))), useDc = config.degcert.value;
  22. const log = this.log;
  23. const rb = (bet) => { return Math.max(100, Math.round(bet / 100) * 100); }
  24. //const rd = (val, dec = 0) => { let d = (10 ** dec); return Math.round(val * d) / d; };
  25. const cl = (val) => { return Math.ceil(val); }, fl = (val) => { return Math.floor(val); };
  26. function sleep(t) { return new Promise((r) => { setTimeout(r, t); }); }
  27. class Targets {
  28. constructor(limit){
  29. this.targets = {};
  30. this.tlimit = limit;
  31. this.tcount = 0;
  32. this.active = null;
  33. }
  34. get target() {
  35. if(!this.active || !this.has(this.active)) return null;
  36. return this.targets[this.active]
  37. }
  38. set target(payout){
  39. if(this.has(payout)){
  40. this.active = payout;
  41. this.targets[payout].n = 0;
  42. if(debug) console.info(`Selected ${payout}x with ${this.targets[payout].b/100} bits base bet.`);
  43. }else{
  44. this.active = null;
  45. }
  46. }
  47. has(payout){ return this.targets.hasOwnProperty(payout); }
  48. add(payout){
  49. if (this.tcount < this.tlimit && !(payout in this.targets)){
  50. if(debug)console.info(`Adding ${payout}x to targets`);
  51. this.targets[payout] = new Target(payout);
  52. this.tcount++;
  53. }
  54. }
  55. remove(payout){
  56. if (this.tcount > 0 && (payout in this.targets)){
  57. if(debug)console.info(`Removing ${payout}x from targets`);
  58. if(this.active == payout) this.active = null;
  59. delete this.targets[payout];
  60. this.tcount--;
  61. }
  62. }
  63. update(result){
  64. let selected = null, missing = true;
  65. Promise.all(Object.values(this.targets).map((a) =>{ return a.update(result) })).then(()=>{
  66. if(this.target !== null && this.target.d === true){
  67. this.remove(this.active);
  68. missing = false;
  69. }
  70. if(result.multiplier > 1){
  71. if(this.has(result.multiplier)){
  72. if(this.targets[result.multiplier].n < 0){
  73. this.remove(result.multiplier);
  74. if(debug)console.debug(`Dropping existing target ${result.multiplier}`);
  75. missing = false;
  76. }
  77. }
  78. }else{
  79. missing = false;
  80. }
  81. if(missing && result.multiplier <= maxTar && result.multiplier >= minTar){
  82. this.add(result.multiplier);
  83. }
  84. let selected = null;
  85. for(let t in this.targets){
  86. if(this.targets.hasOwnProperty(t)){
  87. if(this.targets[t].d == true){
  88. this.remove(t);
  89. }else{
  90. if(!this.active || targetSwap){
  91. if(this.targets[t].rc === true && (!selected || this.targets[t].bc > this.targets[selected].bc)){
  92. selected = t;
  93. }
  94. }
  95. }
  96. }
  97. }
  98. if(selected !== null && this.has(selected)){
  99. if(this.active && targetSwap){
  100. this.targets[selected].b = this.target.b * (this.target.t / (this.targets[selected].t - 1));
  101. if(debug)console.info(`Swapping out ${this.target.t}x`);
  102. this.remove(this.active);
  103. }
  104. this.target = selected;
  105. }
  106. });
  107. }
  108. }
  109.  
  110. class Target {
  111. constructor(payout){
  112. this.n = -1;
  113. this.d = false;
  114. this.t = payout;
  115. this.b = minBet;
  116. this.m = this.t / (this.t-betAdj);
  117. this.p = 0.99 / this.t;
  118. this.q = 1 - this.p;
  119. this.rt = cl(Math.log(1 / prc) / Math.log(this.q));
  120. this.rr = cl(this.rt * (1-(1/Math.E)));
  121. this.g = 1;
  122. this.c = this.cc(this.b, this.rt);
  123. this.cb = -1;
  124. }
  125. get rs() { return Math.max(1, this.rt - this.g); }
  126. get bs() { return (this.cs(this.cb, this.b))}
  127. get bc() { return ((this.g + this.bs) - this.rt); }
  128. get rc() { return (this.bs < (this.rt - this.g)); }
  129.  
  130. cs(bal, bet){
  131. return Math.ceil(Math.log((bal + bet * (this.t - 1)) / (this.t * bet)) / Math.log(this.m))
  132. }
  133. cc(bet, len){
  134. return Array(len).fill(bet).reduce((a,b,l)=>{ return (a + rb(b * (this.m ** l))) }, rb(bet));
  135. //return (bet * (this.m ** len) * this.t) - (bet * (this.t - 1));
  136. }
  137. async update(result){
  138. return new Promise((resolve) => {
  139. this.g += ((result.multiplier < this.t) ? 1 : -this.g);
  140. if(this.n > -1){
  141. this.n++;
  142. if(result.multiplier >= this.t){
  143. log(`Won ${(this.b * (this.t - 1))/100} bits on ${this.t}x (Bust: ${result.multiplier}x)`);
  144. this.d = true;
  145. }else{
  146. log(`Lost ${this.b/100} bits on ${this.t}x (Bust: ${result.multiplier}x)`);
  147. if((this.g / this.rt) > rsLimit){
  148. log(`Dropped ${this.t}x exceeded max expected span (${this.g+this.bs}/${this.rt}, played ${this.n})`);
  149. this.d = true;
  150. }else{
  151. this.b *= this.m;
  152. }
  153. }
  154. if(this.d === true && targets.active === this.t){
  155. targets.remove(this.t);
  156. return resolve();
  157. }
  158. }else{
  159. if(result.balance < this.cb || (result.balance / this.cb) > scaleThresh){
  160. let adjusted = this.b * ((this.cs(result.balance, this.b) + this.g) / this.rt);
  161. if(debug)console.debug(`Adjusting bet size for ${this.t} from ${this.b/100} to ${adjusted}`);
  162. this.b = adjusted;
  163. this.cb = result.balance;
  164. }
  165. }
  166. return resolve();
  167. });
  168. }
  169. }
  170.  
  171. let debugMsg = '', debug = config.debug.value;
  172. let targets = new Targets(tLimit), results = [];
  173. /*
  174. engine.on('GAME_STARTING', () => {
  175. onGameStarting();
  176. });
  177. engine.on('GAME_ENDED', () => {
  178. let result = buildResult(engine.history.first(), userInfo.balance);
  179. onGameEnded(result);
  180. });
  181.  
  182. function onGameStarting(){
  183. if(targets.target) engine.bet(rb(targets.target.b), targets.target.t);
  184. }
  185.  
  186. function buildResult(game, balance){
  187. balance = balance || engine.userInfo.balance;
  188. return { multiplier: game.bust, target: game.payout, value: game.wager, balance: balance };
  189. }
  190.  
  191. function onGameEnded(result){ if(!!result) targets.update(result); }
  192. */
  193. for(;;){
  194. let result = null;
  195. if(targets.target) result = await this.bet(rb(targets.target.b), targets.target.t);
  196. else result = await this.bet(100, 1.01);
  197. if(!!result) await targets.update(result);
  198. await sleep(config.betSpeed.value);
  199. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement