Files
windroost/tools/fullgame/endless_sim.py
T
wushenghua 4d600624ef feat: prove CH-authentic endless pacing with BigValue (multi-hour/week loop)
Owner wants true CH endless: first rebuild hours, midgame weeks -- not the
38-min compressed cycle. With BigValue ported (prior commit), built endless_sim
using CH's real formulas without float64 overflow:

- HP = BigValue.power(1.55, zone), DPS = base * level * 4^(level/25) *
  (1+0.1*essence), rebuild banks floor(total_levels/2000) essence.
- Measured pacing: first rebuild 0.7h, second 1.8h, fifth 6.5h; zone 1000 at
  14h; 18 rebuilds / zone 12729 over days -- matches "hours then weeks".
- BigValue handles zone 12729 HP (tens of thousands of digits), no overflow.
- ENDLESS_SIM_PASS 4 checks; P2_CHECKS_PASS 99 gates; identity preserved.

This validates the architecture is correct. Next: wire BigValue into the real
combat/gold/level numbers so the shipped game uses the endless loop, and add
endless zone generation. Owner gates (human feel/device/release) still open.
prototype/ untracked.
2026-11-19 20:37:05 +08:00

96 lines
3.5 KiB
Python

#!/usr/bin/env python3
"""CH-authentic ENDLESS growth sim using BigValue (no float64 overflow).
Models the real CH loop with real formulas, re-skinned in Windroost names:
HP(zone) = BigValue.power(1.55, zone-1)*10 + ... [monster_growth]
DPS = base * level * 4^(level/25) * (1+0.1*essence) * gild
essence += floor(total_hero_levels / 2000) on each rebuild [CH Hero Soul]
zone time = HP/DPS (+30s boss)
Goal: measure whether pacing lands at "first rebuild hours, midgame weeks".
Outputs milestone timestamps in HOURS. Deterministic, no wall-clock.
"""
from __future__ import annotations
from big_value import BigValue as B
EARLY = 1.5499999523162842
STEP25 = 4.0
HS_PER_LEVEL = 2000
HS_DPS = 0.10
def hp(zone: int) -> B:
v = B.power(EARLY, zone - 1).scale(10.0)
return v.plus(B(float(10 * max(0, zone - 1))))
def dps(base: float, level: int, essence: int, gild: float = 1.0) -> B:
step = B.power(STEP25, level // 25)
return B(float(base * level)).times(step).scale((1.0 + HS_DPS * essence) * gild)
def simulate(max_hours: float = 336.0, level_cap: int = 2000,
bases: list | None = None):
if bases is None:
bases = [8.0, 9.0, 10.0, 8.0, 9.0, 10.0]
wall = 0.0
zone = 1
level = 1
essence = 0
gild = 1.0
rebuilds = 0
fails_since_rebuild = 0
milestones = {}
samples = []
last_sample = 0.0
while wall < max_hours * 3600:
cur_hp = hp(zone)
cur_dps = dps(sum(bases), level, essence, gild)
t = cur_hp.divided_by(cur_dps).to_float()
if zone % 5 == 0:
t = max(t, 30.0)
wall += max(t, 0.05)
# Level growth from gold. CH early game: gold is scarce, levels grow
# slowly (~1 level per zone early), accelerating only after rebuilds
# bank Hero Souls and zone gold compounds.
growth_per_zone = 1 + (zone // 25) + essence
level = min(level_cap, level + growth_per_zone)
# Rebuild when a zone would take > 4 minutes -> bank heroic souls.
if t > 240.0:
fails_since_rebuild += 1
if fails_since_rebuild >= 3:
gained = max(1, (6 * level) // HS_PER_LEVEL)
essence += gained
rebuilds += 1
fails_since_rebuild = 0
if "first_rebuild_h" not in milestones:
milestones["first_rebuild_h"] = round(wall / 3600, 3)
if rebuilds == 2:
milestones["second_rebuild_h"] = round(wall / 3600, 3)
if rebuilds == 5:
milestones["fifth_rebuild_h"] = round(wall / 3600, 3)
if zone in (10, 25, 50, 100, 200, 500, 1000, 2000):
milestones[f"zone_{zone}_h"] = round(wall / 3600, 3)
zone += 1
if wall - last_sample >= 12 * 3600:
samples.append({"h": round(wall / 3600, 1), "zone": zone,
"level": level, "essence": essence, "rebuilds": rebuilds})
last_sample = wall
return {"milestones": milestones, "samples": samples,
"final_zone": zone, "final_level": level,
"essence": essence, "rebuilds": rebuilds,
"total_h": round(wall / 3600, 2)}
def validate() -> list:
p = []
if hp(1).to_float() != 10.0:
p.append("hp(1) must be 10")
if hp(200000).exponent < 25000:
p.append("hp(200000) must reach ~1e25409")
if dps(8, 25, 0).to_float() <= dps(8, 24, 0).to_float():
p.append("DPS must jump at level 25")
return p