Files
windroost/p2_godot_sample/scripts/cf_formulas_parity_test.gd
T
wushenghua f6434a5926 feat: bind remaining edict/skill/enemy numbers to CH formula families
User: "数值应该都可以有对应关系." Completed the numeric provenance:

- cf_formulas.py/.gd: added nearest_family(v) (which CH linear family a tuned
  coefficient maps to), monster_hp_mult(tier,boss) (CH monster_growth 1.6^L /
  1.145^L + boss 1.5x), skill_duration_scale (CH skills.json duration 30s ->
  5s combat timebase). CF_FORMULA_PARITY_PASS 41 cases py==gd.
- edict_rules.py now reads coefficients from CH LINEAR_COEFF (D02=linear10
  0.10, D03/D05=linear15 0.15, D04=linear20 0.20, D06=linear25 0.25) instead
  of hardcoded values; only interval/cooldown remain new-game tuning.
- PRODUCTION/52 documents every remaining number's CH correspondence:
  skill damage -> nearest linear family, buff/debuff 5s -> CH 30s/6,
  stun 1.5s -> 5s*0.3, enemy multipliers -> CH monster curve.

Honest boundary: values that are new-game tuned (interval multipliers, exact
skill damage coefficients) are documented as CH-family-derived + tuning, not
passed off as exact CH numbers. Full P2_CHECKS_PASS (93 gates).
prototype/ untracked.
2026-11-19 18:13:44 +08:00

44 lines
1.8 KiB
GDScript

extends SceneTree
## Emits CF formula results for parity with Python.
const CfFormulas = preload("res://scripts/cf_formulas.gd")
const OUTPUT_PATH := "res://artifacts/cf_formulas_parity_gd.json"
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var results: Array = []
var fams := ["linear01", "linear1", "linear5", "linear10", "linear15",
"linear25", "linear0_25", "diminishingreturns", "percent5"]
for fam in fams:
results.append({"kind": "bonus", "family": fam, "level": 10.0,
"value": CfFormulas.bonus_at(fam, 10.0, "100,-0.05")})
for fam in ["linear", "exponential", "polynomial1_5", "one"]:
results.append({"kind": "cost", "family": fam, "level": 10.0,
"value": CfFormulas.cost_at(fam, 10.0, "1")})
for rid in [1, 2, 3, 5, 14, 20]:
results.append({"kind": "relic_family", "id": rid, "value": CfFormulas.relic_family(rid)})
for kind in ["clicks", "kills", "upgrades", "boss", "gold", "quests"]:
results.append({"kind": "daily", "task": kind,
"target": CfFormulas.daily_target(kind), "rubies": CfFormulas.daily_rubies(kind)})
for value in [0.01, 0.1, 0.15, 0.3, 0.35, 0.5, 0.7, 0.9, 1.0]:
results.append({"kind": "nearest", "value": value, "family": CfFormulas.nearest_family(value)})
for tier in [1, 4, 10, 12]:
results.append({"kind": "monster", "tier": tier,
"normal": CfFormulas.monster_hp_mult(tier, false),
"boss": CfFormulas.monster_hp_mult(tier, true)})
for sec in [30.0, 15.0, 60.0]:
results.append({"kind": "duration", "seconds": sec, "value": CfFormulas.skill_duration_scale(sec)})
var dir := ProjectSettings.globalize_path("res://artifacts")
DirAccess.make_dir_recursive_absolute(dir)
var f := FileAccess.open(OUTPUT_PATH, FileAccess.WRITE)
if f != null:
f.store_string(JSON.stringify({"results": results}, "\t", true))
f.close()
print("CF_FORMULA_PARITY_GD cases=%d" % results.size())
quit(0)