Guest User

Untitled

a guest
May 26th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 121.82 KB | None | 0 0
  1. var config = {
  2. //******************COMMON****************** */
  3. PASTE_CASE: { label: "Paste", type: "text", value: "Paste raw text [see F12]" },
  4.  
  5. cb_globals: {
  6. label: "Sandbox", type: "radio", value: "sandbox_mode", options: {
  7. sandbox_mode: { label: "Sandbox Mode (if you set it to true will trigger below configuration to be used)", type: "noop", value: "" },
  8. SETUP: { label: "Configuration Launch Case", type: "number", value: 0 },
  9. merged: { label: "Run both in sandbox and configuration launch", type: "noop", value: "" },
  10. }
  11. },
  12. //******************GLOBAL****************** */
  13. riskHeader: { label: "Global Risk's Settings", type: "noop", value: "" },
  14. RISK_FACTOR: { label: "Risk Factor (skipping amount - 1.0 = 100%, no skipping - 0.0 = 0%)", type: "multiplier", value: 0.7 },
  15. RISK_MULTIPLIER: { label: "Risk Multiplier (multiplier amount - Add)", type: "multiplier", value: 0.0 },
  16. RISK_BASE: { label: "Risk Base (overall base bet regulation)", type: "multiplier", value: 1.0 },
  17. globalHeader: { label: "Global Settings (-1 = disable, 0 = auto)", type: "noop", value: "" },
  18. sb_stw: { label: "STW - Streak To Wait", type: "number", value: 25 },
  19. sb_increase_bb_on_streak: { label: "Increase basebet after streak happen(rolls)", type: "number", value: -1 },
  20.  
  21. //******************BETS****************** */
  22. bettingHeader: { label: "Bets", type: "noop", value: "" },
  23. sb_base_bet: { label: "Base Bet", type: "balance", value: 300 },
  24.  
  25. sb_max_bet_turns: { label: "Max Bet turns (set to -1 to play infinity amount of rolls until hit)", type: "number", value: 27 },
  26. sb_increase_bb_on_wins: { label: "Increase basebet after hit win(satoshi)", type: "number", value: 20 },
  27. sb_increase_bb_times: { label: "Increase basebet after hit win amount times", type: "number", value: 0 },
  28. sb_max_bk_percent: { label: "Max percent bet of balance usage", type: "number", value: 100 },
  29. cb_bets_modes: {
  30. label: "Bet Change [sub, mul, add]", type: "radio", value: "mul", options: {
  31. mul: { label: "Bet Multiplier", type: "multiplier", value: 1.08 },
  32. add: { label: "Static Change", type: "balance", value: 100 },
  33. }
  34. },
  35.  
  36. //***************BETS CONDITIONS**************** */
  37. bets_conditionHeader: { label: "Bets Conditions", type: "noop", value: "" },
  38. sb_bets_maximal: { label: "Bet Maximal", type: "balance", value: 10000000 },
  39. sb_bets_minimal: { label: "Bet Minimal", type: "balance", value: 100 },
  40.  
  41. sb_return_base: { label: "Return to base bet", type: "checkbox", value: true },
  42. sb_return_on_win: { label: "Return on win", type: "checkbox", value: true },
  43. sb_return_on_lose: { label: "Return on lose", type: "checkbox", value: false },
  44.  
  45. //******************TARGETS****************** */
  46. cb_targets: {
  47. label: "Targets", type: "radio", value: "sb_array", options: {
  48. sb_base_target: { label: "Single Strategy", type: "number", value: 10 },
  49. sb_array: { label: "List of Strategies", type: "text", value: "100, 150, 100, 200, 100, 350, 100, 500, 100, 1000" }, // 3, 5, 10, 14, 19, 35, 75, 100, 250
  50. }
  51. },
  52. cb_target_modes: {
  53. label:"Target Change [sub, mul, add]", type: "radio", value: "mul", options: {
  54. mul: { label: "Target Multiplier", type: "multiplier", value: 1.0 },
  55. add: { label: "Static Change", type: "number", value: 0.30 }
  56. }
  57. },
  58.  
  59. //**************TARGET CONDITIONS*************** */
  60. targets_conditionHeader: { label: "Targets Conditions", type: "noop", value: "" },
  61. sb_target_minimal: { label: "Minimal Target", type: "number", value: 2 },
  62. sb_target_maximal: { label: "Maximal Target", type: "number", value: 10000 },
  63.  
  64. sb_target_return_base: { label: "Return to base target", type: "checkbox", value: false },
  65. sb_target_return_on_win: { label: "Return on win", type: "checkbox", value: true },
  66. sb_target_return_on_lose: { label: "Return on lose", type: "checkbox", value: false },
  67.  
  68. //******************GAMEPLAY MODIFICATIONS****************** Gameplay modifications (-1 = Disabled, 0 = Automatic fill) */
  69.  
  70. att_mod_cc_Header: { label: "Gameplay Feature - Chain chase", type: "noop", value: "" },
  71. sb_chain_chase: { label: "Chain chase enabled", type: "checkbox", value: false },
  72. sb_chain_chase_queue: { label: "Chain chase queue", type: "number", value: 3 },
  73.  
  74. att_ff__betsHeader: { label: "Gameplay Feature - Fast Betting", type: "noop", value: "" },
  75. fast_betting_enabled: { label: "Use Fast Betting", type: "checkbox", value: false },
  76. fast_betting_chase: { label: "Target", type: "multiplier", value: 1.01 },
  77. fast_betting_wager: { label: "Flat bets", type: "balance", value: 100 },
  78.  
  79. att_mod_median_Header: { label: "Gameplay Feature - Median", type: "noop", value: "" },
  80. sb_median_enabled: { label: "Use Median", type: "checkbox", value: false },
  81. sb_median_bettable: { label: "Bettable bet", type: "multiplier", value: 0.1 },
  82. sb_median_min_cut: { label: "Min cut", type: "multiplier", value: 1.5 },
  83. sb_median_max_cut: { label: "Max cut", type: "multiplier", value: 2.0 },
  84. sb_median_skips: { label: "Cargo size", type: "number", value: 3 },
  85.  
  86. att_mod_pullee_Header: { label: "Gameplay Feature - Pullee", type: "noop", value: "" },
  87. sb_pullee_enabled: { label: "Use Pullee", type: "checkbox", value: false },
  88. sb_pullee: { label: "Target Power", type: "multiplier", value: 0.1 },
  89.  
  90. //******************CONDITIONS****************** */
  91. conditionHeader: { label: "Condition Regulations", type: "noop", value: "" },
  92. minProfit: { label: "Amount allow to lose", type: "balance", value: -1000000 },
  93. maxProfit: { label: "Maximal profit", type: "balance", value: 1000000 },
  94.  
  95. //******************OTHER*********************** */
  96. otherHeader: { label: "Other Settings", type: "noop", value: "" },
  97. sb_debug: { label: "Minimize output in logging", type: "checkbox", value: true },
  98. sb_debug_common: { label: "Show debug logging", type: "checkbox", value: false },
  99. sb_test: { label: "Test mode [for emulated rolls]", type: "checkbox", value: false },
  100. sb_test_rolling: { label: "Test mode [rolling speed ms]", type: "number", value: 500 },
  101.  
  102. sb_simulation_balance: { label: "Simulation Balance", type: "balance", value: 10000000 },
  103. sb_simulation_mode: { label: "Simulation Mode", type: "checkbox", value: false },
  104. sb_emulate_rolls: { label: "Emulate rolls", type: "checkbox", value: false },
  105. sb_save_script: { label: "Save Script in text format", type: "checkbox", value: false },
  106. };
  107.  
  108. var RISK_FACTOR = config.RISK_FACTOR.value /* Overall change for every target. Set to 0.0 to run without Streak To Wait(STW), set 1.0(100%, i.o. normal) to run with STW feature */
  109. var RISK_MULTIPLIER = config.RISK_MULTIPLIER.value /* Overall change for all bets size after lose bet, value is added to base multiplier for every target */
  110. var RISK_BASE = config.RISK_BASE.value /* Overall change for all targets base bet, if value set to 1, then basebet = 1, if value set to 0.2, then basebet = 20 satoshi */
  111.  
  112. var min_Profit = config.minProfit.value /* max lose before stop. In bits */
  113. var max_Profit = config.maxProfit.value /* max profit before stop. In bits */
  114.  
  115. var change_seed_next_STW = 100000
  116. var change_seed = 20000
  117.  
  118. var BET_PERCENT_FROM_BK = config.sb_max_bk_percent.value /* 100 = 100%, i.o use all balance to bet size */
  119. var FORCE_STOP_IF_LOWER = 0 /* Don't allow balance drop lower than this value. 0 to disable this feature. */
  120.  
  121. const FULL = 1, NORMAL = 0
  122.  
  123. var simulation = config.sb_simulation_mode.value
  124. var simulation_balance = config.sb_simulation_balance.value
  125. var simulation_MODE = NORMAL /* NORMAL - DON'T SHOW TARGET / FULL - SHOW PLACE TARGET */
  126.  
  127. var HIT_MIN_PROFIT_TIMES = 1 /* Moving stop, after reach minProfit X times it will reset script, 0 to disable */
  128. var HIT_MAX_PROFIT_TIMES = 1 /* Moving profit reacher, when hit maxProfit, do reset profit, so you don't risk it, 0 to disable */
  129.  
  130. const LONGEST_DIFFCULTY = 16 /* STW calculated based on this formula */
  131. const PLAY_IN_RANGE = 4 /* Seed numbers has 4 distances, early, mid, late, extra late */
  132. const ver = 2.12
  133.  
  134. // clientSeed, gameSeed, auditSeed
  135. var auditSeed = "469cd022ade40d200fded1da1704709db25bba932ca1bf9c74516b4babc61e6e" //"04097893aa9456880f62b29d4c52cf256935868cf50f0eae7ba9c6c02099b589"
  136. var clientSeed = "b27cd3fe415600657a29590fb07e78e12a45075aec492061e3a52ca5c0f6057b"
  137. var gameSeed = `glorious subdued berry`
  138.  
  139.  
  140. var setup = config.cb_globals.options.SETUP.value /* Preset configuration selector */
  141. /** Number you set must be in function load_pattern() > switch statement > case with number. */
  142.  
  143. var fast_loading_config = true /* Don't wait when script will launch, force it launch immediatly */
  144. var allow_seed_reset = true /* Set rule for seed being reset only when all tactics have ended their period */
  145.  
  146. var ex = { /* Global settings to game */ /*(990000 / ( 100 * (multiplier + 0.01) * 100 - 1))*/
  147. calculate_base: false, /* For big balances, automatically calculates effecient multiplier and STW */
  148. analyze_streaks: true, /* STW mechanism */
  149. winning_frequency: false, // BETA
  150. luck_usage: false, // BETA
  151. reset_to_first_on_hit_win: false, /* Reset all memory bets to base bets after one of targets has won */
  152. increase_STW_by_same_targets: false, /* Increases STW by one with same target and STW amount */
  153. reset_STW_after_game_pass: true,
  154. disable_target_at_bust: false, /* Make current playing target at bust go offline till it ressurect's */
  155. increasing_bets_at_peak: false, /* If tactic have memorized bets, and loses 2 full cycles, it will increase and decrease base bets */
  156. increasing_bets_at_peak_value: 2, /* Multiply base bet on that amount */
  157. mul_target: 1.0,
  158. stop_on_streak_catch: false,
  159. game_sounds: true,
  160. interval_rolls: 0, /* Pause between rolls */
  161. debug: config.sb_debug_common.value, /* Logging output enabled or disabled */
  162. advanced_log: !config.sb_debug.value, /* Logging output for more detailed information, ignores debug value */
  163. reset_static_stats_on_launch: true, /* Reset static client stats on script launch */
  164. session_game: {
  165. enabled: false, /* SessionProfit will risk profit after reach this amount of overall profit */
  166. sessionProfit: 500, /* Amount in bits to risk while chase high multipliers after accuiring that amount of overall profit */
  167. sessionBet: 10, /* Amount to bet while chasing high multipliers after sessionProfit triggered */
  168. sessionTarget: 5, /* Target and higher will trigger sessionProfit to start */
  169. sessionMode: true, /* Single bet session profit or multiple */
  170. },
  171. hard_style: {
  172. enabled: false,
  173. max_loss: -25000,
  174. multiplier: 0.08,
  175. streak_range: 2,
  176. },
  177. fast_betting: {
  178. enabled: config.fast_betting_enabled.value,
  179. wager: config.fast_betting_wager.value,
  180. chase: config.fast_betting_chase.value,
  181. },
  182. stats_logging: {
  183. median: !config.sb_debug.value,
  184. median_cargo: 20000,
  185. median_history: false,
  186. },
  187. increase_basebet_after_streak: config.sb_increase_bb_on_streak.value, // Increase basebet after reach streak amount you set in GUI
  188. increase_basebet_on_wins: config.sb_increase_bb_on_wins.value, // Increase basebet on amount of satoshi you set each time you win unless increase_times more than 0
  189. increase_basebet_times: config.sb_increase_bb_times.value, // Specify for streaks/wins (two values above) amount of times to repeat this, 0 to disable, more than 1 will activate it(each trigger decreases this value)
  190. }
  191.  
  192. var engine = this
  193.  
  194. var last_strategy = null
  195.  
  196. var change_seed_next = change_seed_next_STW
  197. var game_array = new Array(), patterns = new Array(), history = [], queue = [], log_history = [], rolls_history = [], cases = new Array();
  198.  
  199. var PLAY_HARD = false
  200. var skip_enabled = true
  201. var downloaded = false /* Flag for do once operation as prompt save script case */
  202.  
  203. var notification_timeout = 5;
  204. var cool_down = 10;
  205.  
  206. const queueSize = 5;
  207.  
  208. var skipStep = 1; /* 0 = skip | 1 = bet */
  209.  
  210.  
  211.  
  212. var minProfit = min_Profit, maxProfit = max_Profit; // Converting to satoshies
  213.  
  214. const RISK_MULTIPLIER_DEFAULT = config.RISK_MULTIPLIER.value;
  215. const RISK_FACTOR_DEFAULT = config.RISK_FACTOR.value;
  216. const RISK_BASE_DEFAULT = config.RISK_BASE.value;
  217.  
  218. var nonce = 0, PROFIT = 0, TOTAL_BETS = 0, TOTAL_ROLLS = 0, TOTAL_WINS = 0, profit_times = 0,
  219. hard_style_played = 0, WINS_OVERALL = 0, session_value = 0, STREAK_ROLL = 0, luck_activation = 0;
  220.  
  221. var output_message = ``, output_msg = ``, luck_output = ``, output_features = ``
  222.  
  223. var skips_used_by_median = 3, results = [], loses = [], vectorApex, nextBet, DEBUG = true, BET_BALANCE = 0.1;
  224.  
  225. var diffculty_sleep = ex.interval_rolls;
  226.  
  227. /* Syntax to use game_array.push(new Strategy(TARGET, basebet, max turns, STW, multiplier, return_to_base)) */
  228. async function load_pattern() {
  229. Sandbox_delete_strategies()
  230. let description = ``
  231. let listing = ``
  232. let cost = ``
  233.  
  234. let targets = 9.44 // for some cases common setting
  235. let multipliers = 1.2 // for some cases common setting
  236. let segmentar_betting_sectors = 6
  237.  
  238. if (config.cb_globals.value == "sandbox_mode" || config.cb_globals.value == "merged") {
  239. description = `Sandbox mode`
  240. engine.log(description)
  241. await ScriptConstructorArea()
  242. engine.log(`Reading GUI`)
  243. }
  244. if (config.cb_globals.value == "SETUP" || config.cb_globals.value == "merged") {
  245. switch (config.cb_globals.options.SETUP.value) {
  246. case 1:
  247. description = `Create randomized targets, with random bets, turns, stws`
  248. ex.disable_target_at_bust = true
  249. ex.increase_STW_by_same_targets = false
  250. ex.increasing_bets_at_peak = true
  251. ex.reset_STW_after_game_pass = false
  252. ex.reset_to_first_on_hit_win = true
  253.  
  254. RISK_BASE = 1.0
  255. RISK_FACTOR =
  256. minProfit = 500 * 100
  257. maxProfit = 500 * 100
  258. HIT_MAX_PROFIT_TIMES = 30
  259. HIT_MIN_PROFIT_TIMES = 30
  260.  
  261. for (let i = 1; i < segmentar_betting_sectors; i++) {
  262. let rnd_bet = 5
  263. let rnd_target = 16
  264. let rnd_turn = 5
  265. let temp = get_random(1.2) * rnd_target
  266.  
  267. game_array.push(new Strategy(temp, get_random(1.5) * rnd_bet, get_random(1.2) * rnd_turn, 0, get_formula_multiplier(temp) + RISK_MULTIPLIER, true))
  268. }
  269. Sandbox_do_sort_random()
  270. break;
  271. case 2:
  272. description = `Segmentar for 9.44 with 8 max turns and 8 stw and high various Math.pow`
  273.  
  274. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.6), 8, 8, multipliers))
  275. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.8), 6, 8, multipliers))
  276. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.4), 8, 8, multipliers))
  277. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.7), 6, 8, multipliers))
  278.  
  279. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.1), 8, 8, multipliers))
  280. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.3), 8, 8, multipliers))
  281. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.5), 8, 8, multipliers))
  282. game_array.push(new Strategy(targets, Math.pow(1 * RISK_BASE, 2.72), 6, 8, multipliers))
  283. break;
  284. case 3:
  285. description = `Segmentar for 9.44 with 8 max turns and 8 stw`
  286.  
  287. game_array.push(new Strategy(targets, Math.pow(5, 2.72), 8, 8, multipliers))
  288. game_array.push(new Strategy(targets, Math.pow(6, 2.72), 8, 8, multipliers))
  289. game_array.push(new Strategy(targets, Math.pow(7, 2.72), 8, 8, multipliers))
  290. game_array.push(new Strategy(targets, Math.pow(8, 2.72), 8, 8, multipliers))
  291.  
  292. game_array.push(new Strategy(targets, Math.pow(9, 2.72), 8, 8, multipliers))
  293. game_array.push(new Strategy(targets, Math.pow(10, 2.72), 8, 8, multipliers))
  294. game_array.push(new Strategy(targets, Math.pow(11, 2.72), 8, 8, multipliers))
  295. game_array.push(new Strategy(targets, Math.pow(12, 2.72), 8, 8, multipliers))
  296.  
  297. break;
  298. case 4:
  299. description = `Single safe 4.72x play`
  300. cost = `15.000 bits`
  301. RISK_BASE = 1.0
  302. RISK_FACTOR = 1.0
  303. RISK_MULTIPLIER = 0.01
  304. game_array.push(new Strategy(4.72, 2))
  305. break;
  306. case 5:
  307. description = `Many multiplier targets with high multipliers play and risk_multiplier set to 0`
  308. cost = `30.000 bits bankroll`
  309.  
  310. /* Target arrays: 5x - 25x, risk: multiplier 0.0, base 3.0, factor 0.7 */
  311. for (let i = 0; i < 5; i++) {
  312. RISK_BASE = 1.0
  313. RISK_FACTOR = 1.0
  314. RISK_MULTIPLIER = 0.0
  315. let lower_chase_target = i * 5 + 5
  316. let lower_chase_max_turns = 3 * lower_chase_target // To disable max turns, change value to 0.
  317.  
  318. game_array.push(new Strategy(lower_chase_target, 1, lower_chase_max_turns, get_stw(lower_chase_target), get_formula_multiplier(lower_chase_target), true))
  319.  
  320. }
  321. /* Target arrays: 30x - 45x, risk: multiplier 0.0, base 1.0, factor 0.8 */
  322. for (let i = 5; i < 10; i++) {
  323. RISK_BASE = 1.0
  324. RISK_FACTOR = 1.0
  325. RISK_MULTIPLIER = 0.0
  326. game_array.push(new Strategy(i * 5 + 5))
  327.  
  328. }
  329. /* Target arrays: 50x - 95x, risk: multiplier 0.0, base 1.0, factor 1.2 */
  330. for (let i = 0; i < 9; i++) {
  331. RISK_FACTOR = 1.1
  332. RISK_BASE = 1
  333. RISK_MULTIPLIER = 0.0
  334. game_array.push(new Strategy(i * 5 + 50))
  335. }
  336. /* Target arrays: 100x - 200x, risk: multiplier 0.0, base 1.0, factor 1.0 */
  337. for (let i = 0; i < 10; i++) {
  338. RISK_FACTOR = 1.2
  339. RISK_BASE = 1.0
  340. RISK_MULTIPLIER = 0.0
  341. game_array.push(new Strategy(i * 10 + 100))
  342. }
  343. /* Target arrays: 200x - 450x, risk: multiplier 0.0, base 1.0, factor 1.0 */
  344. for (let i = 0; i < 10; i++) {
  345. RISK_FACTOR = 1.35
  346. RISK_BASE = 1.0
  347. RISK_MULTIPLIER = 0.0
  348. game_array.push(new Strategy(i * 25 + 200))
  349. }
  350. /* Target arrays: 500x - 1000x, risk: multiplier 0.0, base 1.0, factor 1.2 */
  351. for (let i = 0; i < 10; i++) {
  352. RISK_FACTOR = 1.5
  353. RISK_BASE = 1.0
  354. RISK_MULTIPLIER = 0.0
  355. game_array.push(new Strategy(i * 50 + 500))
  356. }
  357. /* Target arrays: 5000x - 10000x, risk: multiplier 0.0, base 1.0, factor 1.3 */
  358. for (let i = 0; i < 10; i++) {
  359. RISK_FACTOR = 2.0
  360. RISK_BASE = 1.0
  361. RISK_MULTIPLIER = 0.0
  362. game_array.push(new Strategy(i * 500 + 5000))
  363. }
  364. RISK_FACTOR = 1.0
  365. RISK_BASE = 1.0
  366. RISK_MULTIPLIER = 0.0
  367. break;
  368. case 6:
  369. description = `Many targets from 5x to 1000x`
  370. cost = `30.000 bits`
  371. for (let i = 5; i < 999; i++) {
  372. game_array.push(new Strategy(i))
  373. }
  374. break;
  375. case 7:
  376. description = `26.6x playing with chains`
  377. cost = `30.000 bits`
  378.  
  379. ex.analyze_streaks = true
  380.  
  381. //game_array.push(new Strategy(26.6, 1, 0, 30, 1.049))
  382. game_array.push(new Strategy(26, 1))
  383. game_array[ 0 ].Settings.modifications.chain_chase.enabled = true
  384. game_array[ 0 ].Settings.modifications.chain_chase.queue_base = 1
  385. break;
  386. case 8:
  387. description = `Target manipulation: 20x to 5x; 5x to 20x; 100x to 35x`
  388. cost = `5.000 bits`
  389.  
  390. ex.analyze_streaks = false
  391. RISK_FACTOR = 0.0
  392. let play_20x = true;
  393. let play_5x = true;
  394. let play_100x = false;
  395.  
  396. if (play_20x) {
  397. game_array.push(new Strategy(20, 1))
  398. game_array[ 0 ].Settings.target.multiplier = 0.95
  399. game_array[ 0 ].Settings.target.maximal = 20
  400. game_array[ 0 ].Settings.target.minimal = 5
  401. game_array[ 0 ].Settings.target.digits_round = 0
  402. game_array[ 0 ].Settings.bet.maximal = 1.2
  403. game_array[ 0 ].Settings.bet.base = 1
  404. game_array[ 0 ].Settings.bet.multiplier = 1.113
  405. game_array[ 0 ].Settings.target.return_at.on_win = true
  406. }
  407. if (play_5x) {
  408. game_array.push(new Strategy(5, 1))
  409. game_array[ 1 ].Settings.target.multiplier = 1.0
  410. game_array[ 1 ].Settings.target.maximal = 4
  411. game_array[ 1 ].Settings.target.minimal = 4
  412. game_array[ 1 ].Settings.target.base = 4
  413.  
  414. game_array[ 1 ].Settings.bet.maximal = 1.2
  415. game_array[ 1 ].Settings.bet.base = 1
  416. game_array[ 1 ].Settings.bet.multiplier = 1.3
  417.  
  418. game_array[ 1 ].Settings.target.return_at.on_win = true
  419. }
  420. if (play_100x) {
  421. game_array.push(new Strategy(100, 1))
  422. game_array[ 2 ].Settings.target.multiplier = 0.98
  423. game_array[ 2 ].Settings.target.maximal = 100
  424. game_array[ 2 ].Settings.target.minimal = 35
  425. game_array[ 2 ].Settings.target.digits_round = 0
  426. game_array[ 2 ].Settings.bet.maximal = 0.35
  427. game_array[ 2 ].Settings.bet.base = 1
  428. game_array[ 2 ].Settings.bet.multiplier = 1.015
  429.  
  430. game_array[ 2 ].Settings.target.return_at.on_win = true
  431. }
  432. for (let i = 0; i < game_array.length; i++) {
  433. game_array[ i ].Settings.modifications.chain_chase.enabled = true
  434. if (game_array[ i ].target > 40) {
  435. game_array[ i ].Settings.modifications.chain_chase.queue = 1
  436. game_array[ i ].Settings.modifications.chain_chase.queue_base = 1
  437. } else {
  438. game_array[ i ].Settings.modifications.chain_chase.queue = 2
  439. game_array[ i ].Settings.modifications.chain_chase.queue_base = 2
  440. }
  441. }
  442. break;
  443. case 9:
  444. description = `Target manipulation: 20x to 5x;`
  445. cost = `5.000 bits`
  446.  
  447. ex.analyze_streaks = false;
  448. RISK_FACTOR = 0.0;
  449.  
  450. game_array.push(new Strategy(20, 1));
  451. game_array[ 0 ].Settings.target.multiplier = -1;
  452. game_array[ 0 ].Settings.target.mode = "add";
  453. game_array[ 0 ].Settings.target.return_at.on_win = true;
  454.  
  455. game_array[ 0 ].Settings.target.maximal = 20;
  456. game_array[ 0 ].Settings.target.minimal = 5;
  457. //game_array[ 0 ].Settings.target.digits_round = 0
  458.  
  459. game_array[ 0 ].Settings.bet.base = 1;
  460. game_array[ 0 ].Settings.bet.multiplier = 1.1;
  461.  
  462. break;
  463. case 10:
  464. ex.analyze_streaks = true;
  465.  
  466. RISK_FACTOR = 1;
  467. RISK_MULTIPLIER = 0;
  468. RISK_BASE = 1;
  469. BET_PERCENT_FROM_BK = 100;
  470.  
  471. minProfit = -500000;
  472. maxProfit = 500000;
  473.  
  474. simulation = false;
  475. simulation_balance = 100000;
  476.  
  477. ex.increase_basebet_after_streak = -1;
  478. ex.increase_basebet_on_wins = 0;
  479. ex.increase_basebet_times = 0;
  480.  
  481. game_array.push(new Strategy(10, 100, 35, 7, 1.12, true));
  482. game_array[ 0 ].target = 10;
  483. game_array[ 0 ].basebet = 100;
  484. game_array[ 0 ].basebet_default = 100;
  485. game_array[ 0 ].bet = 100;
  486. game_array[ 0 ].MAX_BET_TURNS = 35;
  487. game_array[ 0 ].STW = 7;
  488. game_array[ 0 ].enabled = true;
  489.  
  490. game_array[ 0 ].Settings.bet.multiplier = 1.12;
  491. game_array[ 0 ].Settings.bet.base = 100;
  492. game_array[ 0 ].Settings.bet.mode = "mul";
  493. game_array[ 0 ].Settings.bet.minimal = 100;
  494. game_array[ 0 ].Settings.bet.maximal = 4800;
  495. game_array[ 0 ].Settings.bet.return_at.RETURN_BASE = true;
  496. game_array[ 0 ].Settings.bet.return_at.on_win = true;
  497. game_array[ 0 ].Settings.bet.return_at.on_lose = false;
  498.  
  499. game_array[ 0 ].Settings.target.multiplier = 1;
  500. game_array[ 0 ].Settings.target.base = 10;
  501. game_array[ 0 ].Settings.target.mode = "mul";
  502. game_array[ 0 ].Settings.target.minimal = 1.01;
  503. game_array[ 0 ].Settings.target.maximal = 10000;
  504. game_array[ 0 ].Settings.target.return_at.return = false;
  505. game_array[ 0 ].Settings.target.return_at.on_win = true;
  506. game_array[ 0 ].Settings.target.return_at.on_lose = false;
  507. break;
  508.  
  509. }
  510. }
  511. if (config.cb_globals.options.SETUP.value == -1 || config.PASTE_CASE.value != `Paste raw text [see F12]`) {
  512. eval("{" + config.PASTE_CASE.value + "}")
  513. }
  514.  
  515. if (!config.sb_simulation_mode.value && config.sb_emulate_rolls.value){
  516. simulation_balance = engine.balance / 100
  517. }
  518.  
  519. if (!fast_loading_config && config.cb_globals.options.SETUP.value != 0) {
  520. engine.log(`Setup [${setup}] [${description}] [${cost}] being initialized.`)
  521. engine.log(`There is list of ${game_array.length} strategies will play:`)
  522. let arr_tar = []
  523. for (let i = 0; i < game_array.length; i++) {
  524. listing = listing + `${game_array[ i ].target}x, `
  525. arr_tar.push(game_array[ i ].target)
  526. }
  527. engine.log(listing)
  528. }
  529. form_cases()
  530. }
  531.  
  532. /* Syntax to use game_array.push(new Strategy(TARGET, basebet, max turns, STW, multiplier, return_to_base)) */
  533. async function ScriptConstructorArea(){
  534. var numArray = JSON.parse(`[${config.cb_targets.options.sb_array.value}]`);
  535. let len = numArray
  536.  
  537. let sm_bb = config.sb_base_bet.value / 100
  538. let sm_t = config.cb_targets.options.sb_base_target.value
  539. let sm_mbt = config.sb_max_bet_turns.value
  540. let sm_stw = config.sb_stw.value
  541. let sm_mul = config.cb_bets_modes.options.mul.value
  542. let sm_rb = config.sb_return_base.value
  543. let sm_mode = config.cb_target_modes.value
  544.  
  545. if (sm_bb == 0){ sm_bb = 1};
  546.  
  547. await engine.log(`Constructing Script`)
  548.  
  549. switch (sm_mbt) {
  550. case -1:
  551. sm_mbt = 0
  552. sm_rb = true
  553. break;
  554. case 0:
  555. sm_mbt = get_max_turns(sm_t)
  556. sm_rb = false
  557. break;
  558. };
  559.  
  560. switch (sm_mul) {
  561. case -1:
  562. sm_mul = 1.0
  563. break;
  564. case 0:
  565. sm_mul = get_formula_multiplier(sm_t)
  566. break;
  567. };
  568.  
  569. switch (sm_stw) {
  570. case -1:
  571. sm_stw = 0
  572. ex.analyze_streaks = false
  573. ex.reset_STW_after_game_pass = false
  574. break;
  575. case 0:
  576. ex.analyze_streaks = true
  577. ex.reset_STW_after_game_pass = true
  578. sm_stw = get_stw(sm_t)
  579. break;
  580. case sm_stw > 0:
  581. ex.analyze_streaks = true
  582. ex.reset_STW_after_game_pass = true
  583. break;
  584. };
  585.  
  586. if (config.cb_targets.value == `sb_array`) {
  587. for (var i = 0; i < numArray.length; i++) {
  588. if (sm_mbt == 0) {
  589. sm_rb = false
  590. sm_mbt = get_max_turns(numArray[ i ])
  591. }
  592. if (config.sb_stw.value == 0) {
  593. ex.analyze_streaks = true
  594. ex.reset_STW_after_game_pass = true
  595. sm_stw = get_stw(numArray[ i ])
  596. }
  597. if (config.sb_stw.value == -1) {
  598. ex.analyze_streaks = false
  599. ex.reset_STW_after_game_pass = false
  600. sm_stw = 0
  601. }
  602. if (config.cb_bets_modes.options.mul.value == 0) { sm_mul = get_formula_multiplier(numArray[ i ]) }
  603.  
  604. game_array.push(new Strategy(numArray[ i ], sm_bb, sm_mbt, sm_stw, sm_mul, sm_rb)) /* Generate tactics */
  605. await ScriptMasterizeArea(i)
  606. engine.log(`sm_bb ${sm_bb}; sm_t ${numArray[ i ]}; sm_mbt ${sm_mbt}; sm_stw ${sm_stw}; sm_mul ${sm_mul}; sm_rb ${sm_rb}`)
  607. };
  608. };
  609. if (config.cb_targets.value == `sb_base_target`) {
  610. game_array.push(new Strategy(sm_t, sm_bb, sm_mbt, sm_stw, sm_mul, sm_rb)) /* Generate tactic */
  611. await ScriptMasterizeArea(0)
  612. engine.log(`sm_bb ${sm_bb}; sm_t ${sm_t}; sm_mbt ${sm_mbt}; sm_stw ${sm_stw}; sm_mul ${sm_mul}; sm_rb ${sm_rb}`)
  613. };
  614. //let isBustable = await check_bustable(clientSeed, auditSeed, gameSeed, 200, true, true, 0)
  615. };
  616.  
  617. /* Allign GUI to Script logic. */
  618. async function ScriptMasterizeArea(number){
  619. /* Bet */
  620. game_array[number].Settings.bet.base = game_array[number].basebet_default
  621. game_array[number].Settings.bet.maximal = config.sb_bets_maximal.value
  622. game_array[number].Settings.bet.minimal = config.sb_bets_minimal.value
  623.  
  624. game_array[number].Settings.bet.mode = config.cb_bets_modes.value // Will show 'mul' or 'add' of string value
  625. if (game_array[number].Settings.bet.mode == "mul"){
  626. let temp_mul = config.cb_bets_modes.options.mul.value
  627. if (temp_mul == 0){
  628. temp_mul = get_formula_multiplier(game_array[number].target)
  629. }
  630. game_array[number].Settings.bet.multiplier = temp_mul
  631. }
  632. if (game_array[number].Settings.bet.mode == "add"){
  633. game_array[number].Settings.bet.multiplier = config.cb_bets_modes.options.add.value
  634. }
  635.  
  636. game_array[number].Settings.bet.return_at.RETURN_BASE = config.sb_return_base.value
  637. game_array[number].Settings.bet.return_at.on_lose = config.sb_return_on_lose.value
  638. game_array[number].Settings.bet.return_at.on_win = config.sb_return_on_win.value
  639.  
  640. /* Target */
  641. game_array[number].Settings.target.base = game_array[number].target
  642. game_array[number].Settings.target.minimal = config.sb_target_minimal.value
  643. game_array[number].Settings.target.maximal = config.sb_target_maximal.value
  644.  
  645. game_array[number].Settings.target.mode = config.cb_target_modes.value
  646. if (game_array[number].Settings.target.mode == "mul"){
  647. game_array[number].Settings.target.multiplier = config.cb_target_modes.options.mul.value
  648. }
  649. if (game_array[number].Settings.target.mode == "add"){
  650. game_array[number].Settings.target.multiplier = config.cb_target_modes.options.add.value
  651. }
  652.  
  653. game_array[number].Settings.target.return_at.return = config.sb_target_return_base.value
  654. game_array[number].Settings.target.return_at.on_win = config.sb_target_return_on_win.value
  655. game_array[number].Settings.target.return_at.on_lose = config.sb_target_return_on_lose.value
  656. //game_array[number].Settings.target.digits_round
  657.  
  658. /* Modifications */
  659. game_array[number].Settings.modifications.chain_chase.enabled = config.sb_chain_chase.value
  660. game_array[number].Settings.modifications.chain_chase.queue_base = config.sb_chain_chase_queue.value
  661.  
  662. game_array[number].Settings.modifications.median.enabled = config.sb_median_enabled.value
  663. game_array[number].Settings.modifications.median.bet_balance = config.sb_median_bettable.value
  664. game_array[number].Settings.modifications.median.max_cut = config.sb_median_max_cut.value
  665. game_array[number].Settings.modifications.median.min_cut = config.sb_median_min_cut.value
  666. game_array[number].Settings.modifications.median.skips_used_by_median = config.sb_median_skips.value
  667.  
  668. game_array[number].Settings.modifications.pullee.enabled = config.sb_pullee_enabled.value
  669. game_array[number].Settings.modifications.pullee.power = config.sb_pullee.value
  670.  
  671. /* Triggers */
  672. if (game_array[number].Settings.modifications.median.enabled){
  673. ex.analyze_streaks = true
  674. game_array[number].ACTION = await median_loop(game_array[number])
  675. }
  676. if (game_array[ number ].Settings.modifications.pullee.enabled){
  677. ex.analyze_streaks = false
  678. let bet_base = config.sb_bets_minimal.value
  679. let bet_max = config.sb_bets_minimal.value
  680. let bet_power = config.cb_bets_modes.options.mul.value
  681.  
  682. let target_base = config.sb_target_minimal.value
  683. let target_max = config.sb_target_maximal.value
  684. let target_power = config.sb_pullee.value
  685.  
  686. let target_pull = CreatePullee(target_base, target_base, target_max, target_power)();
  687. let bet_pull = CreatePullee(bet_base, bet_base, bet_max, bet_power)();
  688.  
  689. game_array[ number ].ACTION = await strategy_pullee(bet_pull, target_pull)
  690. };
  691. };
  692.  
  693. function console_write_create_launch(){
  694. let output = ``
  695.  
  696. output+= `ex.analyze_streaks = ${ex.analyze_streaks};\n\n`
  697.  
  698. output+= `RISK_FACTOR = ${RISK_FACTOR};\n`
  699. output+= `RISK_MULTIPLIER = ${RISK_MULTIPLIER};\n`
  700. output+= `RISK_BASE = ${RISK_BASE};\n`
  701.  
  702. output+= `BET_PERCENT_FROM_BK = ${BET_PERCENT_FROM_BK};\n\n`
  703.  
  704. output+= `minProfit = ${minProfit};\n`
  705. output+= `maxProfit = ${maxProfit};\n\n`
  706.  
  707. //output+= `simulation = ${simulation};\n`
  708. //output+= `simulation_balance = ${simulation_balance};\n\n`
  709.  
  710. output+= `ex.increase_basebet_after_streak = ${ex.increase_basebet_after_streak};\n`
  711. output+= `ex.increase_basebet_on_wins = ${ex.increase_basebet_on_wins};\n`
  712. output+= `ex.increase_basebet_times = ${ex.increase_basebet_times};\n\n`
  713.  
  714. for (let i = 0; i < game_array.length; i++){
  715. let gs = game_array[i]
  716. output+= `game_array.push(new Strategy(${gs.target}, ${config.sb_base_bet.value}, ${gs.MAX_BET_TURNS}, ${gs.STW}, ${gs.Settings.bet.multiplier}, ${gs.Settings.bet.return_at.RETURN_BASE}));\n`
  717. }
  718. output+= `\n`
  719.  
  720. for (let i = 0; i < game_array.length; i++){
  721. let gs = game_array[i]
  722.  
  723. output+= `game_array[ ${i} ].target = ${gs.target};\n`
  724. output+= `game_array[ ${i} ].basebet = ${config.sb_base_bet.value};\n`
  725. output+= `game_array[ ${i} ].basebet_default = ${config.sb_base_bet.value};\n`
  726. output+= `game_array[ ${i} ].bet = ${config.sb_base_bet.value};\n`
  727. output+= `game_array[ ${i} ].MAX_BET_TURNS = ${gs.MAX_BET_TURNS};\n`
  728. output+= `game_array[ ${i} ].STW = ${gs.STW};\n`
  729. output+= `game_array[ ${i} ].enabled = ${gs.enabled};\n\n`
  730.  
  731. /* Object Bet Attributes || bet: multiplier, base, mode(mul/add), minimal, maximal, return_at(RETURN_BASE, on_win, on_lose) */
  732. let temp_mul = gs.Settings.bet.multiplier
  733. if (temp_mul == 0){
  734. temp_mul = get_formula_multiplier(gs.Settings.target)
  735. }
  736. output+= `game_array[ ${i} ].Settings.bet.multiplier = ${gs.Settings.bet.multiplier};\n`
  737. output+= `game_array[ ${i} ].Settings.bet.base = ${gs.Settings.bet.base};\n`
  738. output+= `game_array[ ${i} ].Settings.bet.mode = "${gs.Settings.bet.mode}";\n`
  739. output+= `game_array[ ${i} ].Settings.bet.minimal = ${gs.Settings.bet.minimal};\n`
  740. output+= `game_array[ ${i} ].Settings.bet.maximal = ${gs.Settings.bet.maximal};\n`
  741. output+= `game_array[ ${i} ].Settings.bet.return_at.RETURN_BASE = ${gs.Settings.bet.return_at.RETURN_BASE};\n`
  742. output+= `game_array[ ${i} ].Settings.bet.return_at.on_win = ${gs.Settings.bet.return_at.on_win};\n`
  743. output+= `game_array[ ${i} ].Settings.bet.return_at.on_lose = ${gs.Settings.bet.return_at.on_lose};\n\n`
  744.  
  745. /* Object Target Attributes || target: multiplier, base, mode(mul/add), minimal, maximal, return_at(return, on_win, on_lose) */
  746.  
  747. output+= `game_array[ ${i} ].Settings.target.multiplier = ${gs.Settings.target.multiplier};\n`
  748. output+= `game_array[ ${i} ].Settings.target.base = ${gs.Settings.target.base};\n`
  749. output+= `game_array[ ${i} ].Settings.target.mode = "${gs.Settings.target.mode}";\n`
  750. output+= `game_array[ ${i} ].Settings.target.minimal = ${gs.Settings.target.minimal};\n`
  751. output+= `game_array[ ${i} ].Settings.target.maximal = ${gs.Settings.target.maximal};\n`
  752. output+= `game_array[ ${i} ].Settings.target.return_at.return = ${gs.Settings.target.return_at.return};\n`
  753. output+= `game_array[ ${i} ].Settings.target.return_at.on_win = ${gs.Settings.target.return_at.on_win};\n`
  754. output+= `game_array[ ${i} ].Settings.target.return_at.on_lose = ${gs.Settings.target.return_at.on_lose};\n\n\n`
  755.  
  756. /* Object Trigger Attribute */
  757. output+= `game_array[ ${i} ].ACTION = async function () { await strategy_play(this) };\n\n`
  758.  
  759. /* Object Modifications - Chain Chase */
  760. if (gs.Settings.modifications.chain_chase.enabled){
  761. output+= `game_array[ ${i} ].Settings.modifications.chain_chase.enabled = ${gs.Settings.modifications.chain_chase.enabled};\n`
  762. output+= `game_array[ ${i} ].Settings.modifications.chain_chase.queue_base = ${gs.Settings.modifications.chain_chase.queue_base};\n\n`
  763. }
  764.  
  765. /* Object Modifications - Median */
  766. if (gs.Settings.modifications.median.enabled){
  767. output+= `ex.analyze_streaks = true;\n`
  768. output+= `game_array[ ${i} ].ACTION = await median_loop(game_array[ ${i} ]);\n`
  769. output+= `game_array[ ${i} ].Settings.modifications.median.enabled = ${gs.Settings.modifications.median.enabled};\n`
  770. output+= `game_array[ ${i} ].Settings.modifications.median.min_cut = ${gs.Settings.modifications.median.min_cut};\n`
  771. output+= `game_array[ ${i} ].Settings.modifications.median.max_cut = ${gs.Settings.modifications.median.max_cut};\n`
  772. output+= `game_array[ ${i} ].Settings.modifications.median.bet_balance = ${gs.Settings.modifications.median.bet_balance};\n`
  773. output+= `game_array[ ${i} ].Settings.modifications.median.skips_used_by_median = ${gs.Settings.modifications.median.skips_used_by_median};\n\n`
  774. }
  775.  
  776. /* Object Modifications - Pullee */
  777. if (gs.Settings.modifications.pullee.enabled){
  778. output+= `ex.analyze_streaks = false;\n`
  779. output+= `let bet_base = config.sb_bets_minimal.value;\n`
  780. output+= `let bet_max = config.sb_bets_minimal.value;\n`
  781. output+= `let bet_power = config.cb_bets_modes.options.mul.value;\n\n`
  782.  
  783. output+= `let target_base = config.sb_target_minimal.value;\n`
  784. output+= `let target_max = config.sb_target_maximal.value;\n`
  785. output+= `let target_power = config.sb_pullee.value;\n\n`
  786.  
  787. output+= `let target_pull = CreatePullee(target_base, target_base, target_max, target_power)();\n`
  788. output+= `let bet_pull = CreatePullee(bet_base, bet_base, bet_max, bet_power)();\n\n`
  789.  
  790. output+= `game_array[ ${i} ].ACTION = await strategy_pullee(bet_pull, target_pull);\n`
  791. output+= `game_array[ ${i} ].Settings.modifications.pullee.enabled = ${gs.Settings.modifications.pullee.enabled};\n`
  792. output+= `game_array[ ${i} ].Settings.modifications.pullee.power = ${gs.Settings.modifications.pullee.power};\n`
  793. };
  794. };
  795.  
  796. if (config.PASTE_CASE.value == `Paste raw text [see F12]`){
  797. console.log(output)
  798. if (config.sb_save_script.value && !downloaded){
  799. downloaded = true
  800. downloadString(output, "txt", "ScriptCase.txt")
  801. }
  802. } else {
  803. console.log(config.PASTE_CASE.value)
  804. }
  805. };
  806.  
  807. /* Form prompt for save file with selected information. */
  808. function downloadString(text, fileType, fileName) {
  809. var blob = new Blob([text], { type: fileType });
  810.  
  811. var a = document.createElement('a');
  812. a.download = fileName;
  813. a.href = URL.createObjectURL(blob);
  814. a.dataset.downloadurl = [fileType, a.download, a.href].join(':');
  815. a.style.display = "none";
  816. document.body.appendChild(a);
  817. a.click();
  818. document.body.removeChild(a);
  819. setTimeout(function() { URL.revokeObjectURL(a.href); }, 1500);
  820. };
  821.  
  822. /* Download CSV table history of rolls */
  823. function downloadRolls(){
  824. downloadString(engine.log_history, `text/csv`, `rolls_history.csv`)
  825. };
  826.  
  827. /* Sandbox Constructor - Set all strategies bets return to base. */
  828. function Sandbox_set_return_to_base(isOn = false) {
  829. for (let i = 0; i < game_array.length; i++) {
  830. game_array[ i ].Settings.bet.return_at.RETURN_BASE = isOn;
  831. }
  832. };
  833.  
  834. /* Sandbox Constructor - Set max bet turns to infinity amount. */
  835. function Sandbox_off_max_bet_turns() {
  836. for (let i = 0; i < game_array.length; i++) {
  837. game_array[ i ].MAX_BET_TURNS = 0
  838. }
  839. };
  840.  
  841. /* HARD_STYLE TABLE for maximum profit, ps not using it anymore. */
  842. var bet_levels_hard_hit_mod = {
  843. T2_36: { base: 26, prev: 2 },
  844. T4_72: { base: 12, prev: 2 },
  845. T9_44: { base: 3, prev: 3 },
  846. T15: { base: 1, prev: 1 },
  847. T30: { base: 1, prev: 1 },
  848. T60: { base: 16, prev: 6 },
  849. T100: { base: 6, prev: 1 },
  850. };
  851.  
  852. function check_multiplier(balance, turns, wager = 100, precision = 5) {
  853. let num = 0, bal = balance, mul = 1.01, last = mul;
  854. let p = 0, inc = 0.1;
  855. for (let mul = 1.01; mul < balance; mul += inc) {
  856. bal = balance, num = 0
  857. while (bal > 0) {
  858. bal -= (wager * Math.pow(mul, num));
  859. num++;
  860. }
  861. if (num < turns) {
  862. if (p >= precision) return last;
  863. p++ , mul = last, inc /= 10;
  864. }
  865. last = mul;
  866. }
  867. };
  868.  
  869. async function calculate_bankroll() {
  870. let balance = 0
  871. if (!simulation) {
  872. engine.log(`Starting calculating max turns for balance ${engine.balance / 100}`)
  873. balance = engine.balance
  874. } else {
  875. engine.log(`Starting calculating max turns for simulated balance ${simulation_balance / 100}`)
  876. balance = simulation_balance
  877. }
  878.  
  879. for (let i = 0; i < game_array.length; i++) {
  880. if (ex.debug) {
  881. engine.log(`Calculating bets for ${game_array[ i ].target}x, base bet ${game_array[ i ].basebet / 100}, STW ${game_array[ i ].STW}`)
  882. engine.log(`${game_array[ i ].target}x, mul ${game_array[ i ].Settings.bet.multiplier.toFixed(5)}`)
  883. }
  884.  
  885. let last_bet_size = 0
  886. let turns = 0
  887. let start_bet_size = game_array[ i ].basebet
  888. let bet_size = start_bet_size
  889. let cost = 0
  890. let longest = Math.round(game_array[ i ].target * LONGEST_DIFFCULTY)
  891. let solution_found = false
  892. let multiplier_found = false
  893.  
  894. while (!solution_found) {
  895. turns++
  896. last_bet_size = bet_size
  897. bet_size *= game_array[ i ].multiplier
  898.  
  899. cost = cost + bet_size
  900.  
  901. if (cost > balance) {
  902. turns--
  903. cost = cost - bet_size
  904. bet_size = last_bet_size
  905. solution_found = true
  906. }
  907. }
  908. game_array[ i ].MAX_BET_TURNS = turns
  909.  
  910. if (!multiplier_found) {
  911. if (ex.debug) { engine.log(`Finding effecient multiplier for ${game_array[ i ].target}x...`) }
  912. game_array[ i ].Settings.bet.multiplier = check_multiplier(balance, game_array[ i ].MAX_BET_TURNS, 100, 4)
  913. if (ex.debug) { engine.log(`Found! Multiplier for ${game_array[ i ].target}x is set to ${game_array[ i ].multiplier.toFixed(6)}`) }
  914. multiplier_found = true
  915. last_bet_size = 0
  916. turns = 0
  917. start_bet_size = game_array[ i ].basebet
  918. bet_size = start_bet_size
  919. cost = 0
  920. longest = Math.round(game_array[ i ].target * LONGEST_DIFFCULTY)
  921. solution_found = false
  922.  
  923. while (!solution_found) {
  924. turns++
  925. last_bet_size = bet_size
  926. bet_size *= game_array[ i ].Settings.bet.multiplier
  927.  
  928. cost = cost + bet_size
  929.  
  930. if (cost > balance) {
  931. turns--
  932. cost = cost - bet_size
  933. bet_size = last_bet_size
  934. solution_found = true
  935. if (ex.debug) { engine.log(`Final: turn ${turns} cost ${Math.round(cost / 100)}, last bet ${Math.round(last_bet_size / 100)} bits, Reach cap of balance.`) }
  936.  
  937. } else {
  938. if (ex.debug) { engine.log(`Turn ${turns} cost ${Math.round(cost / 100)}, last bet ${Math.round(bet_size / 100)} bits`) }
  939. }
  940. }
  941. }
  942. let check_stw = false
  943. while (!check_stw) {
  944. if (game_array[ i ].STW + turns <= longest) {
  945. game_array[ i ].STW += 1
  946. } else {
  947. check_stw = true
  948. }
  949. }
  950. if (ex.debug || ex.advanced_log) {
  951. engine.log(`Strategy ${game_array[ i ].target}x calculation is done.`)
  952. }
  953.  
  954. if (ex.debug) {
  955. engine.log(`${game_array[ i ].target}x STW: ${game_array[ i ].STW}, max cost ${Math.round(cost / 100)} bits , multiplier ${game_array[ i ].multiplier.toFixed(5)}, max bet ${Math.round(bet_size)}, turns ${turns}(+${game_array[ i ].STW})=${turns + game_array[ i ].STW} safe is ${longest}`)
  956. await sleep(10)
  957. }
  958.  
  959. }
  960. };
  961.  
  962. (function (I) {
  963. function w(c, a, d) {
  964. var l = 0, b = [], g = 0, f, n, k, e, h, q, y, p, m = !1, t = [], r = [], u, z = !1; d = d || {}; f = d.encoding || "UTF8"; u = d.numRounds || 1; if (u !== parseInt(u, 10) || 1 > u) throw Error("numRounds must a integer >= 1"); if (0 === c.lastIndexOf("SHA-", 0)) if (q = function (b, a) { return A(b, a, c) }, y = function (b, a, l, f) {
  965. var g, e; if ("SHA-224" === c || "SHA-256" === c) g = (a + 65 >>> 9 << 4) + 15, e = 16; else throw Error("Unexpected error in SHA-2 implementation"); for (; b.length <= g;)b.push(0); b[ a >>> 5 ] |= 128 << 24 - a % 32; a = a + l; b[ g ] = a & 4294967295;
  966. b[ g - 1 ] = a / 4294967296 | 0; l = b.length; for (a = 0; a < l; a += e)f = A(b.slice(a, a + e), f, c); if ("SHA-224" === c) b = [ f[ 0 ], f[ 1 ], f[ 2 ], f[ 3 ], f[ 4 ], f[ 5 ], f[ 6 ] ]; else if ("SHA-256" === c) b = f; else throw Error("Unexpected error in SHA-2 implementation"); return b
  967. }, p = function (b) { return b.slice() }, "SHA-224" === c) h = 512, e = 224; else if ("SHA-256" === c) h = 512, e = 256; else throw Error("Chosen SHA variant is not supported"); else throw Error("Chosen SHA variant is not supported"); k = B(a, f); n = x(c); this.setHMACKey = function (b, a, g) {
  968. var e; if (!0 === m) throw Error("HMAC key already set");
  969. if (!0 === z) throw Error("Cannot set HMAC key after calling update"); f = (g || {}).encoding || "UTF8"; a = B(a, f)(b); b = a.binLen; a = a.value; e = h >>> 3; g = e / 4 - 1; if (e < b / 8) { for (a = y(a, b, 0, x(c)); a.length <= g;)a.push(0); a[ g ] &= 4294967040 } else if (e > b / 8) { for (; a.length <= g;)a.push(0); a[ g ] &= 4294967040 } for (b = 0; b <= g; b += 1)t[ b ] = a[ b ] ^ 909522486, r[ b ] = a[ b ] ^ 1549556828; n = q(t, n); l = h; m = !0
  970. }; this.update = function (a) {
  971. var c, f, e, d = 0, p = h >>> 5; c = k(a, b, g); a = c.binLen; f = c.value; c = a >>> 5; for (e = 0; e < c; e += p)d + h <= a && (n = q(f.slice(e, e + p), n), d += h); l += d; b = f.slice(d >>>
  972. 5); g = a % h; z = !0
  973. }; this.getHash = function (a, f) {
  974. var d, h, k, q; if (!0 === m) throw Error("Cannot call getHash after setting HMAC key"); k = C(f); switch (a) {
  975. case "HEX": d = function (a) { return D(a, e, k) }; break; case "B64": d = function (a) { return E(a, e, k) }; break; case "BYTES": d = function (a) { return F(a, e) }; break; case "ARRAYBUFFER": try { h = new ArrayBuffer(0) } catch (v) { throw Error("ARRAYBUFFER not supported by this environment"); } d = function (a) { return G(a, e) }; break; default: throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER");
  976. }q = y(b.slice(), g, l, p(n)); for (h = 1; h < u; h += 1)q = y(q, e, 0, x(c)); return d(q)
  977. }; this.getHMAC = function (a, f) {
  978. var d, k, t, u; if (!1 === m) throw Error("Cannot call getHMAC without first setting HMAC key"); t = C(f); switch (a) {
  979. case "HEX": d = function (a) { return D(a, e, t) }; break; case "B64": d = function (a) { return E(a, e, t) }; break; case "BYTES": d = function (a) { return F(a, e) }; break; case "ARRAYBUFFER": try { d = new ArrayBuffer(0) } catch (v) { throw Error("ARRAYBUFFER not supported by this environment"); } d = function (a) { return G(a, e) }; break; default: throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER");
  980. }k = y(b.slice(), g, l, p(n)); u = q(r, x(c)); u = y(k, e, h, u); return d(u)
  981. }
  982. } function m() { } function D(c, a, d) { var l = ""; a /= 8; var b, g; for (b = 0; b < a; b += 1)g = c[ b >>> 2 ] >>> 8 * (3 + b % 4 * -1), l += "0123456789abcdef".charAt(g >>> 4 & 15) + "0123456789abcdef".charAt(g & 15); return d.outputUpper ? l.toUpperCase() : l } function E(c, a, d) {
  983. var l = "", b = a / 8, g, f, n; for (g = 0; g < b; g += 3)for (f = g + 1 < b ? c[ g + 1 >>> 2 ] : 0, n = g + 2 < b ? c[ g + 2 >>> 2 ] : 0, n = (c[ g >>> 2 ] >>> 8 * (3 + g % 4 * -1) & 255) << 16 | (f >>> 8 * (3 + (g + 1) % 4 * -1) & 255) << 8 | n >>> 8 * (3 + (g + 2) % 4 * -1) & 255, f = 0; 4 > f; f += 1)8 * g + 6 * f <= a ? l += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n >>>
  984. 6 * (3 - f) & 63) : l += d.b64Pad; return l
  985. } function F(c, a) { var d = "", l = a / 8, b, g; for (b = 0; b < l; b += 1)g = c[ b >>> 2 ] >>> 8 * (3 + b % 4 * -1) & 255, d += String.fromCharCode(g); return d } function G(c, a) { var d = a / 8, l, b = new ArrayBuffer(d), g; g = new Uint8Array(b); for (l = 0; l < d; l += 1)g[ l ] = c[ l >>> 2 ] >>> 8 * (3 + l % 4 * -1) & 255; return b } function C(c) {
  986. var a = { outputUpper: !1, b64Pad: "=", shakeLen: -1 }; c = c || {}; a.outputUpper = c.outputUpper || !1; !0 === c.hasOwnProperty("b64Pad") && (a.b64Pad = c.b64Pad); if ("boolean" !== typeof a.outputUpper) throw Error("Invalid outputUpper formatting option");
  987. if ("string" !== typeof a.b64Pad) throw Error("Invalid b64Pad formatting option"); return a
  988. } function B(c, a) {
  989. var d; switch (a) { case "UTF8": case "UTF16BE": case "UTF16LE": break; default: throw Error("encoding must be UTF8, UTF16BE, or UTF16LE"); }switch (c) {
  990. case "HEX": d = function (a, b, c) {
  991. var f = a.length, d, k, e, h, q; if (0 !== f % 2) throw Error("String of HEX type must be in byte increments"); b = b || [ 0 ]; c = c || 0; q = c >>> 3; for (d = 0; d < f; d += 2) {
  992. k = parseInt(a.substr(d, 2), 16); if (isNaN(k)) throw Error("String of HEX type contains invalid characters");
  993. h = (d >>> 1) + q; for (e = h >>> 2; b.length <= e;)b.push(0); b[ e ] |= k << 8 * (3 + h % 4 * -1)
  994. } return { value: b, binLen: 4 * f + c }
  995. }; break; case "TEXT": d = function (c, b, d) {
  996. var f, n, k = 0, e, h, q, m, p, r; b = b || [ 0 ]; d = d || 0; q = d >>> 3; if ("UTF8" === a) for (r = 3, e = 0; e < c.length; e += 1)for (f = c.charCodeAt(e), n = [], 128 > f ? n.push(f) : 2048 > f ? (n.push(192 | f >>> 6), n.push(128 | f & 63)) : 55296 > f || 57344 <= f ? n.push(224 | f >>> 12, 128 | f >>> 6 & 63, 128 | f & 63) : (e += 1, f = 65536 + ((f & 1023) << 10 | c.charCodeAt(e) & 1023), n.push(240 | f >>> 18, 128 | f >>> 12 & 63, 128 | f >>> 6 & 63, 128 | f & 63)), h = 0; h < n.length; h += 1) {
  997. p = k +
  998. q; for (m = p >>> 2; b.length <= m;)b.push(0); b[ m ] |= n[ h ] << 8 * (r + p % 4 * -1); k += 1
  999. } else if ("UTF16BE" === a || "UTF16LE" === a) for (r = 2, n = "UTF16LE" === a && !0 || "UTF16LE" !== a && !1, e = 0; e < c.length; e += 1) { f = c.charCodeAt(e); !0 === n && (h = f & 255, f = h << 8 | f >>> 8); p = k + q; for (m = p >>> 2; b.length <= m;)b.push(0); b[ m ] |= f << 8 * (r + p % 4 * -1); k += 2 } return { value: b, binLen: 8 * k + d }
  1000. }; break; case "B64": d = function (a, b, c) {
  1001. var f = 0, d, k, e, h, q, m, p; if (-1 === a.search(/^[a-zA-Z0-9=+\/]+$/)) throw Error("Invalid character in base-64 string"); k = a.indexOf("="); a = a.replace(/\=/g,
  1002. ""); if (-1 !== k && k < a.length) throw Error("Invalid '=' found in base-64 string"); b = b || [ 0 ]; c = c || 0; m = c >>> 3; for (k = 0; k < a.length; k += 4) { q = a.substr(k, 4); for (e = h = 0; e < q.length; e += 1)d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(q[ e ]), h |= d << 18 - 6 * e; for (e = 0; e < q.length - 1; e += 1) { p = f + m; for (d = p >>> 2; b.length <= d;)b.push(0); b[ d ] |= (h >>> 16 - 8 * e & 255) << 8 * (3 + p % 4 * -1); f += 1 } } return { value: b, binLen: 8 * f + c }
  1003. }; break; case "BYTES": d = function (a, b, c) {
  1004. var d, n, k, e, h; b = b || [ 0 ]; c = c || 0; k = c >>> 3; for (n = 0; n < a.length; n +=
  1005. 1)d = a.charCodeAt(n), h = n + k, e = h >>> 2, b.length <= e && b.push(0), b[ e ] |= d << 8 * (3 + h % 4 * -1); return { value: b, binLen: 8 * a.length + c }
  1006. }; break; case "ARRAYBUFFER": try { d = new ArrayBuffer(0) } catch (l) { throw Error("ARRAYBUFFER not supported by this environment"); } d = function (a, b, c) { var d, n, k, e, h; b = b || [ 0 ]; c = c || 0; n = c >>> 3; h = new Uint8Array(a); for (d = 0; d < a.byteLength; d += 1)e = d + n, k = e >>> 2, b.length <= k && b.push(0), b[ k ] |= h[ d ] << 8 * (3 + e % 4 * -1); return { value: b, binLen: 8 * a.byteLength + c } }; break; default: throw Error("format must be HEX, TEXT, B64, BYTES, or ARRAYBUFFER");
  1007. }return d
  1008. } function r(c, a) { return c >>> a | c << 32 - a } function J(c, a, d) { return c & a ^ ~c & d } function K(c, a, d) { return c & a ^ c & d ^ a & d } function L(c) { return r(c, 2) ^ r(c, 13) ^ r(c, 22) } function M(c) { return r(c, 6) ^ r(c, 11) ^ r(c, 25) } function N(c) { return r(c, 7) ^ r(c, 18) ^ c >>> 3 } function O(c) { return r(c, 17) ^ r(c, 19) ^ c >>> 10 } function P(c, a) { var d = (c & 65535) + (a & 65535); return ((c >>> 16) + (a >>> 16) + (d >>> 16) & 65535) << 16 | d & 65535 } function Q(c, a, d, l) {
  1009. var b = (c & 65535) + (a & 65535) + (d & 65535) + (l & 65535); return ((c >>> 16) + (a >>> 16) + (d >>> 16) + (l >>> 16) + (b >>>
  1010. 16) & 65535) << 16 | b & 65535
  1011. } function R(c, a, d, l, b) { var g = (c & 65535) + (a & 65535) + (d & 65535) + (l & 65535) + (b & 65535); return ((c >>> 16) + (a >>> 16) + (d >>> 16) + (l >>> 16) + (b >>> 16) + (g >>> 16) & 65535) << 16 | g & 65535 } function x(c) {
  1012. var a = [], d; if (0 === c.lastIndexOf("SHA-", 0)) switch (a = [ 3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428 ], d = [ 1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225 ], c) {
  1013. case "SHA-224": break; case "SHA-256": a = d; break; case "SHA-384": a = [ new m, new m,
  1014. new m, new m, new m, new m, new m, new m ]; break; case "SHA-512": a = [ new m, new m, new m, new m, new m, new m, new m, new m ]; break; default: throw Error("Unknown SHA variant");
  1015. } else throw Error("No SHA variants supported"); return a
  1016. } function A(c, a, d) {
  1017. var l, b, g, f, n, k, e, h, m, r, p, w, t, x, u, z, A, B, C, D, E, F, v = [], G; if ("SHA-224" === d || "SHA-256" === d) r = 64, w = 1, F = Number, t = P, x = Q, u = R, z = N, A = O, B = L, C = M, E = K, D = J, G = H; else throw Error("Unexpected error in SHA-2 implementation"); d = a[ 0 ]; l = a[ 1 ]; b = a[ 2 ]; g = a[ 3 ]; f = a[ 4 ]; n = a[ 5 ]; k = a[ 6 ]; e = a[ 7 ]; for (p =
  1018. 0; p < r; p += 1)16 > p ? (m = p * w, h = c.length <= m ? 0 : c[ m ], m = c.length <= m + 1 ? 0 : c[ m + 1 ], v[ p ] = new F(h, m)) : v[ p ] = x(A(v[ p - 2 ]), v[ p - 7 ], z(v[ p - 15 ]), v[ p - 16 ]), h = u(e, C(f), D(f, n, k), G[ p ], v[ p ]), m = t(B(d), E(d, l, b)), e = k, k = n, n = f, f = t(g, h), g = b, b = l, l = d, d = t(h, m); a[ 0 ] = t(d, a[ 0 ]); a[ 1 ] = t(l, a[ 1 ]); a[ 2 ] = t(b, a[ 2 ]); a[ 3 ] = t(g, a[ 3 ]); a[ 4 ] = t(f, a[ 4 ]); a[ 5 ] = t(n, a[ 5 ]); a[ 6 ] = t(k, a[ 6 ]); a[ 7 ] = t(e, a[ 7 ]); return a
  1019. } var H; H = [ 1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206,
  1020. 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474,
  1021. 2756734187, 3204031479, 3329325298 ]; "function" === typeof define && define.amd ? define(function () { return w }) : "undefined" !== typeof exports ? ("undefined" !== typeof module && module.exports && (module.exports = w), exports = w) : I.jsSHA = w
  1022. })(window);
  1023.  
  1024. /* Generate emulated roll. */
  1025. async function gameResult(nonce) {
  1026. let shaObj = new jsSHA("SHA-256", "TEXT");
  1027. shaObj.setHMACKey(auditSeed, "HEX");
  1028. shaObj.update(`${gameSeed}|${clientSeed}|${nonce}`);
  1029. let hash = shaObj.getHMAC("HEX");
  1030. hash = hash.substr(0, 52 / 4);
  1031. const X = parseInt(hash, 16) / Math.pow(2, 52);
  1032. const multiplier = Math.floor(99 / (1 - X));
  1033. return Math.max(100, Math.min(multiplier, 100000000));
  1034. };
  1035.  
  1036. //****************************ASSIGN AREA**************************************** */
  1037.  
  1038. const origBet = this.bet;
  1039. const origSkip = this.skip;
  1040.  
  1041. let emulation, _nonce = -1
  1042. let rolling_test = 0
  1043.  
  1044. if (config.sb_test.value){rolling_test = config.sb_test_rolling.value}
  1045.  
  1046. let nonce_x = async () => {_nonce = _nonce + 1; await sleep(rolling_test); return _nonce};
  1047.  
  1048. this.bet = async function () {
  1049. console_group()
  1050. if (config.sb_emulate_rolls.value){
  1051. emulation = await gameResult(await nonce_x()) / 100;
  1052. return {multiplier: emulation}
  1053. } else {
  1054. return origBet.apply(this, arguments);
  1055. }
  1056. };
  1057.  
  1058. this.skip = async function () {
  1059. console_group()
  1060. if (config.sb_emulate_rolls.value){
  1061. emulation = await gameResult(await nonce_x()) / 100;
  1062. return {multiplier: emulation}
  1063. } else {
  1064. return origSkip.apply(this, arguments);
  1065. }
  1066. };
  1067.  
  1068. //****************************************************************************** */
  1069.  
  1070. /**
  1071. * Emulate test for bust.
  1072. * @param {string} clientSeed
  1073. * @param {string} auditSeed
  1074. * @param {string} gameSeed
  1075. * @param {number} endNonce
  1076. * @param {boolean} debug_verifier
  1077. * @param {boolean} debug_stats
  1078. * @param {number} startNonce
  1079. */
  1080. async function check_bustable(clientSeed = ``, auditSeed = ``, gameSeed = ``, endNonce = 1000, debug_verifier = true, debug_stats = true, startNonce = 0) {
  1081. if (startNonce == null) { startNonce = 0 }
  1082. if (endNonce == null || endNonce == 0) { endNonce = 1000 }
  1083. if (clientSeed == null || clientSeed == ``) { clientSeed = '04097893aa9456880f62b29d4c52cf256935868cf50f0eae7ba9c6c02099b589' }
  1084. if (auditSeed == null || auditSeed == ``) { auditSeed = 'b27cd3fe415600657a29590fb07e78e12a45075aec492061e3a52ca5c0f6057b' }
  1085. if (gameSeed == null || gameSeed == ``) { gameSeed = 'glorious subdued berry' }
  1086.  
  1087.  
  1088. let i_played = 0
  1089. let won = 0
  1090. let loss = 0
  1091. let ATL = 0
  1092. let ATH = 0
  1093. let net = 0
  1094.  
  1095. // let will_it_rip = 100000
  1096.  
  1097. if (debug_verifier) {
  1098. engine.log(`Audit Seed: ${auditSeed}`);
  1099. engine.log(`Game Seed: ${gameSeed}`);
  1100. engine.log(`Client Seed: ${clientSeed}`);
  1101. engine.log();
  1102. engine.log(`Beginning process of emulation rolls`);
  1103. engine.log(`Nonce | Outcomes`);
  1104. }
  1105. let profit = 0
  1106. let gs_num = 0
  1107. let gs_bet = config.sb_base_bet.value
  1108. let gs_balance = 20000 * 100
  1109.  
  1110. for (let i = startNonce; i < endNonce; i++) {
  1111. let result = await gameResult(i) / 100;
  1112.  
  1113. i_played = i
  1114. if (debug_verifier) engine.log(`${i} | ${result} | ${(gs_balance / 100).toFixed(2)} bits`);
  1115. if (result >= game_array[ gs_num ].target) {
  1116. won++
  1117. profit += (game_array[ gs_num ].target - 1) * gs_bet
  1118. gs_balance += (game_array[ gs_num ].target - 1) * gs_bet
  1119. gs_bet = config.sb_base_bet.value
  1120. gs_num++
  1121. } else {
  1122. loss++
  1123. profit -= gs_bet
  1124. gs_balance -= gs_bet
  1125. gs_bet *= config.cb_bets_modes.options.mul.value
  1126.  
  1127. }
  1128. if (gs_num >= game_array.length){
  1129. gs_num = 0
  1130. }
  1131. }
  1132.  
  1133.  
  1134. if (debug_stats) {
  1135. engine.log(`Net Profit: ${(profit / 100).toFixed(2)}`);
  1136. engine.log(`Balance: ${(gs_balance / 100).toFixed(2)}`);
  1137. engine.log(`Games played ${i_played} rolls`);
  1138. engine.log(`wons = ${won}; loss = ${loss};`)
  1139.  
  1140. }
  1141. //if (100000 <= 0) {
  1142.  
  1143. return true
  1144. // } else {
  1145. // return false
  1146. // }
  1147. };
  1148.  
  1149.  
  1150. /**
  1151. * Sandbox Constructor - Orders all targets go online.
  1152. */
  1153. function Sandbox_do_ressurect_disabled_targets() {
  1154. for (let i = 0; i < game_array.length; i++) {
  1155. if (game_array[ i ].enabled == false) {
  1156. game_array[ i ].enabled = true
  1157. engine.log(`${game_array[ i ].target}x ressurected.`)
  1158. }
  1159. }
  1160. Sandbox_do_sort_decremental()
  1161. };
  1162.  
  1163. /**
  1164. * Sandbox Constructor - Sort strategies randomly, works only when RISK_FACTOR set to 0.
  1165. */
  1166. function Sandbox_do_sort_random() {
  1167. game_array.sort(function (a, b) { return 0.5 - Math.random() });
  1168. };
  1169.  
  1170. /**
  1171. * Sandbox Constructor - Sort strategies incremental in amount of target, from low to high, works only when RISK_FACTOR set to 0.
  1172. */
  1173. function Sandbox_do_sort_incremental() {
  1174. game_array.sort(function (a, b) { return a.target - b.target });
  1175. };
  1176.  
  1177. /**
  1178. * Sandbox Constructor - Sort strategies decremental in amount of target, from high to low, works only when RISK_FACTOR set to 0.
  1179. */
  1180. function Sandbox_do_sort_decremental() {
  1181. game_array.sort(function (a, b) { return b.target - a.target });
  1182. };
  1183.  
  1184. /**
  1185. * Sandbox Constructor - Sort strategies decremental by bet size in memory, from high to low, works only when RISK_FACTOR set to 0.
  1186. */
  1187. function Sandbox_do_sort_bet_size_decremental(arr = game_array) {
  1188. arr.sort(function (a, b) { return b.bet - a.bet });
  1189. };
  1190.  
  1191. /**
  1192. * Sandbox Constructor - Erasing list of existing games.
  1193. */
  1194. function Sandbox_delete_strategies(arr = game_array) {
  1195. engine.log(`List of strategies is clear.`)
  1196. arr => { arr = [] }
  1197.  
  1198. };
  1199.  
  1200. /**
  1201. * Sandbox Constructor - Orders strategy go to offline.
  1202. **/
  1203. function Sandbox_kill_strategy(game_type) {
  1204. game_type.enabled = false
  1205. engine.log(`Strategy ${game_type.target} was set to ${game_type.enabled}`)
  1206. };
  1207.  
  1208. Array.prototype.median = function (arr) {
  1209. arr.sort((a, b) => a - b);
  1210. var pivot = Math.floor(arr.length / 2);
  1211. return arr.length % 2 ? arr[ pivot ] : (arr[ pivot - 1 ] + arr[ pivot ]) / 2;
  1212. };
  1213.  
  1214. async function preload_setup_script() {
  1215. if (ex.reset_static_stats_on_launch) engine.resetStatistics()
  1216.  
  1217. setSeed_rules()
  1218.  
  1219. await load_pattern()
  1220. if (ex.calculate_base) {
  1221. await calculate_bankroll()
  1222. }
  1223.  
  1224. //engine.clearLog()
  1225. engine.log('Script.......OK')
  1226. };
  1227.  
  1228. async function gather_information() {
  1229. if (ex.interval_rolls != 0) { await sleep(ex.interval_rolls) }
  1230. if (ex.fast_betting.enabled == true) {
  1231. await fast_betting()
  1232. } else if (ex.fast_betting.enabled == false) {
  1233. await normal_betting()
  1234. }
  1235. };
  1236.  
  1237. async function fastBet() {
  1238. const result = skip_enabled ? skipStep ? await engine.bet(ex.fast_betting.wager, ex.fast_betting.chase) : await engine.bet(ex.fast_betting.wager, ex.fast_betting.chase) : await engine.bet(ex.fast_betting.wager, ex.fast_betting.chase);
  1239. skipStep = !skipStep;
  1240. return result;
  1241. };
  1242.  
  1243. async function analyzeBet() {
  1244. const result = skip_enabled ? skipStep ? await engine.bet(100, 1.01) : await engine.skip() : await engine.bet(100, 1.01);
  1245. skipStep = !skipStep;
  1246.  
  1247. return result;
  1248. };
  1249.  
  1250. /**
  1251. * Updates STW with multipliers
  1252. * @param multiplier Outcome of last game result.
  1253. */
  1254. async function updateStreaks(multiplier) {
  1255. for (let i = 0; i < game_array.length; i++) {
  1256. if (multiplier < game_array[ i ].target) {
  1257. game_array[ i ].LS++
  1258.  
  1259. } else if (multiplier > game_array[ i ].target) {
  1260. game_array[ i ].LS = 0
  1261. game_array[ i ].MISSED++
  1262.  
  1263. } else {
  1264. if (ex.reset_STW_after_game_pass) {
  1265. game_array[ i ].LS = 0 // Reset all while playing
  1266. }
  1267.  
  1268. }
  1269. }
  1270. };
  1271.  
  1272. async function Summary(streak_count) {
  1273. let main_number_who_trigger = 9.44
  1274. let current_streak = streak_count
  1275. let STYLE_PLAY = LONGEST_DIFFCULTY / ex.hard_style.streak_range
  1276. if (last_strategy == main_number_who_trigger && PLAY_HARD != true) {
  1277. if (current_streak >= Math.round(main_number_who_trigger * STYLE_PLAY)) {
  1278. if (PROFIT > 0 && ex.hard_style.enabled == true) {
  1279. hit_hard(true)
  1280. }
  1281. }
  1282. }
  1283. if (ex.hard_style.enabled == true && ex.debug) {
  1284. await notification(`Game ended in amount ${current_streak} of streak, to trigger hard play style ${Math.round(main_number_who_trigger * STYLE_PLAY)} on ${main_number_who_trigger}x strategy`)
  1285. }
  1286. STREAK_ROLL = current_streak
  1287.  
  1288. }
  1289.  
  1290. async function notification_update() {
  1291. if (notification_timeout <= 0) {
  1292. output_message = `No Status`
  1293. notification_timeout = 5
  1294. }
  1295. notification_timeout--
  1296. }
  1297.  
  1298. function notification(message) {
  1299. output_message = message
  1300. engine.log(`${output_message}`)
  1301. }
  1302.  
  1303. function log_busting_to_console() {
  1304. engine.log(`${output_msg}`)
  1305. if (HIT_MIN_PROFIT_TIMES > 1) {
  1306. engine.log(`Script bust ${profit_times}/${HIT_MIN_PROFIT_TIMES} times, Winning ${TOTAL_WINS} times`)
  1307. }
  1308.  
  1309. }
  1310.  
  1311. function hard_style_logging() {
  1312. let output = ``
  1313. if (hard_style_played > 0) {
  1314. output = `, hard style hits was ${hard_style_played} times`
  1315. } else {
  1316. output = ``
  1317. }
  1318. return output
  1319. }
  1320.  
  1321. /**
  1322. * Updates data to values after switching features like hard play.
  1323. */
  1324. function updateData(UPDATED_RISK_FACTOR = RISK_FACTOR_DEFAULT) {
  1325. if (UPDATED_RISK_FACTOR != undefined) {
  1326. for (let i = 0; i < game_array.length; i++) {
  1327. if (game_array[ i ].STW == 0) {
  1328. game_array[ i ].STW = Math.round((game_array[ i ].target * ex.mul_target) * LONGEST_DIFFCULTY / PLAY_IN_RANGE * UPDATED_RISK_FACTOR)
  1329. }
  1330. }
  1331. } else {
  1332. for (let i = 0; i < game_array.length; i++) {
  1333. game_array[ i ].STW = 0
  1334. }
  1335. }
  1336. }
  1337.  
  1338. /**
  1339. * Updates all output logging.
  1340. */
  1341. async function updateLog() {
  1342. let other_output = ``
  1343.  
  1344. await engine.clearLog()
  1345.  
  1346. log_busting_to_console()
  1347.  
  1348. if (ex.luck_usage){ await engine.log(`Luck: ${get_luck()}% | Activation: ${luck_activation}%`); await engine.log(luck_output)}
  1349.  
  1350. await engine.log(`Rolls: ${TOTAL_ROLLS} | Seed: ${nonce}/${change_seed_next} | last run Strategy ${last_strategy}x at streak ${STREAK_ROLL}` + hard_style_logging())
  1351.  
  1352. if (ex.advanced_log) {
  1353. await engine.log(output_message)
  1354. other_output = stats_show() + ` | `
  1355. }
  1356. await engine.log(other_output + `Profit: ${(PROFIT / 100).toFixed(2)} bits`)
  1357.  
  1358. if (ex.advanced_log) { features_logging() }
  1359.  
  1360. if (ex.debug && ex.hard_style.enabled && PLAY_HARD) await engine.log('HARD-PLAY MODE!')
  1361.  
  1362. if (config.sb_simulation_mode.value || config.sb_emulate_rolls.value) {
  1363. await engine.log(`Balance ${Math.round(simulation_balance / 100)} bits`)
  1364. if (simulation_balance <= 0) {
  1365. await engine.log(`Game Over`)
  1366. await engine.stop()
  1367. }
  1368. }
  1369. if (ex.stats_logging.median){
  1370. if(ex.stats_logging.median_history){console.log(`History of latest ${ex.stats_logging.median_cargo} games: ${log_history}`)}
  1371. await engine.log(`Median: ${log_history.median(log_history).toFixed(2)}`)
  1372. if (log_history.length >= ex.stats_logging.median_cargo){log_history = []}
  1373. }
  1374. }
  1375. function console_group(){
  1376. console.clear()
  1377. console.time(`console_logging`) // TIMER
  1378. console.warn(`You using v${ver} of Sandbox Script made by Ruzli#7111, if you have questions or suggestions, write me at ruzli999@gmail.com or if you want say thanks me for sandbox simply tip to Ruzli or donate to my team 1GUU7UZLAWUAA58bx9zuJiTM7eLGUoK6wi`)
  1379. console.group(`Sandbox Script v${ver}`);
  1380. console.groupCollapsed(`Sandbox - Script Launch Configuration`);console_write_create_launch();console.groupEnd();
  1381. console.groupCollapsed(`Sandbox - Available Launch Cases`);console_write_cases();console.groupEnd();
  1382. console.groupCollapsed(`Sandbox - Game Preferences`);console_write_game_preferences();console.groupEnd();
  1383. console.groupCollapsed(`Sandbox - Changelog`);console_write_updates();console.groupEnd()
  1384. console.groupCollapsed(`Sandbox - Documentation`);
  1385. console.groupCollapsed(`Sandbox - GUI [How to/What for]`);list_cases();console.groupEnd()
  1386. console.groupCollapsed(`Sandbox - Code [Tutorials]`);console.log(`All other cases located at https://github.com/ruzli/script_cases`);console.groupEnd()
  1387. console.log(`Will be added soon.`);console.groupEnd()
  1388.  
  1389. if (config.sb_simulation_mode.value || config.sb_emulate_rolls.value) {
  1390. console.log('Running - Simulation');
  1391. console.group('Status');
  1392. console.log(`[S]Balance: ${(simulation_balance / 100).toFixed(2)} bits`);
  1393. } else {
  1394. console.log('Running - Live');
  1395. console.group('Status [Live]');
  1396. console.log(`Balance: ${engine.balance / 100} bits`);
  1397. }
  1398. console.log(`Profit: ${(PROFIT / 100).toFixed(2)} bits`);
  1399. console.groupEnd();
  1400.  
  1401. console.group('Features');
  1402. console.log(`Last run Strategy ${last_strategy}x`);
  1403. console.log(`At streak ${STREAK_ROLL}`);
  1404. console.log(`Median: ${log_history.median(log_history).toFixed(2)}x`);
  1405.  
  1406. console.groupCollapsed(`Rolls: ${TOTAL_ROLLS}`);console.table(rolls_history);console.groupEnd();
  1407. if (game_array.length < 100){
  1408. if (config.sb_test.value){
  1409. console.group(`Strategy: ${game_array.length}`);
  1410. } else {
  1411. console.groupCollapsed(`Strategy: ${game_array.length}`);
  1412. }
  1413. for (let i = 0; i < game_array.length; i++){
  1414. console.group(`Strategy: ${game_array[i].target.toFixed(2)}x - [${game_array[i].enabled}]`);
  1415. console.log(`Base bet: ${Math.round(game_array[i].basebet)} sats`);
  1416. console.log(`Current bet: ${Math.round(game_array[i].bet)} sats`);
  1417. console.log(`Multiplier: ${game_array[i].Settings.bet.multiplier.toFixed(5)}`);
  1418. console.log(`Run times: ${game_array[i].RUNS}`);
  1419. console.log(`Could catch: ${game_array[i].MISSED}`);
  1420. console.log(`Longest streak: ${game_array[i].MAX_STREAK}`);
  1421. console.log(`Profit: ${game_array[i].PROFIT.toFixed(2) / 100} bits`);
  1422. console.log(`Target: ${game_array[i].target.toFixed(2)}x`);
  1423. console.log(`Last streak: ${game_array[i].STREAK_ROLL}`);
  1424. console.log(`Current bet: ${Math.round(game_array[i].bet / 100)} bits`);
  1425. console.groupEnd();
  1426. }
  1427. }
  1428.  
  1429. //console.group(`Strategy: ${game_array}`);console.table();console.groupEnd();
  1430.  
  1431. console.groupEnd();
  1432. console.groupEnd(); console.timeEnd(`console_logging`,)
  1433. };
  1434.  
  1435. function case_type(name, cost = 0, code = ``, type = `Standart`){
  1436. this.name = name,
  1437. this.cost = cost,
  1438. this.code = code,
  1439. this.type = type
  1440. };
  1441.  
  1442. function add_case(name, cost = 0, code = ``, type = `Standart`){
  1443. cases.push(new case_type(name, cost, code, type));
  1444. };
  1445.  
  1446. function list_cases(){
  1447. console.log(`ID|Name|Rec.Balance|Type`)
  1448. for (let i = 0; i < cases.length; i++){
  1449. console.log(`[${i}][${cases[i].name}][${cases[i].cost} bits][${cases[i].type}]`)
  1450. };
  1451. };
  1452.  
  1453. function list_cases_table(){
  1454. console.table(cases);
  1455. };
  1456.  
  1457. function form_cases() {
  1458. add_case("Sandbox Script", 0, "Paste in first text field launch case to load strategy")
  1459. add_case("RND targets/bets", 15000, "After cycle past, their base bet get doubled if did not won, and halved if won, busted target dies, turns and stw also rnd")
  1460. add_case("for 9.44 with 8 max turns and 8 stw and high various Math.pow", 0, "")
  1461. add_case("for 9.44 with 8 max turns and 8 stw", 0, "")
  1462. add_case("Single safe 4.72x play", 15000, "")
  1463. add_case("Many multiplier targets with high multipliers play and risk_multiplier set to 0", 30000, "")
  1464. add_case("Many targets from 5x to 1000x", 20000, "")
  1465. add_case("26.6x playing with chains", 30000, "")
  1466. add_case("Target manipulation: 20x to 5x; 5x to 20x; 100x to 35x", 5000, "")
  1467. };
  1468.  
  1469. function console_write_cases() {
  1470. let output = ``
  1471.  
  1472. output += `To use just write in launch configuration case number strategy you liked with index.`
  1473. list_cases_table()
  1474.  
  1475. };
  1476.  
  1477. function console_write_updates() {
  1478. let output = ``;
  1479.  
  1480. output += `- version 2.0 -\n\n`
  1481. output += `* New logging system.\n`
  1482. output += `* Easy loading and saving system.\n`
  1483. output += `* Prepare for even more easy reading console variables.\n`
  1484. output += `\n - version 2.1 -\n\n`
  1485. output += `* Game preferences also is shown in console group.\n`
  1486. output += `* Added checkbox as last GUI element for save script in text file.\n`
  1487. output += `\n - version 2.11 -\n\n`
  1488. output += `* Added emulated rolls, to run game checkbox GUI.\n`
  1489. output += `\n - version 2.12 -\n\n`
  1490. output += `* Added full logging to each playing strategy in console.\n`
  1491. output += `* Added rolls history available in console.\n`
  1492.  
  1493. console.log(output)
  1494. };
  1495.  
  1496. function console_write_game_preferences() {
  1497. let output = ``;
  1498.  
  1499. output += `calculate_base: ${ex.calculate_base};\n`
  1500. output += `analyze_streaks: ${ex.analyze_streaks};\n`
  1501. output += `debug: ${ex.debug};\n`
  1502. output += `advanced_log: ${ex.advanced_log};\n`
  1503. output += `increasing_bets_at_peak: ${ex.increasing_bets_at_peak};\n`
  1504. output += `reset_all_after_win: ${ex.reset_to_first_on_hit_win};\n`
  1505. output += `increase_STW_by_same_targets: ${ex.increase_STW_by_same_targets};\n`
  1506. output += `disable_target_at_bust: ${ex.disable_target_at_bust};\n`
  1507. output += `reset_STW_after_game_pass: ${ex.reset_STW_after_game_pass};\n`
  1508.  
  1509. console.log(output)
  1510. };
  1511.  
  1512. function get_luck() {
  1513. let luck = calculateLuck(TOTAL_BETS, WINS_OVERALL, game_array[ 0 ].target).toFixed(2)
  1514. return luck
  1515. };
  1516.  
  1517. function calculateLuck(gamesPlayed, gamesWon, target) {
  1518. let luck = (gamesWon / (gamesPlayed * (1 / target) * (1 - 0.01)) - 1) * 100;
  1519. return luck
  1520. };
  1521.  
  1522. async function features_logging() {
  1523. let features_satoshi = ``
  1524. let features_chains = ``
  1525.  
  1526. for (let i = 0; i < game_array.length; i++) {
  1527. if (ex.advanced_log) {
  1528. if (RISK_BASE != 1.0 || RISK_BASE < 1.0) features_satoshi = `Wager: ${game_array[ i ].bet.toFixed(2)} sats. | Max wager: ${(game_array[ i ].Settings.bet.maximal / 100).toFixed()} bits`
  1529. if (game_array[ i ].Settings.modifications.chain_chase.enabled) features_chains = `Chaining: ${game_array[ i ].Settings.modifications.chain_chase.queue}/${game_array[ i ].Settings.modifications.chain_chase.queue_base}`
  1530. output_features = `[${i}] ` + ` ${game_array[ i ].target.toFixed(2)}x, ` + features_chains + ` | ` + features_satoshi
  1531. if (RISK_BASE != 1.0 || game_array[ i ].Settings.modifications.chain_chase.enabled) {
  1532. await engine.log(output_features)
  1533. }
  1534. }
  1535. }
  1536. };
  1537.  
  1538. /**
  1539. * Returns data as string with updated information for each target multiplier, profit, base bet.
  1540. */
  1541. async function stats_show() {
  1542. let limitBroadcast = 50
  1543. let output = ``
  1544. let status = ``
  1545.  
  1546. if (game_array.length < limitBroadcast) {
  1547. for (let i = 0; i < game_array.length; i++) {
  1548. if (game_array[ i ].enabled == true) {
  1549. if (ex.debug) {
  1550. if (ex.winning_frequency) luck_output = `WinRate: ${Math.round(WinRate(WINS_OVERALL, TOTAL_BETS))} WinProb: ${ProbRun(TOTAL_WINS, game_array[ i ].STREAK_ROLL, 1 / game_array[ i ].target)}, Activation ${luck_activation}, Luck: ${calculateLuck(TOTAL_BETS, WINS_OVERALL, game_array[ i ].target).toFixed(2)}%`;
  1551. status = `${game_array[ i ].target.toFixed(2)}x base: ${game_array[ i ].basebet}, multiplier ${game_array[ i ].Settings.bet.multiplier.toFixed(5)}, run ${game_array[ i ].RUNS} times. Could catch: ${game_array[ i ].MISSED}, streaks: last ${game_array[ i ].STREAK_ROLL}, max ${game_array[ i ].MAX_STREAK}, PROFIT: ${game_array[ i ].PROFIT.toFixed(2) / 100}`
  1552. if (game_array[ i ].MAX_BET_TURNS > 0 && !game_array[ i ].Settings.bet.return_at.RETURN_BASE) { status = status + `, cycle ${game_array[ i ].CYCLES_PAST}` }
  1553. }
  1554. if (game_array[ i ].STW != 0) {
  1555. if (ex.advanced_log) {
  1556. output = output + `${game_array[ i ].target.toFixed(2)}x: ${game_array[ i ].LS}/${game_array[ i ].STW} | `
  1557. }
  1558. } else {
  1559. output = output + `${game_array[ i ].target.toFixed(2)}x: next bet ${Math.round(game_array[ i ].bet) / 100} bits | `
  1560. }
  1561.  
  1562. } else {
  1563. status = `Offline. ${game_array[ i ].target.toFixed(2)}x with end bet: ${game_array[ i ].bet / 100} bits`
  1564. }
  1565. await engine.log(status)
  1566. }
  1567. }
  1568. return output
  1569. }
  1570.  
  1571. function max_win_reach() {
  1572. PROFIT = 0
  1573. session_value = 0
  1574. TOTAL_WINS++
  1575. if (HIT_MIN_PROFIT_TIMES == 0 || TOTAL_WINS >= HIT_MAX_PROFIT_TIMES) {
  1576. engine.log(`You reached max profit limit, stopping script`)
  1577. engine.stop()
  1578. }
  1579. }
  1580.  
  1581. /**
  1582. * When condition was met, do update bust counter and stop script if necessery.
  1583. */
  1584. async function condition_to_bust(game_strategy) {
  1585. if (PROFIT > maxProfit) {
  1586. max_win_reach()
  1587. } else {
  1588. profit_times++
  1589. if (profit_times >= HIT_MIN_PROFIT_TIMES) {
  1590. await engine.log(`Script lost ${profit_times} times, so it is stopping`)
  1591. await engine.stop()
  1592. } else {
  1593. output_msg = `Script lost once more and now ${profit_times}/${HIT_MIN_PROFIT_TIMES} before stop`
  1594. PROFIT = 0
  1595. session_value = 0
  1596. //await generateSeed() // Dont change seed at target bust
  1597. if (ex.disable_target_at_bust) Sandbox_kill_strategy(game_strategy)
  1598. }
  1599. }
  1600. }
  1601.  
  1602. function clampTarget(target) {
  1603. let clamp_target
  1604. for (let i = 0; i < game_array.length; i++) {
  1605. if (game_array[ i ].Settings.modifications.median.enabled) {
  1606. clamp_target = Math.max(game_array[ i ].Settings.modifications.median.min_cut, Math.min(game_array[ i ].Settings.modifications.median.max_cut, target));
  1607. }
  1608. }
  1609. return clamp_target
  1610. }
  1611.  
  1612. function betSize(bet) {
  1613. //return Math.round((bet * 100) / 100) * 100
  1614. return Math.max(100, Math.round((bet) / 100) * 100)
  1615. }
  1616.  
  1617. /**
  1618. * Sandbox Constructor - Returns multiplier with calculated RISK_MULTIPLIER.
  1619. * @param {number} target
  1620. */
  1621. function get_formula_multiplier(target) {
  1622. return (1 / (target - 1) + 1) + (RISK_MULTIPLIER * (1 / (target - 1) + 1))
  1623. }
  1624.  
  1625. function get_longest_streak(target) {
  1626. return Math.round(target * LONGEST_DIFFCULTY)
  1627. }
  1628.  
  1629. function get_stw(target) {
  1630. if (RISK_FACTOR == 0) {
  1631. return 0
  1632. } else {
  1633. return Math.round(get_longest_streak(target) / PLAY_IN_RANGE * RISK_FACTOR)
  1634. }
  1635.  
  1636. }
  1637.  
  1638. function get_max_turns(target) { return get_longest_streak(target) - get_stw(target) }
  1639.  
  1640. /**
  1641. * Returns perfect multiplier without additional parameters
  1642. * @param {Odds to calculate} target
  1643. * @param {Round multiplier} toFixed
  1644. */
  1645. function get_multiplier(target, fixit = 7) { return (1 / (target - 1) + 1).toFixed(fixit) }
  1646.  
  1647. function increase_profit(game_strategy) { return betSize(game_strategy.bet) * (game_strategy.target - 1) }
  1648.  
  1649. function decrease_profit(game_strategy) { return betSize(game_strategy.bet) }
  1650.  
  1651. function get_random(power = 1.5) { return power - Math.random() }
  1652.  
  1653. function turn_all_strategies(isOn = true) {
  1654. for (let i = 0; i < game_array.length; i++) {
  1655. game_array[ i ].enabled = isOn
  1656. engine.log(`Strategy ${game_array[ i ].target} was set to ${game_array[ i ].enabled}`)
  1657. }
  1658. }
  1659.  
  1660. /** Not used for now */
  1661. async function session_place() {
  1662. if (ex.session_game.sessionMode && ex.session_game.enabled && session_value > 0) {
  1663. session_value = 0
  1664. if (!simulation) {
  1665. await engine.bet(ex.session_game.sessionBet, ex.session_game.sessionTarget)
  1666. } else {
  1667. if (simulation_MODE == FULL) {
  1668. var { multiplier } = await engine.bet(100, ex.session_game.sessionTarget)
  1669. log_history.push(multiplier)
  1670. rolls_history.push(multiplier)
  1671. } else {
  1672. var { multiplier } = await engine.bet(100, 1.01)
  1673. log_history.push(multiplier)
  1674. rolls_history.push(multiplier)
  1675. }
  1676.  
  1677. if (multiplier < ex.session_game.sessionTarget) {
  1678. simulation_balance -= ex.session_game.sessionBet
  1679.  
  1680. } else {
  1681. simulation_balance += (ex.session_game.sessionBet * ex.session_game.sessionTarget)
  1682. }
  1683. }
  1684.  
  1685. }
  1686. }
  1687.  
  1688. function session_start(game_strategy) {
  1689. let temp = 0
  1690. if (ex.session_game.enabled && game_strategy.target >= ex.session_game.sessionTarget && session_value >= 0) {
  1691. if (session_value <= 0) {
  1692. session_value = 0
  1693. temp = session_value
  1694. } else {
  1695. if (session_value >= ex.session_game.sessionProfit + (ex.session_game.sessionProfit * TOTAL_WINS)) {
  1696. temp = ex.session_game.sessionBet + (ex.session_game.sessionBet * TOTAL_WINS)
  1697. }
  1698. }
  1699. }
  1700. return temp
  1701. }
  1702.  
  1703. /* Attributes - Target */
  1704. async function target_attributes(game_strategy, multiplier) {
  1705. if (game_strategy.Settings.target.multiplier != 1.0) {
  1706. if (game_strategy.target < game_strategy.Settings.target.minimal || game_strategy.target > game_strategy.Settings.target.maximal) {
  1707. // if (game_strategy.Settings.target.return_at.return) {
  1708. game_strategy.target = game_strategy.Settings.target.base
  1709. // } else {
  1710. // game_strategy.target = game_strategy.Settings.target.maximal
  1711. // }
  1712. }
  1713. if (game_strategy.target <= multiplier) { //Win behavior
  1714. if (game_strategy.Settings.target.return_at.on_win) {
  1715. game_strategy.target = game_strategy.Settings.target.base
  1716. } else {
  1717. if (game_strategy.Settings.target.mode == `mul`) {
  1718. game_strategy.target *= game_strategy.Settings.target.multiplier
  1719.  
  1720. }
  1721. if (game_strategy.Settings.target.mode == `add`) {
  1722. game_strategy.target += game_strategy.Settings.target.multiplier
  1723. }
  1724. }
  1725. } else { // Lose behavior
  1726. if (game_strategy.Settings.target.return_at.on_lose) {
  1727. game_strategy.target = game_strategy.Settings.target.base
  1728. } else {
  1729. if (game_strategy.Settings.target.mode == `mul`) {
  1730. game_strategy.target *= game_strategy.Settings.target.multiplier
  1731. }
  1732. if (game_strategy.Settings.target.mode == `add`) {
  1733. game_strategy.target += game_strategy.Settings.target.multiplier
  1734. }
  1735. }
  1736. }
  1737. // DOUBLE CHECK
  1738. if (game_strategy.target < game_strategy.Settings.target.minimal || game_strategy.target > game_strategy.Settings.target.maximal) {
  1739. if (game_strategy.Settings.target.return_at.return) {
  1740. game_strategy.target = game_strategy.Settings.target.base
  1741. } else {
  1742. //game_strategy.target = game_strategy.Settings.target.maximal
  1743. }
  1744. }
  1745. if (game_strategy.target >= 10) {
  1746. //game_strategy.target = game_strategy.target.toFixed(game_strategy.Settings.target.digits_round)
  1747. } else if (game_strategy.target >= 50) {
  1748. //game_strategy.target = game_strategy.target.toFixed(game_strategy.Settings.target.digits_round + 1)
  1749. }
  1750. } else {
  1751. return
  1752. }
  1753. }
  1754.  
  1755. /* Attributes - Betting */
  1756. async function betting_attribute(game_strategy, multiplier) {
  1757. if (game_strategy.bet > game_strategy.Settings.bet.maximal || game_strategy.bet < game_strategy.Settings.bet.minimal) {
  1758. game_strategy.bet = game_strategy.basebet_default
  1759. }
  1760.  
  1761. if (game_strategy.Settings.bet.multiplier != 1.0) {
  1762. if (game_strategy.target <= multiplier) { //Win behavior
  1763. if (game_strategy.Settings.bet.return_at.on_win) {
  1764. game_strategy.bet = game_strategy.basebet_default
  1765. } else {
  1766. if (game_strategy.Settings.bet.mode == `mul`) {
  1767. game_strategy.bet *= game_strategy.Settings.bet.multiplier
  1768. } else if (game_strategy.Settings.bet.mode == `add`) {
  1769. game_strategy.bet += game_strategy.Settings.bet.multiplier
  1770. }
  1771. }
  1772. } else if (multiplier < game_strategy.target) { // Lose behavior
  1773. if (game_strategy.Settings.bet.return_at.on_lose) {
  1774. game_strategy.bet = game_strategy.basebet_default
  1775. } else {
  1776. if (game_strategy.Settings.bet.mode == `mul`) {
  1777. game_strategy.bet *= game_strategy.Settings.bet.multiplier
  1778. } else if (game_strategy.Settings.bet.mode == `add`) {
  1779.  
  1780. game_strategy.bet += game_strategy.Settings.bet.multiplier
  1781. }
  1782. }
  1783. }
  1784. } else {
  1785. game_strategy.bet *= game_strategy.Settings.bet.multiplier
  1786. }
  1787. }
  1788.  
  1789. async function passive_phase() {
  1790. let NOT_TIME = true
  1791. let out_standing = 0
  1792. while (NOT_TIME) {
  1793. engine.clearLog()
  1794. engine.log(`---PASSIVE PERIOD---`)
  1795. engine.log(`${get_luck()}%/${luck_activation}`)
  1796. engine.log(`--------------------`)
  1797. TOTAL_BETS++
  1798. const { multiplier } = await engine.bet(betSize(game_array[ 0 ].basebet), game_array[ 0 ].target + 5)
  1799. log_history.push(multiplier)
  1800. rolls_history.push(multiplier)
  1801. if (multiplier > game_array[ 0 ].target) { //WIN
  1802. WINS_OVERALL++
  1803. } else { //LOSE
  1804. out_standing++
  1805. }
  1806. if (get_luck() > luck_activation || out_standing >= PASSIVE_PERIOD_NOT_LONGER) {
  1807. cool_down = PASSIVE_PERIOD_NOT_LONGER
  1808. NOT_TIME = false
  1809. }
  1810. }
  1811. }
  1812.  
  1813. async function strategy_play(game_strategy) {
  1814. var cycles_activation = 0
  1815. let RETRY = true
  1816.  
  1817. if (game_strategy.LS < game_strategy.STW) return
  1818.  
  1819.  
  1820.  
  1821. game_strategy.LS = 0
  1822. game_strategy.STREAK_ROLL = 0
  1823.  
  1824. game_strategy.RUNS++
  1825. game_strategy.CYCLES_PAST++
  1826.  
  1827. last_strategy = game_strategy.target
  1828. cycles_activation = game_strategy.CYCLES_PAST
  1829. if (ex.stop_on_streak_catch) {
  1830. //gong()
  1831. sound_loop(null,`sc`)
  1832. engine.log(`Stopped due option stop_on_streak_catch = true, catched target ${last_strategy}x.`)
  1833. engine.stop()
  1834. }
  1835.  
  1836. while (RETRY) {
  1837. if (game_strategy.STREAK_ROLL >= game_strategy.MAX_BET_TURNS && game_strategy.MAX_BET_TURNS != 0) {
  1838. if (game_strategy.Settings.bet.return_at.RETURN_BASE) {
  1839. game_strategy.bet = game_strategy.basebet
  1840. }
  1841. RETRY = false
  1842. return
  1843. }
  1844. if (!simulation) {
  1845. if (ex.interval_rolls != 0) { await sleep_decreasing_interval() }
  1846.  
  1847. var { multiplier } = await engine.bet(betSize(game_strategy.bet + session_start(game_strategy)), game_strategy.target)
  1848. log_history.push(multiplier)
  1849. rolls_history.push(multiplier)
  1850.  
  1851. } else {
  1852. if (simulation_MODE == FULL) {
  1853. var { multiplier } = await engine.bet(100, game_strategy.target)
  1854. log_history.push(multiplier)
  1855. rolls_history.push(multiplier)
  1856. } else {
  1857. var { multiplier } = await engine.bet(100, 1.01)
  1858. log_history.push(multiplier)
  1859. rolls_history.push(multiplier)
  1860. }
  1861.  
  1862. if (multiplier < game_strategy.target) {
  1863. simulation_balance -= (game_strategy.bet + session_start(game_strategy))
  1864.  
  1865. } else {
  1866. simulation_balance += ((game_strategy.bet + session_start(game_strategy)) * game_strategy.target)
  1867. }
  1868. }
  1869. //gong()
  1870. await sound_engine(multiplier, false, game_strategy.target)
  1871.  
  1872. TOTAL_BETS++
  1873. TOTAL_ROLLS++
  1874. nonce++
  1875.  
  1876. if (multiplier < game_strategy.target) { // Lose
  1877. game_strategy.STREAK_ROLL++
  1878.  
  1879.  
  1880. PROFIT -= decrease_profit(game_strategy)
  1881. session_value -= decrease_profit(game_strategy)
  1882. game_strategy.PROFIT -= decrease_profit(game_strategy)
  1883.  
  1884.  
  1885. if (PROFIT - game_strategy.bet < ex.hard_style.max_loss && PLAY_HARD ||
  1886. (Math.min(1, (multiplier / game_strategy.target)) >= game_strategy.proximity)) {
  1887. hit_hard(false)
  1888. RETRY = false
  1889. }
  1890.  
  1891. if (game_strategy.CYCLES_PAST >= 2 && ex.increasing_bets_at_peak) {
  1892. if (cycles_activation >= 2) {
  1893. game_strategy.basebet = game_strategy.basebet * ex.increasing_bets_at_peak_value
  1894. game_strategy.bet = game_strategy.basebet
  1895. await updateLog()
  1896. cycles_activation = 0
  1897. }
  1898. }
  1899. if (!game_strategy.Settings.bet.return_at.RETURN_BASE) {
  1900. allow_seed_reset = false // if return base is set to false, then we do not allow change seed until this strategy will end its period
  1901. }
  1902. } else { // Win
  1903. PROFIT += increase_profit(game_strategy)
  1904. session_value += increase_profit(game_strategy)
  1905.  
  1906. if (ex.increase_basebet_on_wins > 0 && ex.increase_basebet_times > 0 && ex.increase_basebet_after_streak <= 0 ){
  1907. game_strategy.basebet = game_strategy.basebet + ex.increase_basebet_on_wins
  1908. game_strategy.basebet_default = game_strategy.basebet
  1909. ex.increase_basebet_times--
  1910. }
  1911.  
  1912.  
  1913. game_strategy.PROFIT += increase_profit(game_strategy)
  1914. if (game_strategy.Settings.modifications.chain_chase.enabled) {
  1915. if (game_strategy.Settings.modifications.chain_chase.queue > 0) {
  1916. game_strategy.Settings.modifications.chain_chase.queue--
  1917. RETRY = true
  1918. } else {
  1919. game_strategy.bet = game_strategy.basebet
  1920. game_strategy.Settings.modifications.chain_chase.queue = game_strategy.Settings.modifications.chain_chase.queue_base
  1921. RETRY = false
  1922. }
  1923. await updateLog()
  1924. gong()
  1925. } else {
  1926. RETRY = false
  1927. if (game_strategy.Settings.bet.multiplier == 1.0) {
  1928. game_strategy.bet = game_strategy.basebet
  1929. }
  1930. }
  1931. if (ex.increasing_bets_at_peak) {
  1932. if (game_strategy.CYCLES_PAST >= 2) {
  1933. game_strategy.basebet = game_strategy.basebet / 2
  1934. game_strategy.bet = game_strategy.basebet
  1935. cycles_activation = 0
  1936. if (game_strategy.basebet < game_strategy.basebet_default) {
  1937. game_strategy.basebet = game_strategy.basebet_default
  1938. game_strategy.bet = game_strategy.basebet
  1939. }
  1940. await updateLog()
  1941. }
  1942. }
  1943. game_strategy.CYCLES_PAST = 0
  1944. WINS_OVERALL++
  1945.  
  1946.  
  1947. if (!game_strategy.Settings.bet.return_at.RETURN_BASE) {
  1948. allow_seed_reset = true // if return base is set to false, then we allow change seed as period is ended
  1949. }
  1950.  
  1951.  
  1952. if (game_array[ 0 ].target == game_array[ game_array.length - 1 ].target && ex.increase_STW_by_same_targets) {
  1953. game_strategy.STW++
  1954. }
  1955.  
  1956. //if (PLAY_HARD == true && game_array[game_array_get_max()].enabled != true || game_array[game_array_get_max()].target == game_array_target_max() && PLAY_HARD == true) {
  1957. if (PLAY_HARD) hit_hard(false)
  1958. if (ex.reset_STW_after_game_pass) await updateStreaks(multiplier)
  1959. reset_to_first_strategy()
  1960. }
  1961.  
  1962.  
  1963. await updateLog()
  1964.  
  1965. // Attribute sectors
  1966. //
  1967.  
  1968. await betting_attribute(game_strategy, multiplier)
  1969. await target_attributes(game_strategy, multiplier)
  1970.  
  1971. /* Attributes - Luck */
  1972. if (ex.winning_frequency) { // Luck Set
  1973. luck_activation = calculateLuck(TOTAL_BETS, WINS_OVERALL, game_strategy.target).toFixed(2)
  1974. game_strategy.base /= 2
  1975. }
  1976. if (get_luck() < luck_activation && cool_down <= 0 && ex.luck_usage) {
  1977. //game_strategy.bet = game_strategy.basebet * RISK_BASE
  1978. game_strategy.Settings.bet.maximal = BET_PERCENT_FROM_BK
  1979. await passive_phase()
  1980. }
  1981. //
  1982. // Features - Probability
  1983. //
  1984. //let chance = ProbRun(rolls, game_strategy.STREAK_ROLL, 1 / game_strategy.target)
  1985. //gen.log(`Probability: ${(chance*100).toFixed(2)}%`)
  1986.  
  1987. // Features - Special
  1988.  
  1989. if (!ex.reset_STW_after_game_pass) await updateStreaks(multiplier)
  1990.  
  1991. Summary(game_strategy.STREAK_ROLL)
  1992. await updateLog()
  1993.  
  1994. // Features - Conditions
  1995.  
  1996. //
  1997. // End Attributes sections
  1998.  
  1999. if (PROFIT > maxProfit + (maxProfit * TOTAL_WINS) || PROFIT - game_strategy.bet < minProfit) {
  2000. RETRY = false
  2001. condition_to_bust(game_strategy)
  2002. }
  2003.  
  2004. if (FORCE_STOP_IF_LOWER != 0 && engine.balance / 100 <= FORCE_STOP_IF_LOWER) engine.stop()
  2005.  
  2006. if (game_strategy.STREAK_ROLL > game_strategy.MAX_STREAK) {
  2007. game_strategy.MAX_STREAK = game_strategy.STREAK_ROLL
  2008. }
  2009. }
  2010. if (game_strategy.STREAK_ROLL >= ex.increase_basebet_after_streak && ex.increase_basebet_times > 0){
  2011. game_strategy.basebet += ex.increase_basebet_on_wins
  2012. game_strategy.basebet_default = game_strategy.basebet
  2013. ex.increase_basebet_times--
  2014. }
  2015. };
  2016.  
  2017. /**
  2018. * Syntax to use new Strategy(TARGET, basebet, max turns, STW, multiplier, return_to_base)
  2019. * @type {number} BaseBet Base bet which from strategy starting to play, amount is set in bits.
  2020. * @type {number} Target Base target which from strategy starting to play.
  2021. * @type {number} MaXBettuns Max bet turns allowed nscript to do.
  2022. * @type {number} StreakToWait Strea k to wwait before strategy will start bet to you.
  2023. * @type {float} Multiplier Multiply bets on amount you specify, if you leave it blank, itw il automatically.
  2024. * @type {boolean} Return_Base Set strategy to reset bet or no, to basebe, if max bet turns was reached.
  2025. */
  2026. function Strategy(target = 2, basebet = 1, max_bet_turns = 0, STW = get_stw(target), multiplier = get_formula_multiplier(target), return_base = false) {
  2027. /* Object Main Properties || target, base bet, bet, max bet turns, stw, multiplier || enabled */
  2028. this.target = target;
  2029. this.basebet = basebet * 100 * RISK_BASE;
  2030. this.basebet_default = basebet * 100 * RISK_BASE;
  2031. this.bet = basebet * 100 * RISK_BASE;
  2032. this.MAX_BET_TURNS = max_bet_turns;
  2033. this.STW = STW;
  2034. this.enabled = true;
  2035. /* Object Triggers || ACTION, PRE_ROLL */
  2036. this.ACTION = async function () { await strategy_play(this) };
  2037. this.PRE_ROLL = async function () {}; // {engine.log(`Luck: ${calculateLuck(this.STREAK_ROLL,this.RUNS,this.target-0.02)}%`);}//{for (let i = 0; i < target; i++){engine.skip()} }; //engine.log(`${probRunMulti(2000, 3, 0.105, 3)}`)
  2038. /* Object Properties - in future loading/save implementation */
  2039. this.CYCLES_PAST = 0;
  2040. this.proximity = 1.0;
  2041. this.LS = 0;
  2042. this.PROFIT = 0;
  2043. this.RUNS = 0;
  2044. this.MISSED = 0;
  2045. this.STREAK_ROLL = 0;
  2046. this.MAX_STREAK = 0;
  2047. this.WINS = 0;
  2048. /* Object Bet Attributes || bet: multiplier, base, mode(mul/add), minimal, maximal, return_at(RETURN_BASE, on_win, on_lose) */
  2049. this.Settings = {
  2050. bet: {
  2051. multiplier: multiplier,
  2052. base: basebet * RISK_BASE,
  2053. mode: `mul`, /* mul - multiply, add - static additional */
  2054. minimal: basebet * RISK_BASE,
  2055. _maximal: engine.balance / 100 * BET_PERCENT_FROM_BK,
  2056. get maximal() { return this._maximal },
  2057. set maximal(val) {
  2058. this._maximal = val * BET_PERCENT_FROM_BK,
  2059. engine.log(`Strategy ${target}x; Maximal bet size is set to ${Math.floor(this._maximal / 100)} bits`)
  2060. },
  2061. return_at: {
  2062. RETURN_BASE: return_base,
  2063. on_win: true,
  2064. on_lose: false,
  2065. },
  2066. },
  2067. /* Object Target Attributes || target: multiplier, base, mode(mul/add), minimal, maximal, return_at(return, on_win, on_lose) */
  2068. target: {
  2069. multiplier: 1.0,
  2070. base: target,
  2071. mode: `mul`, /* mul - multiply, add - static additional */
  2072. minimal: target,
  2073. maximal: 10000,
  2074. digits_round: 2,
  2075. return_at: {
  2076. return: true,
  2077. on_win: true,
  2078. on_lose: false,
  2079. },
  2080. },
  2081. /* Object Modifications || modifications: chain_chase[enabled/queue], median[enabled, bet_balance, skips, min, max cut], pullee[enabled, power] */
  2082. modifications: {
  2083. chain_chase: {
  2084. enabled: false,
  2085. _queue_base: 3,
  2086. queue: 3,
  2087. get queue_base() { return this._queue_base },
  2088. set queue_base(val) { this._queue_base = this.queue = val },
  2089. },
  2090. median: {
  2091. enabled: false,
  2092. bet_balance: 0.1,
  2093. skips_used_by_median: 10,
  2094. min_cut: 1.5,
  2095. max_cut: 2,
  2096. },
  2097. pullee: {
  2098. enabled: false,
  2099. power: 0.5,
  2100. }
  2101. },
  2102. }
  2103. };
  2104.  
  2105. /* Starting strategy run, should be used only when there is gurantee will be high multipliers.
  2106. *
  2107. */
  2108. function hit_hard(isEnabled) {
  2109. if (ex.hard_style.enabled == false) {
  2110. return
  2111. }
  2112. for (let i = 0; i < game_array.length; i++) {
  2113. bet_levels_hard_hit_mod[ i ].prev = Math.round(game_array[ i ].basebet)
  2114. }
  2115. if (isEnabled == true) {
  2116. PLAY_HARD = true
  2117. hard_style_played++
  2118. RISK_FACTOR = 0.0
  2119. RISK_MULTIPLIER = ex.hard_style.multiplier
  2120. updateData(RISK_FACTOR)
  2121. for (let i = 0; i < game_array.length; i++) {
  2122. game_array[ i ].Settings.bet.multiplier = (1 / ((game_array[ i ].target) - 1) + 1) + (ex.hard_style.multiplier * (1 / ((game_array[ i ].target) - 1) + 1))
  2123.  
  2124. }
  2125. for (let i = 0; i < game_array.length; i++) {
  2126. game_array[ i ].basebet = Math.round(bet_levels_hard_hit_mod[ i ].base * RISK_BASE)
  2127. game_array[ i ].bet = Math.round(bet_levels_hard_hit_mod[ i ].base * RISK_BASE)
  2128. }
  2129.  
  2130. } else {
  2131. PLAY_HARD = false
  2132.  
  2133. RISK_FACTOR = RISK_FACTOR_DEFAULT
  2134. RISK_MULTIPLIER = RISK_MULTIPLIER_DEFAULT
  2135.  
  2136. for (let i = 0; i < game_array.length; i++) {
  2137. game_array[ i ].basebet = Math.round(bet_levels_hard_hit_mod[ i ].prev * RISK_BASE)
  2138. game_array[ i ].bet = Math.round(bet_levels_hard_hit_mod[ i ].prev * RISK_BASE)
  2139. }
  2140. for (let i = 0; i < game_array.length; i++) {
  2141. game_array[i].Settings.bet.multiplier = (1 / ((game_array[ i ].target * ex.mul_target) - 1) + 1) + (RISK_MULTIPLIER_DEFAULT * (1 / ((game_array[ i ].target * ex.mul_target) - 1) + 1))
  2142.  
  2143. }
  2144. updateData()
  2145. }
  2146. };
  2147.  
  2148. /* Words for setting seed. Not used anymore. */
  2149. function randomSeed() {
  2150. const words = [ 'aAld35gheidfra ', 'aBragvif3hfd5n ', 'aCh5a6idr3rfdlik ', 'aDelf56fhriadgo ', 'aZ6erfchfi5hso ', 'a6Fgdfeihxft5romb ', 'agHogti56felshsa ', 'aGndhgi6mg636fu5s ', 'aAdddg5ihgc336ted ', 'aAu5d5gh6frelia ', 'aZifg2556dgalo ', 'aWive65gm66fdda ',
  2151. 'aMarid5d6fniger ', 'aOctober3idd5gffhfest ', 'aNd5radfi6shcar ', 'aPdd5aiff3ghpaja ', 'aAlbfe6hgf5idds ', 'aGfgohi6fdm5us ', 'aFigih6fgrra ', 'aGT5gg66d6i6ffdO ', 'aUn5dgh6i6ciog6frn ', 'agVicdnfg6h6t5uis ', 'aShig55diski ', 'aXda6v6gf25ier ', 'aPoigd666upfldd5et ', 'aAdntu66tdgssfulika2 ' ]
  2152.  
  2153. return words[ Math.floor(words.length * Math.random()) ] + words[ Math.floor(words.length * Math.random()) ] + words[ Math.floor(words.length * Math.random()) ]
  2154. };
  2155.  
  2156. function setSeed_rules() {
  2157. if (RISK_FACTOR == 0) {
  2158. change_seed_next = change_seed
  2159. } else {
  2160. change_seed_next = change_seed_next_STW
  2161. }
  2162. };
  2163.  
  2164. async function generateSeed() {
  2165. if (ex.luck_usage) {
  2166. luck_activation = get_luck()
  2167. }
  2168.  
  2169. try {
  2170. const { server_seed_hash } = await engine.newSeedPair()
  2171. if (ex.debug) {
  2172. engine.log(`Server hash: ${server_seed_hash}`)
  2173. }
  2174. }
  2175. catch (e) {
  2176. engine.log(`Seed is already was reset`)
  2177. }
  2178. try {
  2179. const clientSeed = await createSeed()
  2180. await engine.setClientSeed(clientSeed)
  2181. nonce = 0
  2182. if (ex.debug) {
  2183. engine.log(`Seed was set to: ${clientSeed}`)
  2184. }
  2185. }
  2186. catch (e) {
  2187. if (ex.debug) {
  2188. engine.log(`Client seed already is used`)
  2189. }
  2190. }
  2191. };
  2192.  
  2193. async function createSeed() {
  2194. const s = new TextEncoder('utf-8').encode(Date.now());
  2195. const h = await crypto.subtle.digest('SHA-256', s);
  2196. const a = Array.from(new Uint8Array(h));
  2197. const r = a.map(b => ('00' + b.toString(16)).slice(-2)).join('');
  2198. return r;
  2199. };
  2200.  
  2201. /* Sleep with changing interval overtime */
  2202. async function sleep_decreasing_interval() {
  2203. if (diffculty_sleep != 0) {
  2204. diffculty_sleep -= 1
  2205. } else {
  2206. diffculty_sleep = ex.interval_rolls
  2207. }
  2208. await sleep(diffculty_sleep)
  2209. }
  2210. /* Sleep with set static interval of milliseconds */
  2211. async function sleep(ms = ex.interval_rolls) {
  2212. if (ms != 0) return new Promise(resolve => setTimeout(resolve, ms))
  2213. };
  2214.  
  2215. /* Strategy playing of pullee */
  2216. async function strategy_pullee(bet_pull, target_pull) {
  2217. //let target = target_pull
  2218. //let bet = bet_pull
  2219. let rolls = 0
  2220. while (true) {
  2221. if (rolls >= change_seed && change_seed != 0) {
  2222. await generateSeed()
  2223. rolls = 0
  2224. } else { rolls++ }
  2225.  
  2226. engine.clearLog()
  2227. engine.log(`Roll: ${rolls}`)
  2228. engine.log(`Bet: ${Math.round(bet.pull())}`)
  2229. engine.log(`Target: ${target.pull().toFixed(2)}`)
  2230. engine.log(`Profit `)
  2231.  
  2232. const { multiplier } = await this.bet(betSize(bet_pull.current), target_pull.current.toFixed(2) + 1)
  2233.  
  2234. if (multiplier >= target.current.toFixed(2) + 1) {
  2235. sound_loop(5)
  2236. target.pull("min")
  2237. bet.pull("min")
  2238. }
  2239. }
  2240. };
  2241.  
  2242. /* Power functions modification - Can create using a single number as an argument, and modify later if needed */
  2243. function CreatePullee(initial, min = undefined, max = undefined, power = 0) {
  2244. min === undefined ? min = initial : null;
  2245. max === undefined ? max = initial : null;
  2246. var pullee = {
  2247. min: min,
  2248. max: max,
  2249. current: initial,
  2250. puller: "max",
  2251. reversed: false,
  2252. initial: initial,
  2253. power: power
  2254. }
  2255. return function () {
  2256. // yank() will instantly pull the number to the puller (essentially a 100% power pull)
  2257. pullee.yank = function (puller = pullee.puller) { pullee.current = pullee[ puller ]; return pullee.current; };
  2258. // attach the pull function so it can be called as a method
  2259. pullee.pull = function (puller = undefined) { pullee.current = pull(pullee, puller); return pullee.current; };
  2260. // attach a function to reverse the polarity, reversed will become true if false, and false if true
  2261. pullee.reverse = function () { pullee.reversed = !pullee.reversed; }
  2262. return pullee;
  2263. };
  2264. };
  2265.  
  2266. function pull(num = undefined, to_num = undefined, percent = undefined) {
  2267. var pullee;
  2268. if (typeof num === "object") {
  2269. pullee = {};
  2270. pullee = Object.create(num);
  2271. num = pullee.current;
  2272. if (to_num !== undefined) {
  2273. if ((typeof to_num === "string") && (to_num === "max" || to_num === "min" || to_num === "reverse")) {
  2274. if (to_num === "reverse") {
  2275. let reversable = false;
  2276. pullee.puller === "max" ? reversable = "min" : null;
  2277. pullee.puller === "min" ? reversable = "max" : null;
  2278. if (reversable !== false) {
  2279. pullee.puller = reversable;
  2280. }
  2281. } else {
  2282. pullee.puller = to_num;
  2283. }
  2284. to_num = pullee[ pullee.puller ];
  2285. } else if (typeof to_num === "number") {
  2286. } else if (typeof to_num === "string") {
  2287. if (pullee[ to_num ] !== undefined) {
  2288. pullee.puller = to_num;
  2289. to_num = pullee[ pullee.puller ];
  2290. } else {
  2291. to_num = pullee[ pullee.puller ];
  2292. }
  2293. } else {
  2294. to_num = pullee[ pullee.puller ];
  2295. }
  2296. } else {
  2297. if (pullee.reversed === true && (pullee.puller === "max" || pullee.puller === "min")) {
  2298. let reversable = false;
  2299. pullee.puller === "max" ? reversable = "min" : null;
  2300. pullee.puller === "min" ? reversable = "max" : null;
  2301. if (reversable !== false) {
  2302. pullee.puller = reversable;
  2303. }
  2304. }
  2305. to_num = pullee[ pullee.puller ];
  2306. }
  2307. if (percent !== undefined) {
  2308. pullee.power = percent;
  2309. } else {
  2310. percent = pullee.power;
  2311. }
  2312. } else {
  2313. }
  2314. let pull_strength;
  2315. if (num === undefined || to_num === undefined || percent === undefined) {
  2316. console.log('PULL() Error, an argument was missing.');
  2317. pull_strength = 0;
  2318. } else if (typeof num !== "number" || typeof to_num !== "number" || typeof percent !== "number") {
  2319. console.log('PULL() Error, all arguments must be numbers');
  2320. pull_strength = 0;
  2321. } else {
  2322. percent > 1 ? percent = 1 : null;
  2323. pull_strength = ((to_num - num) * percent);
  2324. }
  2325. return (num + pull_strength);
  2326. };
  2327.  
  2328. async function gong() {
  2329. const audio = new Audio("https://bustadice.com/5bb187b7ef764e76fb519939f77288c1.mp3")
  2330. if (ex.game_sounds) await audio.play()
  2331. return new Promise(resolve => audio.onended = resolve)
  2332. };
  2333.  
  2334. /* Playing sound loop by number or by name from sound track listed below. */
  2335. async function sound_loop(sound_number, name) {
  2336. let sound_track = [ `cl_hihat`, `claves`, `conga1`, `cowbell`, `hi_conga`, `hightom`, `rimshot`, `snare`, `tom1`, `sc` ] // Sounds are hosted on gist users content repository
  2337. let url = `https://raw.githubusercontent.com/ruzli/misc/master/`
  2338. let format = `.wav`
  2339. let full_string = url + name + format
  2340.  
  2341. if (name != undefined) {
  2342. full_string = url + name + format
  2343. } else if (sound_number != undefined) {
  2344. full_string = url + sound_track[ sound_number ] + format
  2345. } else {
  2346. engine.log(`Sound url not found.`)
  2347. }
  2348. const audio = new Audio(full_string)
  2349.  
  2350. if (ex.game_sounds) await audio.play()
  2351. return new Promise(resolve => audio.onended = resolve)
  2352. };
  2353.  
  2354. async function sound_engine(multiplier, beat_mode = false, beat_target = undefined) {
  2355. if (multiplier == undefined) {
  2356. engine.log(`Something is wrong with sound engine.`)
  2357. await sleep(3000)
  2358. return
  2359. }
  2360. if (beat_mode) {
  2361. if (multiplier < 5) {
  2362. sound_loop(8)
  2363. } else if (multiplier < 10) {
  2364. sound_loop(1)
  2365. } else if (multiplier < 15) {
  2366. sound_loop(2)
  2367. } else if (multiplier < 20) {
  2368. sound_loop(5)
  2369. } else if (multiplier < 25) {
  2370. sound_loop(4)
  2371. } else if (multiplier < 30) {
  2372. sound_loop(6)
  2373. } else if (multiplier < 35) {
  2374. sound_loop(7)
  2375. } else if (multiplier < 40) {
  2376. sound_loop(0)
  2377. } else {
  2378. sound_loop(3)
  2379. }
  2380. } else {
  2381. if (multiplier >= beat_target || beat_target != undefined) {
  2382. sound_loop(8)
  2383. } else {
  2384. sound_loop(3)
  2385. }
  2386. }
  2387. };
  2388.  
  2389. async function normal_betting() {
  2390. const { multiplier } = await analyzeBet()
  2391. log_history.push(multiplier)
  2392. rolls_history.push(multiplier)
  2393. TOTAL_ROLLS++
  2394. nonce++
  2395.  
  2396. history.unshift(multiplier);
  2397. // save the result and update the patterns
  2398. for (let i = 0; i < patterns.length; i++) {
  2399. await patterns[ i ].update(history);
  2400. }
  2401.  
  2402. if (skipStep == 0) {
  2403. if (multiplier > 1.00) {
  2404. if (simulation) simulation_balance += 0.01
  2405. PROFIT += 0.01
  2406. } else {
  2407. if (simulation) simulation_balance -= 1
  2408. PROFIT -= 1
  2409. }
  2410. }
  2411. await updateStreaks(multiplier);
  2412. await updateLog();
  2413. return
  2414. };
  2415.  
  2416. async function fast_betting() {
  2417. if (queue.length < queueSize) {
  2418. for (let i = 0, m = queueSize - queue.length; i < m; i++) {
  2419. queue.push(fastBet());
  2420. }
  2421. }
  2422. let results = [];
  2423. await Promise.all(queue.map(p => p.catch(e => e))).then(result => result.forEach(r => results.unshift(r))).catch(e => engine.log(e));
  2424. results.forEach(async (result) => {
  2425. TOTAL_ROLLS++
  2426. if (result.value) {
  2427. if (result.multiplier > 1.00) {
  2428. if (simulation) simulation_balance += 0.01
  2429. PROFIT += 0.01
  2430.  
  2431. } else {
  2432. if (simulation) simulation_balance -= 1
  2433. PROFIT -= 1
  2434. }
  2435. }
  2436. nonce++
  2437. log_history.push(result.multiplier)
  2438. rolls_history.push(result.multiplier)
  2439. await updateStreaks(result.multiplier);
  2440. await updateLog();
  2441. });
  2442. queue = [];
  2443. };
  2444.  
  2445. /**
  2446. * That one calculates the chance of hitting win of r length in n rolls with a % roll success probability of p
  2447. * @param {number} numbers
  2448. * @param {number} rolls
  2449. * @param {number} probability
  2450. * @param {number} streaks
  2451. */
  2452. function ProbRunMulti(numbers, rolls, probability, streaks) {
  2453. let out = [ streaks ]
  2454. let prob = [ numbers ]
  2455. for (let i = 0; i < numbers; i++) {
  2456. prob[ i ] = [ rolls ];
  2457. };
  2458. let c = Math.pow((1 - probability) * probability, rolls);
  2459. let curr, prev, first, i, j;
  2460. if (rolls <= numbers) prob[ 1, rolls ] = Math.pow(probability, rolls);
  2461. for (i = (rolls + 1); i <= numbers; i++) {
  2462. prob[ 1, i ] = prob[ 1, i - 1 ] + (1 - prob[ 1, i - rolls - 1 ]) * c;
  2463. };
  2464. out[ 0 ] = prob[ 1, numbers ];
  2465.  
  2466. for (j = 1; j < streaks; j++) {
  2467. curr = j % 2
  2468. prev = (j + 1) % 2
  2469. first = j * (rolls + 1) - 1;
  2470. if (first <= numbers) prob[ curr, first ] = Math.pow(probability, (j * rolls)) * Math.pow((1 - probability), (j - 1));
  2471.  
  2472. for (i = (first + 1); i <= numbers; i++) {
  2473. prob[ curr, i ] = prob[ j, i - 1 ] + (prob[ prev, (i - rolls - 1) ] - prob[ curr, (i - rolls - 1) ]) * c;
  2474. };
  2475. out[ j ] = prob[ curr, numbers ];
  2476.  
  2477. };
  2478. return Math.round(out).toFixed(7);
  2479. };
  2480.  
  2481. function WinRate(wins, games) {
  2482. return Math.round((wins / games) * 100).toFixed(2)
  2483. };
  2484.  
  2485. /**
  2486. * That one calculates the chance of hitting win of r length in n rolls with a % roll success probability of p
  2487. * @param {number of rolls} n
  2488. * @param {length of concurrent rolls} r
  2489. * @param {probability of rolls} p
  2490. */
  2491. function ProbRun(rolls, lossCount, probability) {
  2492. let prob = [ lossCount ],
  2493. c, iter, last, i, j;
  2494. iter = rolls / (lossCount + 1)
  2495. last = Math.round(rolls - iter * (lossCount + 1));
  2496. c = (1 - probability) * Math.pow(probability, lossCount);
  2497. prob[ lossCount ] = Math.pow(probability, lossCount);
  2498. for (j = 1; j < iter; j++) {
  2499. prob[ 0 ] = prob[ lossCount ] + (1 - prob[ 0 ]) * c;
  2500. for (i = 1; i < lossCount; i++) {
  2501. prob[ i ] = prob[ i - 1 ] + (1 - prob[ i ]) * c
  2502. }
  2503. }
  2504. return Math.round(prob[ last ]).toFixed(2);
  2505. };
  2506.  
  2507. function calcTarget(skips_used_by_median, results) {
  2508. let pLen = results.length
  2509. if (pLen < skips_used_by_median) {
  2510. if (DEBUG) { engine.log("[DEBUG] Not enough input to slice. Returning.. ") }
  2511. //return
  2512. }
  2513. let r = results.slice(pLen - (skips_used_by_median), pLen).sort((a, b) => a - b),
  2514. len = r.length,
  2515. mid = Math.floor(len / 2)
  2516. if (DEBUG) { engine.log(`Target is ${clampTarget((len % 2 ? r[ mid ] : ((r[ mid - 1 ] + r[ mid ]) / 2)))}`) }
  2517. return clampTarget((len % 2 ? r[ mid ] : ((r[ mid - 1 ] + r[ mid ]) / 2))) / 100
  2518. };
  2519.  
  2520. function calcBet() {
  2521. engine.log(`Starting calculate median bet size`)
  2522. let lossCount = loses.length || 0
  2523. let baseBet = betSize(engine.balance * (BET_BALANCE / (200 - lossCount)));
  2524. engine.log(`base Bet is ${baseBet / 100}`)
  2525. let vectorApex = calcTarget(skips_used_by_median, results);
  2526. if (!lossCount) {
  2527. if (DEBUG) { engine.log(`[DEBUG] Base bet ${baseBet / 100}, no losses.`); }
  2528. return baseBet;
  2529. }
  2530. let losses = (loses.reduce((a, b) => a + b) * 100);
  2531. let nextBet = betSize((baseBet + (losses / ((vectorApex * 100) - 1))));
  2532. if (DEBUG) engine.log(`[DEBUG] Next ${betSize(nextBet)}, (base ${betSize(baseBet)}+(${losses / 100}/${vectorApex} losses)`);
  2533. return nextBet;
  2534. };
  2535.  
  2536. /* Strategy playing of median */
  2537. async function median_loop(game_strategy) {
  2538. while (true) {
  2539. await sleep_decreasing_interval()
  2540. //if (results.length < hmrsv) return;
  2541. nextBet = calcBet(), vectorApex = calcTarget(game_strategy.Settings.modifications.median.skips_used_by_median, results)
  2542.  
  2543.  
  2544. if (results.length < game_strategy.Settings.modifications.median.skips_used_by_median) {
  2545. if (DEBUG) engine.log(`[DEBUG] gathered initial data (${results.length}/${game_strategy.Settings.modifications.median.skips_used_by_median} results)`);
  2546. var { multiplier } = await engine.skip();
  2547.  
  2548. } else {
  2549. engine.log(`[INFO] Balance: ${engine.balance / 100} bits. Betting ${nextBet / 100} bits @ ${vectorApex * 100}x next.`)
  2550. var { multiplier } = await engine.bet(betSize(nextBet), vectorApex * 100);
  2551. log_history.push(multiplier)
  2552. rolls_history.push(multiplier)
  2553. sound_engine(multiplier)
  2554. }
  2555. results.push(multiplier);
  2556.  
  2557. if (multiplier >= vectorApex * 100) {
  2558. loses = []
  2559. let profit = nextBet * vectorApex - nextBet;
  2560. engine.log(`[WIN] Won at ${multiplier}x, Cashed at ${vectorApex * 100}x for ${profit / 100} bits profit.`);
  2561. } else {
  2562. loses.push(nextBet / 100)
  2563. let loss = loses.reduce((a, b) => a + b);
  2564. engine.log(`[LOSS] Bust at ${multiplier}x, Current losses at ${loss} bits`);
  2565. }
  2566. engine.log(`Loses: ${loses.length}`)
  2567. }
  2568. };
  2569.  
  2570. /* Huge Addon which gives alot of advantages in rolls manipulation */
  2571. class Pattern {
  2572. /**
  2573. * constructor - Description
  2574. *
  2575. * @param {array} sequence Defines the pattern sequence as 0 for <1.98x and 1 for >1.98x (or equal to 1.98x)
  2576. * @param {number} [cooldown=0] Time required before pattern can be triggered again.
  2577. * @param {type} action Function which is called when pattern is found.
  2578. * @param {array} actionData Additional parameters passed in action calls.
  2579. */
  2580. constructor (sequence, cooldown = 0, action, ...actionData) {
  2581. this.enabled = true;
  2582. this.active = true;
  2583. this.lastSeen = Date.now();
  2584. this.sequence = sequence.reverse();
  2585. this.length = sequence.length;
  2586. this.elapsed = 0;
  2587. this.cooldown = cooldown;
  2588. this.action = action;
  2589. this.actionData = actionData;
  2590. }
  2591. /**
  2592. * update - Description
  2593. *
  2594. * @param {Array} results Array of game results
  2595. */
  2596. async update(results) {
  2597. if (!this.enabled) {
  2598. return;
  2599. } else if (!this.active) {
  2600. if (this.cooldown) {
  2601. if (typeof this.cooldown === "number" && this.elapsed > this.cooldown) {
  2602. // cooldown is over, pattern enabled.
  2603. console.log(`Cooldown is up for ${this.sequence}`);
  2604. this.active = true;
  2605. } else {
  2606. console.log(`Still on cooldown for ${this.sequence}`);
  2607. }
  2608. }
  2609. } else {
  2610. let segment = results.slice(0, this.length);
  2611. console.log(segment);
  2612. let progress = 0;
  2613. for (let i = 0; i < this.length; i++) {
  2614. if ((this.sequence[ i ] < 0 && segment[ i ] <= Math.abs(this.sequence[ i ])) ||
  2615. (this.sequence[ i ] > 0 && segment[ i ] >= this.sequence[ i ]) || this.sequence[ i ] === 0) {
  2616. // check if game result matches sequence
  2617. progress++;
  2618. } else { return; }
  2619. }
  2620. // found entire sequence
  2621. if (progress >= this.length) {
  2622. if (this.cooldown > 0) { this.active = false; }
  2623. // update counters
  2624. this.lastSeen = Date.now();
  2625. this.elapsed = 0;
  2626. console.log(`Found pattern ${this.sequence}!`);
  2627. if (this.action && typeof this.action == "function") {
  2628. // call action func
  2629. await this.action.apply(this, this.actionData);
  2630. }
  2631. }
  2632. }
  2633. this.elapsed++;
  2634. }
  2635. };
  2636.  
  2637. function reset_to_first_strategy() {
  2638. if (ex.reset_to_first_on_hit_win) {
  2639. RUNNING = true
  2640. }
  2641. return RUNNING
  2642. };
  2643. var RUNNING = false;
  2644.  
  2645. /* Main loop is starting from here */
  2646. const main = async () => {
  2647. await preload_setup_script();
  2648.  
  2649. while (true) {
  2650.  
  2651. if (ex.analyze_streaks) {
  2652. await gather_information();
  2653. };
  2654. for (let igo = 0; igo < game_array.length; igo++) {
  2655. if (ex.reset_to_first_on_hit_win && RUNNING == true) {
  2656. igo = 0
  2657. RUNNING = false
  2658. };
  2659. if (game_array[ igo ].enabled) {
  2660. await game_array[ igo ].ACTION();
  2661. await game_array[ igo ].PRE_ROLL();
  2662.  
  2663. if (nonce >= change_seed_next && allow_seed_reset) {
  2664. await generateSeed();
  2665. };
  2666. };
  2667. };
  2668. };
  2669. };
  2670.  
  2671. async function credits() {
  2672. engine.log(`Sandbox Script made by by Ruzli. v${ver}.`)
  2673. await sleep(500)
  2674. };
  2675.  
  2676. await credits()
  2677. /* Prevent script from lost connection to server */
  2678. while (true) {
  2679. try {
  2680. await main();
  2681. } catch (error) {
  2682. if (error.message === "connection closed") {
  2683. await this.log("Connection closed. Restarting script");
  2684. continue;
  2685. } else if (error.message === "insufficient balance") {
  2686. await this.log("Not enough balance to bet");
  2687. //downloadRolls()
  2688. await this.stop();
  2689. } else {
  2690. throw error;
  2691. }
  2692. };
  2693. };
Add Comment
Please, Sign In to add comment