"""Economy pacing sim: a team pops, buys the cheapest thing (sectors favoured), plays in its best hall. Prints when milestones are hit for 1, 2 and 4 players with the current prices. Rates are rough guesses; orders, recycling and trucks are left out, so real play runs a bit faster.""" import os, re, math ROOT = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) gd = open(os.path.join(ROOT, 'Assets', 'Scripts', 'Gameplay', 'GameDefs.cs'), encoding='utf-8').read() def perks_from(src, price_scale=None): out = [] for m in re.finditer(r'new PerkDef \{([^}]*)', src): b = m.group(1) pid = re.search(r'id = PerkId\.(\w+)', b).group(1) ml = int((re.search(r'maxLevel = (\d+)', b) or [0, 1])[1]) bp = int(re.search(r'basePrice = (\d+)', b).group(1)) g = float((re.search(r'growth = ([\d.]+)f', b) or [0, '1'])[1]) row = int(re.search(r'row = (\d+)', b).group(1)) out.append(dict(id=pid, max=ml, base=bp, growth=g, row=row)) return out SECTORS = [ # hall, price (0, 0), (0, 1500), (0, 6000), (0, 18000), (0, 50000), (0, 140000), (1, 300000), (1, 420000), (1, 600000), (1, 850000), (1, 520000), (1, 700000), (1, 950000), (1, 1300000), (2, 2500000), (2, 3200000), (2, 3600000), (2, 4500000), (2, 5200000), (2, 6000000), (2, 7000000), (2, 8500000), (2, 10000000), (2, 12000000), (2, 15000000), (2, 20000000)] SECTOR_WEIGHT = 0.35 TOOL_RATE = [ # (perk that unlocks it, raw bubbles/s for a team of two, share of pops that are carpet bubbles) (None, 9, 0.35), ('Mallet', 22, 0.4), ('Boots', 28, 0.45), ('SpikeRoller', 45, 0.5), ('RoadRoller', 120, 0.75)] def run(rules, perks, sectors, hallmul, label, horizon_h=12): lv = {p['id']: 0 for p in perks} owned = 1 money, t, dt = 0.0, 0.0, 10.0 marks = {} while t < horizon_h * 3600: hall = sectors[owned - 1][0] raw, carpet = 9, 0.35 for perk, r, c in TOOL_RATE: if perk is None or lv.get(perk, 0) > 0: raw, carpet = r, c raw *= 1 + 0.08 * lv['Sneakers'] + (0.25 if lv['DoubleTap'] else 0) + 0.06 * lv['ChainPop'] + 0.1 * lv['HeavyMallet'] + 0.1 * lv['TurboRoller'] money += dt * rules['income'](raw, carpet, lv, hallmul[hall]) t += dt # buy: the next sector if affordable, otherwise the cheapest perk level while True: opts = [] if owned < len(sectors): opts.append((sectors[owned][1], 'sector', None)) for p in perks: if lv[p['id']] < p['max']: opts.append((p['base'] * p['growth'] ** lv[p['id']], 'perk', p)) if not opts: break price, kind, p = min(opts, key=lambda o: o[0] * (SECTOR_WEIGHT if o[1] == 'sector' else 1)) if price > money: break money -= price if kind == 'sector': owned += 1 money += price * rules['clear'] if owned == 6: marks.setdefault('small hall done', t) if owned == 7: marks.setdefault('medium hall open', t) if owned == 14: marks.setdefault('medium hall done', t) if owned == 15: marks.setdefault('large hall open', t) if owned == 26: marks.setdefault('all sectors', t) else: lv[p['id']] += 1 if p['id'] == 'RoadRoller': marks.setdefault('road roller', t) if all(lv[q['id']] == q['max'] for q in perks): marks.setdefault('ALL PERKS', t) order = sorted(marks.items(), key=lambda kv: kv[1]) print(f'{label}: ' + ', '.join(f'{k} {v / 60:.0f}m' for k, v in order) + (f' | perks bought {sum(lv.values())}/{sum(p["max"] for p in perks)}' if 'ALL PERKS' not in marks else '')) def old_income(raw, carpet, lv, hall): pv = 1 + lv['PopValue'] combo = min(4 + 2 * lv['ComboCap'], 12) * 0.85 gold = 1 + (0.01 + 0.01 * lv['Golden']) * {0: 25, 1: 35, 2: 45}.get(lv['GoldRush'], 60) big = 1.6 # big bubbles / giant carpets return raw * pv * combo * gold * big * hall def new_income(raw, carpet, lv, hall): pv = 1 + 0.3 * lv['PopValue'] maxc = 4 + 2 * lv['ComboCap'] combo = 1 + (maxc * 0.85 - 1) * 0.15 gold = 1 + (0.008 + 0.006 * lv['Golden']) * {0: 25, 1: 30, 2: 35}.get(lv['GoldRush'], 45) worth = (1 - carpet) * 1.3 + carpet * 0.2 * 1.6 # sheets (some big) vs carpets at 0.2 return raw * pv * combo * gold * worth * hall OLD = dict(income=old_income, clear=0.6) NEW = dict(income=new_income, clear=0.25) if __name__ == '__main__': # current prices straight from the game code dep = open(os.path.join(ROOT, 'Assets', 'Scripts', 'Gameplay', 'Depot.cs'), encoding='utf-8').read() secs = [(int(h), int(pr)) for h, pr in re.findall(r'hall = (\d), gx = -?\d, gz = \d, price = (\d+)', dep)] perks = perks_from(gd) print('perk total', round(sum(p['base'] * sum(p['growth'] ** i for i in range(p['max'])) for p in perks))) base_rate = list(TOOL_RATE) for n in (1, 2, 4): TOOL_RATE[:] = [(a, b * n / 2, c) for a, b, c in base_rate] run(NEW, perks, secs, [1, 2.5, 6], f'{n} player(s)', horizon_h=16)