本机首次具备引擎自验证能力后的首跑修复。四条命令 + 主场景 180 帧全绿: - --import exit=0(漂移门 git diff data/build 空) - --validate-only exit=0 RESULT: PASS - test_runner exit=0 PASS(584 检查,8/8 用例) - sim_main exit=0(报告落 tests/sim_reports/report-2026-10-20.json) - 主场景 --quit-after 180 exit=0 零 ERROR/WARNING(F5 可玩) 预定位错误(team-lead 清单): - R1 economy_state.gd:596 enthone_ready -> enthrone_ready(单点故障连锁) - R2 hud_root.gd:142,160 HorizontalAlignment.LEFT -> HORIZONTAL_ALIGNMENT_LEFT - R3 boss_arena.gd 补 var _pending_hall_index := -1 - R4 hall_band_world.gd:95 删 "_ = ext"(非法语句;--check-only 定位) - R5 sheet_importer._type_ok 补 object->Dictionary / array->Array(9 条假违规) - R6 game_state.gd econ==null 防护(防 autoload 崩每帧刷错打满管道挂死) 引擎新暴露错误: - R7 prestige_model floor() Variant 推断(4.7.2 按错误)连锁编译失败 - R8 gates.gd var pass 保留字;R9 %g/%.*f 格式符 ×6 处 - R10 greedy.gd Dictionary.get() 推断;R11 probe_p1 条件表达式推断 - R12 测试用例 data 参数统一标 BalanceData(无类型参数成员调用返 Variant) - R13 boss_battle 用例 Dictionary 下标运算显式 float 化 - R14 band_world_root.compute_ranges 返回 Array[Vector2](类型化数组不隐式转换) 测试侧数值修正(根因已核实,实现符合设计): - gen3 可购断言 merit 1000->2000(800 文书 + 1200 首购) - 开场伤害断言改"循环至 ACTIVE 即停"(INTRO 结束 tick 不计军列伤) - 容量断言预算 30->34s(战斗真实给 intro 3s + active 30s) 工程加固: - EconomyState 红线守卫首次越线才报(sim 长跑日志 6.5MB->1KB) - stage_world.gd stretch=false(SubViewport 手动尺寸驱动生效) 知识缺口登记:docs/engineering/2026-10-20-f-engine-first-run-notes.md sim 首轮数据:主口径 11/14 过(#2/#3/#12/#13/#14 FAIL 待文策渊裁定)
70 lines
2.4 KiB
GDScript
70 lines
2.4 KiB
GDScript
class_name GreedyStrategy
|
||
extends SimStrategy
|
||
|
||
# ============================================================================
|
||
# GreedyStrategy —— 回本最快策略(架构 §10.3)
|
||
#
|
||
# 行为模型:每秒点 1 次;每决策点比较
|
||
# ① 可见升级的"回本"(效率:cost / 该班底当前产出)
|
||
# ② 各班底下一级的回本(cost / Δoutput)
|
||
# 买最小者;bulk ×10 解锁后一次买 10 级(仍按回本选班底)。
|
||
# 门 #7(主导策略极差 <1.5×)的对照臂。
|
||
# ============================================================================
|
||
|
||
func _init() -> void:
|
||
strategy_name = "greedy"
|
||
click_rate = 1.0
|
||
|
||
|
||
func act(econ: EconomyState) -> void:
|
||
econ.click()
|
||
# Dictionary.get() 返回 Variant → `:=` 推断会触发 INFERENCE_ON_VARIANT(4.7.2 按错误处理)
|
||
var bulk10: bool = econ.bought.has("up_gate_bulk10") \
|
||
or int(econ.meta_ranks.get("meta_11", 0)) > 0
|
||
var count := 10 if bulk10 else 1
|
||
var best_kind := ""
|
||
var best_id := ""
|
||
var best_gi := -1
|
||
var best_pb := INF
|
||
var gm := econ.global_mult()
|
||
# 升级回本(效率类:产出增量 = 该班底当前产出 × param)
|
||
for u in econ.data.upgrades:
|
||
if econ.bought.has(u.id) or not econ.upgrade_visible(u) or not econ.requires_ok(u):
|
||
continue
|
||
if econ.merit < float(u.cost):
|
||
continue
|
||
var pb := INF
|
||
if u.effect_type == "gen_output_add":
|
||
var gi := econ.gen_index_of(u.target_gen)
|
||
if gi < 0:
|
||
continue
|
||
var g := econ.data.generators[gi]
|
||
var d_out := g.base_rate * float(econ.gen_levels[gi]) * u.effect_param * gm
|
||
pb = float(u.cost) / d_out if d_out > 0.0 else INF
|
||
else:
|
||
# 点击/闸门/离线类:给一个小回本估值(点击区×2 ≈ 点击收益翻倍)
|
||
pb = float(u.cost) / maxf(1.0, econ.click_value() * 2.0)
|
||
if pb < best_pb:
|
||
best_pb = pb
|
||
best_kind = "upgrade"
|
||
best_id = u.id
|
||
best_gi = -1
|
||
# 班底下一级回本
|
||
var best_gen := best_payback_generator(econ)
|
||
if best_gen >= 0:
|
||
var g := econ.data.generators[best_gen]
|
||
var cost := g.cost_range(econ.gen_levels[best_gen], count)
|
||
if econ.merit >= cost:
|
||
var d_out2 := g.base_rate * float(count) * econ.gen_mult(best_gen) * gm
|
||
var pb := cost / d_out2 if d_out2 > 0.0 else INF
|
||
if pb < best_pb:
|
||
best_pb = pb
|
||
best_kind = "generator"
|
||
best_id = g.id
|
||
best_gi = best_gen
|
||
match best_kind:
|
||
"upgrade":
|
||
econ.buy_upgrade(best_id)
|
||
"generator":
|
||
econ.buy_generator(best_gi, count)
|