52 lines
2.6 KiB
GDScript
52 lines
2.6 KiB
GDScript
# VERTICAL SLICE - NOT FOR PRODUCTION
|
||
# Validation Question: 玩家能否无指导在一场完整战斗中经历「开战→挖掘规划→轮末结算逐行兑现→胜/负」并逐行归因(P2)
|
||
# Date: 2026-09-10
|
||
# 一次性检查脚本:打印一场完整战斗的结算步骤流 + 棋盘摘要(肉眼验收 P2 归因质量)。
|
||
# 运行:Godot_console.exe --headless --path . --script res://smoke/dump_battle.gd
|
||
extends SceneTree
|
||
|
||
const AutoPlayer := preload("res://smoke/auto_player.gd") # O4 收口:自动玩家策略单一实现
|
||
|
||
func _initialize() -> void:
|
||
var db = load("res://core/config_db.gd").new()
|
||
db.load_tables("res://data/tables", false)
|
||
var rng = load("res://core/rng_service.gd").new()
|
||
rng.set_master_seed(42) # 种子 = 42;第二个命令行参数可覆盖(关卡 种子)
|
||
var settlement = load("res://core/battle_orchestrator.gd").new(db, rng)
|
||
var stream: Array = []
|
||
settlement.step_row.connect(func(row): stream.append(row))
|
||
var level := 2
|
||
if OS.get_cmdline_user_args().size() > 0:
|
||
level = int(OS.get_cmdline_user_args()[0])
|
||
if OS.get_cmdline_user_args().size() > 1:
|
||
rng.set_master_seed(int(OS.get_cmdline_user_args()[1]))
|
||
settlement.begin_battle({"level_index": level, "node_depth": 0, "hero_hp": db.hero.max_hp})
|
||
print("=== 棋盘摘要 L%d ===" % level)
|
||
var bd = settlement.minesweeper.current_board()
|
||
print("尺寸 %dx%d · 雷 %d · 安全格 %d · R₀ %d" % [bd.width, bd.height, bd.mines.size(), bd.safe_cells().size(), bd.metrics.r0_count])
|
||
print("指标: inferability=%.3f attempts=%s accept=%s" % [bd.metrics.inferability, bd.metrics.attempts_used, bd.metrics.accept_mode])
|
||
var rounds := 0
|
||
while settlement.battle_result == "" and rounds < 40:
|
||
rounds += 1
|
||
var start_round: int = settlement.round_index
|
||
var minesweeper = settlement.minesweeper
|
||
var action_economy = settlement.action_economy
|
||
var guard := 400
|
||
while action_economy.phase == "Active" and settlement.round_index == start_round and guard > 0:
|
||
guard -= 1
|
||
var plan := AutoPlayer.choose_dig(minesweeper)
|
||
if plan.is_empty():
|
||
break
|
||
if plan.hero_cell != minesweeper.hero_pos():
|
||
minesweeper.settle_batch([{"action": "move", "cell": plan.hero_cell}])
|
||
if action_economy.phase == "Active":
|
||
minesweeper.settle_batch([{"action": "dig", "cell": plan.dig_cell}])
|
||
if action_economy.phase == "Active" and settlement.round_index == start_round:
|
||
minesweeper.settle_batch([{"action": "stop"}])
|
||
print("战斗结果: %s(%d 轮)" % [settlement.battle_result, rounds])
|
||
print("=== 结算步骤流(%d 行)===" % stream.size())
|
||
for row in stream:
|
||
print(JSON.stringify(row))
|
||
quit(0)
|
||
|