Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var config = {
- baseBet: { type: 'balance', label: 'BaseBet', value: 500 },
- betMult: { type: 'multiplier', label: 'BetMulti', value: 1.1 },
- frompayout: { type: 'multiplier', label: 'From Payout', value: 10 },
- topayout: { type: 'multiplier', label: 'To Payout', value: 10 },
- calcPrc: { type: 'text', label: 'Precision', value: '1e3' },
- betProb: { type: 'text', label: 'Confidence', value: '1.0' },
- intervalling: { type: 'number', value: 0 },
- whenToStop: { type: "number", label: "Reset bet on Loss balance less than < %", value: 0 },
- whenToStopProfit: { type: "number", label: "Reset bet on Profit, when balance higher than > %", value: 0 },
- stopScript: { type: "checkbox", label: "Stop Script after reach %", value: false },
- };
- /** ----------- -RULES- ------------------------ */
- var rules_allow_max_streak = false;
- var rules_max_streak = 35;
- var rules_how_long_recover_attempts = 3;
- var rules_confident_recover = Number(eval(config.betProb.value)) + 0.01;
- var recovery_mul = 2;
- /** ------------ ----- ------------------------- */
- var Targets = [], engine = this, game = 0, debug = false;
- var session_profit = 0, profit_total = 0, PROFIT = 0;
- /** ------------ -RULES VARS- ------------------ */
- var recovery_attempt = 0;
- var global_playing = 0;
- /** ------------ ----- ------------------------- */
- var req = Number(eval(config.betProb.value));
- var prc = Number(config.calcPrc.value);
- /** ------------ ----- ------------------------- */
- var lock_balance = (this.balance / 100) * (config.whenToStop.value / 100);
- var lock_balance_profit = (this.balance / 100) * (config.whenToStopProfit.value / 100);
- var lock_normal = (this.balance / 100);
- /** ------------ ----- --------------- */
- const rb = (bet) => { return Math.max(100, Math.round(bet / 100) * 100); }
- class Target {
- constructor (payout, bet = config.baseBet.value) {
- this.b = bet; /* Base bet */
- this.p = payout; /* Payout */
- this.cb = bet; /* Current Bet */
- this.m = payout / (payout - config.betMult.value); /* Payout Multiplier */
- this.n = 0; /* Lose Amount in rolls */
- this.prob = Math.round(geoProb(payout, this.n) * prc) / prc; /* Probability */
- this.playing = false; /* State of Playing */
- this.mss = 0; /* Max Streak Seen */
- this.sn = 0; /* Streak Number */
- Targets.push(this); /* Add Target to Array of Targets */
- console.log(`Created target ${this.p}x successfully.`)
- };
- update(result) {
- if (this.sn >= rules_max_streak && rules_allow_max_streak) { /* Statement of Rules - Allow limitation of Max Streak */
- this.cb = this.b; /* Set Current Bet to Base Bet */
- this.sn = 0; /* Reset Streak Number */
- recovery_attempt = rules_how_long_recover_attempts;
- profit_total += session_profit
- this.playing = false; /* Disable Playing Phase */
- global_playing = 0; /* Set index to zero of active target */
- }
- if (result.multiplier < this.p) {
- this.sn++; /* Increase Streak Number */
- session_profit -= this.cb;
- PROFIT -= this.cb;
- this.cb *= this.m; /* Multiply Current Bet */
- } else {
- this.playing = false; /* Disable Playing Phase */
- global_playing = 0; /* Set index to zero of active target */
- if (this.sn > this.mss){ this.mss = this.sn } /* Update Max Streak Seen */
- this.sn = 0; /* Reset Streak Number */
- session_profit += this.cb * (this.p - 1);
- PROFIT += this.cb * (this.p - 1);
- profit_total += session_profit;
- if (recovery_attempt > 0) {
- this.cb = this.b * recovery_mul;
- recovery_attempt--;
- } else {
- this.cb = this.b; /* Set Current Bet to Base Bet */
- }
- if (profit_total < 0) { this.cb *= recovery_mul; }
- game = 0; /* Reset game counter */
- }
- };
- async play(context) {
- if (this.prob >= req) {
- if (global_playing == 0) {
- global_playing = this.p;
- this.playing == true;
- }
- while(true){
- let result = null;
- await checkConditions();
- result = await context.bet(rb(this.cb), this.p);
- Targets_UpdateProbabilities(result);
- this.update(result);
- if (this.playing == false && global_playing != this.p){break;}
- }
- }
- }
- };
- function Targets_UpdateProbabilities(data){
- for (let i = 0; i < Targets.length; i++){
- Targets[i].n += (data.multiplier < Targets[i].p ? 1 : -Targets[i].n);
- Targets[i].prob = Math.round(geoProb(Targets[i].p, Targets[i].n) * prc) / prc;
- }
- }
- function geoProb(x, n) {
- let p = (x > 1 ? 1 / x : 0.01);
- return (1 - (Math.log(1 - ((1 - p) ** n)) / Math.log(p)));
- }
- function Targets_ShowLog(){
- for (let i = 0; i < Targets.length; i++){if (debug) engine.log(`${Targets[i].p}x | max streak seen ${Targets[i].mss} | ${Targets[i].prob}/${req}`)}
- }
- function Targets_ResetBets() {
- for (let i = 0; i < Targets.length; i++) {Targets[ i ].cb = Targets[ i ].b}
- }
- async function Targets_Update(context) {
- for (let i = 0; i < Targets.length; i++) {
- await Targets[ i ].play(context);
- };
- }
- const main = async () => {
- if (rules_confident_recover > 1) rules_confident_recover = 1;
- for (let i = config.frompayout.value; i < config.topayout.value + 1; i = i + 5) { new Target(i) }; /* Create targets from config */
- //var SA = new SeedAlert();
- for (; ;) {
- game++;
- let result = null;
- let output = ``;
- result = await this.bet(100, 1.01);
- //SA.start(result);
- if (result.multiplier == 1.0){PROFIT -= 100;} else {PROFIT += 1;} /* Update Profit for 1.0x instant crashes */
- Targets_UpdateProbabilities(result);
- await Targets_Update(this);
- Targets_ShowLog();
- session_profit = 0;
- if (profit_total > 0) profit_total = 0;
- if (recovery_attempt < 1) {
- req = Number(eval(config.betProb.value));
- } else {
- req = Number(rules_confident_recover);
- }
- output += `${game}# | Profit: ${Math.round(PROFIT / 100)} bits`;
- if (profit_total < 0) output += ` | To recover ${Math.round(profit_total / 100)} bits`;
- //this.clearLog();
- //printStatus();
- await this.log(output);
- await sleep(config.intervalling.value);
- }
- }
- class SeedAlert {
- constructor() {
- this.rolls;
- this.target = 10;
- this.seek = 1000;
- this.rolls = 0;
- this.total_rolls = 0;
- this.seekFound = 0;
- this.seekFoundMax = 0;
- this.total_wins = 0;
- this.bad_win_rate = 7.5;
- this.reset_rolls_after = 2500;
- console.log(`Seed Alert class created.`);
- };
- async start(multiplier){
- this.rolls++;
- this.total_rolls++;
- if (multiplier >= this.seek){
- this.seekFound++;
- if (this.seekFound >= this.seekFoundMax){
- this.seekFoundMax = this.seekFound;
- }
- }
- if (multiplier > this.target){
- this.total_wins++;
- }
- engine.log(`Win rate ${this.target}x: ${this.getWinRate(this.total_wins, this.total_rolls)}%`)
- engine.log(`Current game seed diffculty is ${getSeedState()}`)
- if (this.total_rolls >= this.reset_rolls_after){
- this.total_rolls = 0;
- }
- };
- getSeedState(){
- if (this.getWinRate(this.total_wins, this.total_rolls) <= this.bad_win_rate){
- return "VERY HARD";
- } else {
- return "PLAYABLE";
- }
- };
- getWinRate(wins, games){
- return Math.round((wins / games) * 100).toFixed(2);
- };
- };
- async function checkConditions() {
- printStatus();
- if (engine.balance / 100 <= lock_balance && config.whenToStop.value != 0) {
- gong(1);
- await breakPoint();
- };
- if (engine.balance / 100 > lock_normal + lock_balance_profit && config.whenToStopProfit.value != 0) {
- gong(0);
- await breakPoint();
- };
- };
- async function sleep(ms) { if (ms != 0) return new Promise(resolve => setTimeout(resolve, ms)) };
- async function gong(song_number) {
- let song_name = ``
- if (song_number == 0) {
- song_name = "https://freesound.org/data/previews/411/411639_5121236-lq.mp3"
- } else {
- song_name = "https://freesound.org/data/previews/274/274178_5123851-lq.mp3"
- }
- const audio = new Audio(song_name);
- await audio.play();
- return new Promise(resolve => audio.onended = resolve);
- };
- async function printStatus() {
- if (config.whenToStop.value > 0 && config.whenToStopProfit.value > 0) engine.log(`Till reset | ${Math.round(Math.round(lock_balance - engine.balance / 100))}- / +${Math.round(Math.round(lock_balance_profit + lock_normal) - engine.balance / 100)} |`);
- if (recovery_attempt > 0) { engine.log(`Recovery attempt: ${recovery_attempt}`) }
- }
- async function breakPoint() {
- if (config.stopScript.value) {
- await engine.stop();
- } else {
- Targets_ResetBets();
- lock_balance = (engine.balance / 100) * (config.whenToStop.value / 100);
- lock_balance_profit = (engine.balance / 100) * (config.whenToStopProfit.value / 100);
- lock_normal = (engine.balance / 100);
- engine.log(`Script recalculated lock profit stop and loss stop; new values are:`);
- engine.log(`Stop loss ${Math.round(lock_balance)} bits | Stop profit ${Math.round(lock_normal + lock_balance_profit)} bits`);
- }
- }
- /* Prevent script from lost connection to server */
- while (true) {
- try {
- await main();
- } catch (error) {
- if (error.message === "connection closed") {
- await this.log("Connection closed. Restarting script");
- continue;
- } else if (error.message === "insufficient balance") {
- await this.log("Not enough balance to bet");
- await this.stop();
- } else {
- throw error;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement