Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = {
- 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)
- 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)
- tLimit: { type: 'text', label: 'Target Count',value:20 }, // for sims 100 performs faster, for live 1000-5000 for larger target selection / accuracy.
- tSwap: { type: 'checkbox', label: 'Target Swaps', value: false }, // allows the script to switch between targets while already playing an existing target.
- minTar: { type: 'multiplier', label: 'Min Target', value: 3}, // lowest allowed target, low balance may require lower value if it's not playing much..
- maxTar: { type: 'multiplier', label: 'Max Target', value: 15}, // max allowed target, values too high can cause long streaks / waste target slots waiting.
- calcPr: { type: 'text', label: 'Precision', value: "1e18" }, // 1e4 to 1e10 is ideal, larger value increases accuracy but may play fewer games.
- 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.
- rsLimit: { type: 'text', label: 'Extend Limit', value: 1.3 }, // Limits how far beyond the expected runspan a target can play before being dropped.
- betScale: { type: 'text', label: 'Scale ', value: 1.03 }, // Adjusts balance increase threshold required to scale up target base bets.
- betSpeed: { type: 'text', label: 'Bet Speed', value: 50}, // controls the delay between placing bets (specified in milliseconds)
- debug: { type: 'checkbox', label: 'Debug Log', value: false} // Enables/disables the logging
- };
- const scaleThresh = Number(config.betScale.value);
- const rsLimit = Number(config.rsLimit.value);
- const maxBet = config.maxBet.value, targetSwap = config.tSwap.value;
- const minTar = config.minTar.value, maxTar = config.maxTar.value, tLimit = Number(config.tLimit.value);
- const minBet = config.minBet.value, betAdj = config.betAdj.value, prc = Number(config.calcPr.value);
- //const minRun = Math.max(1, rd(Math.log(1/prc)/Math.log(1-(1/minTar)))), useDc = config.degcert.value;
- const log = this.log;
- const rb = (bet) => { return Math.max(100, Math.round(bet / 100) * 100); }
- //const rd = (val, dec = 0) => { let d = (10 ** dec); return Math.round(val * d) / d; };
- const cl = (val) => { return Math.ceil(val); }, fl = (val) => { return Math.floor(val); };
- function sleep(t) { return new Promise((r) => { setTimeout(r, t); }); }
- class Targets {
- constructor(limit){
- this.targets = {};
- this.tlimit = limit;
- this.tcount = 0;
- this.active = null;
- }
- get target() {
- if(!this.active || !this.has(this.active)) return null;
- return this.targets[this.active]
- }
- set target(payout){
- if(this.has(payout)){
- this.active = payout;
- this.targets[payout].n = 0;
- if(debug) console.info(`Selected ${payout}x with ${this.targets[payout].b/100} bits base bet.`);
- }else{
- this.active = null;
- }
- }
- has(payout){ return this.targets.hasOwnProperty(payout); }
- add(payout){
- if (this.tcount < this.tlimit && !(payout in this.targets)){
- if(debug)console.info(`Adding ${payout}x to targets`);
- this.targets[payout] = new Target(payout);
- this.tcount++;
- }
- }
- remove(payout){
- if (this.tcount > 0 && (payout in this.targets)){
- if(debug)console.info(`Removing ${payout}x from targets`);
- if(this.active == payout) this.active = null;
- delete this.targets[payout];
- this.tcount--;
- }
- }
- update(result){
- let selected = null, missing = true;
- Promise.all(Object.values(this.targets).map((a) =>{ return a.update(result) })).then(()=>{
- if(this.target !== null && this.target.d === true){
- this.remove(this.active);
- missing = false;
- }
- if(result.multiplier > 1){
- if(this.has(result.multiplier)){
- if(this.targets[result.multiplier].n < 0){
- this.remove(result.multiplier);
- if(debug)console.debug(`Dropping existing target ${result.multiplier}`);
- missing = false;
- }
- }
- }else{
- missing = false;
- }
- if(missing && result.multiplier <= maxTar && result.multiplier >= minTar){
- this.add(result.multiplier);
- }
- let selected = null;
- for(let t in this.targets){
- if(this.targets.hasOwnProperty(t)){
- if(this.targets[t].d == true){
- this.remove(t);
- }else{
- if(!this.active || targetSwap){
- if(this.targets[t].rc === true && (!selected || this.targets[t].bc > this.targets[selected].bc)){
- selected = t;
- }
- }
- }
- }
- }
- if(selected !== null && this.has(selected)){
- if(this.active && targetSwap){
- this.targets[selected].b = this.target.b * (this.target.t / (this.targets[selected].t - 1));
- if(debug)console.info(`Swapping out ${this.target.t}x`);
- this.remove(this.active);
- }
- this.target = selected;
- }
- });
- }
- }
- class Target {
- constructor(payout){
- this.n = -1;
- this.d = false;
- this.t = payout;
- this.b = minBet;
- this.m = this.t / (this.t-betAdj);
- this.p = 0.99 / this.t;
- this.q = 1 - this.p;
- this.rt = cl(Math.log(1 / prc) / Math.log(this.q));
- this.rr = cl(this.rt * (1-(1/Math.E)));
- this.g = 1;
- this.c = this.cc(this.b, this.rt);
- this.cb = -1;
- }
- get rs() { return Math.max(1, this.rt - this.g); }
- get bs() { return (this.cs(this.cb, this.b))}
- get bc() { return ((this.g + this.bs) - this.rt); }
- get rc() { return (this.bs < (this.rt - this.g)); }
- cs(bal, bet){
- return Math.ceil(Math.log((bal + bet * (this.t - 1)) / (this.t * bet)) / Math.log(this.m))
- }
- cc(bet, len){
- return Array(len).fill(bet).reduce((a,b,l)=>{ return (a + rb(b * (this.m ** l))) }, rb(bet));
- //return (bet * (this.m ** len) * this.t) - (bet * (this.t - 1));
- }
- async update(result){
- return new Promise((resolve) => {
- this.g += ((result.multiplier < this.t) ? 1 : -this.g);
- if(this.n > -1){
- this.n++;
- if(result.multiplier >= this.t){
- log(`Won ${(this.b * (this.t - 1))/100} bits on ${this.t}x (Bust: ${result.multiplier}x)`);
- this.d = true;
- }else{
- log(`Lost ${this.b/100} bits on ${this.t}x (Bust: ${result.multiplier}x)`);
- if((this.g / this.rt) > rsLimit){
- log(`Dropped ${this.t}x exceeded max expected span (${this.g+this.bs}/${this.rt}, played ${this.n})`);
- this.d = true;
- }else{
- this.b *= this.m;
- }
- }
- if(this.d === true && targets.active === this.t){
- targets.remove(this.t);
- return resolve();
- }
- }else{
- if(result.balance < this.cb || (result.balance / this.cb) > scaleThresh){
- let adjusted = this.b * ((this.cs(result.balance, this.b) + this.g) / this.rt);
- if(debug)console.debug(`Adjusting bet size for ${this.t} from ${this.b/100} to ${adjusted}`);
- this.b = adjusted;
- this.cb = result.balance;
- }
- }
- return resolve();
- });
- }
- }
- let debugMsg = '', debug = config.debug.value;
- let targets = new Targets(tLimit), results = [];
- /*
- engine.on('GAME_STARTING', () => {
- onGameStarting();
- });
- engine.on('GAME_ENDED', () => {
- let result = buildResult(engine.history.first(), userInfo.balance);
- onGameEnded(result);
- });
- function onGameStarting(){
- if(targets.target) engine.bet(rb(targets.target.b), targets.target.t);
- }
- function buildResult(game, balance){
- balance = balance || engine.userInfo.balance;
- return { multiplier: game.bust, target: game.payout, value: game.wager, balance: balance };
- }
- function onGameEnded(result){ if(!!result) targets.update(result); }
- */
- for(;;){
- let result = null;
- if(targets.target) result = await this.bet(rb(targets.target.b), targets.target.t);
- else result = await this.bet(100, 1.01);
- if(!!result) await targets.update(result);
- await sleep(config.betSpeed.value);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement