"""Crash/Limbo: reach probabilities and auto-cashout outcomes, using the published 1%-edge formula.""" import numpy as np from common import save SEED = 20261004 EDGE = 0.01 rng = np.random.default_rng(SEED) N = 10_000_000 # crashpoint = max(1, (2^32 / (int + 1)) * (1 - edge)), int uniform in [0, 2^32) ints = rng.integers(0, 2 ** 32, N, dtype=np.uint64).astype(np.float64) cp = np.maximum(1.0, np.floor((2 ** 32 / (ints + 1)) * (1 - EDGE) * 100) / 100) targets = [1.01, 1.1, 1.25, 1.5, 2, 3, 5, 10, 20, 50, 100, 1000] reach = [] for t in targets: reach.append({"target": t, "theoretical_pct": round((1 - EDGE) / t * 100, 4), "simulated_pct": round((cp >= t).mean() * 100, 4)}) instant = round((cp == 1.0).mean() * 100, 3) # 100 bets of 1 USDT at fixed auto-cashout, 50,000 sessions SESS = 50_000 auto = [] for t in (1.1, 1.5, 2, 3, 10, 100): p = (1 - EDGE) / t wins = rng.binomial(100, p, SESS) net = wins * (t - 1) - (100 - wins) auto.append({"cashout": t, "win_chance_pct": round(p * 100, 3), "expected_net_usdt": round(100 * (p * t - 1), 2), "median_net_usdt": round(float(np.median(net)), 2), "chance_up_after_100_pct": round((net > 0).mean() * 100, 2), "worst_5pct_usdt": round(float(np.percentile(net, 5)), 2), "best_5pct_usdt": round(float(np.percentile(net, 95)), 2)}) save("crash", {"game": "Crash / Limbo", "house_edge": EDGE, "rounds": N, "sessions": SESS, "seed": SEED, "formula": "crash point = max(1, 2^32/(int+1) x 0.99), truncated to 2 decimals", "script": "crash_sim.py"}, {"reach": reach, "instant_bust_pct": instant, "auto_cashout": auto}, [[r["target"], r["theoretical_pct"], r["simulated_pct"]] for r in reach], ["target_multiplier", "theoretical_reach_pct", "simulated_reach_pct"])