Files
windroost/p2_godot_sample/scripts/busy_state_test.gd
T
wushenghua 30f566d0a4 art: run the busy-state falsifying test from the visual contract
PRODUCTION/44 named a next falsifying test: at the busiest representative
state (five enemies plus a flooded damage-number pool), does feedback still
avoid priority state values? Implemented run_busy_state_test.sh with a
geometric probe over every live floating number against all enemy plates,
timer bar and manual controls, plus a real-render capture.

The first attempt at fanning stacked numbers (vertical stagger) actually
pushed them INTO the nameplate band (167px^2 overlap); the geometric test
caught it and I reverted to a sprite-above band with horizontal drift only.
The authoritative anti-goal is covering state values (HP/shield/countdown/
buttons), not the sprite itself, so numbers over the sprite are correct.
Final result: 0px^2 overlap with 16 numbers live, pool capped, reduced-motion
propagates. The busy capture was agent-visually reviewed: focus stays on the
enemy target and its plate stays readable.

tools/run_p2_checks.sh now runs 26 gates; all pass, including parity, pacing,
feedback, log audit and the full capture matrix. Honest open item: stacked
numbers in synchronous injection still cluster; real feel needs a human
recording.
2026-11-17 16:37:50 +08:00

108 lines
3.7 KiB
GDScript

extends SceneTree
## Busy-state falsifying test from PRODUCTION/44.
##
## The contract's anti-goal: floating numbers / VFX must never cover priority
## state values (enemy HP/shield plates, timer). This builds the busiest
## representative state - five enemies plus continuous taps producing up to
## the 16-number pool cap - and checks geometric overlap, then that the pool
## is bounded and every effect returns to rest.
const OUTPUT_PATH := "res://artifacts/busy_state_test.json"
var _problems: Array = []
var _steps: Array = []
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var scene = load("res://scripts/battle_scene.gd").new()
root.add_child(scene)
var battle := scene as BattleScene
battle.set_process(false)
battle.setup("zh_CN", "P3A-N08", 10001)
# Replace with a 5-enemy scenario: the stage cap and the busiest layout.
var scenario := {
"id": "BUSY-FIVE", "node_id": "R1-C01-N08", "mode": "auto",
"enemy_ids": ["E-R1-F1-V1", "E-R1-F2-V1", "E-R1-F3-V1", "E-R1-F5-V1", "E-R1-F10-V1"],
"enemy_specs": {}, "visible_hero_ids": ["H01", "H02", "H04"],
"roster_hero_ids": ["H01", "H02", "H04"],
"input_events": [], "timeout_seconds": 45.0, "hp_scale": 1.0,
}
for eid in scenario["enemy_ids"]:
var spec := LaunchContent.enemy(str(eid))
scenario["enemy_specs"][str(eid)] = {
"hp": float(spec.get("base_hp", 480.0)),
"armor": float(spec.get("armor", 1.0)),
"shield": float(spec.get("shield_max", 0.0)),
"weak_tag": str(spec.get("weak_tag", "")),
"rebuild_at": [], "rebuild_amount": 0.0,
}
battle.set_p3a_scenario(scenario, 0.0, ["H01", "H02", "H04"])
await process_frame
await process_frame
# Drive ~4 seconds while tapping every tick to flood the number pool.
for i in range(40):
P2BattleSim.inject_input(battle.state, {"time": float(battle.state.get("time", 0.0)), "type": "click_enemy"})
battle.advance_ticks(1)
await process_frame
await process_frame
var count := battle.hud.floating_number_count()
_check(count > 0, "busy state should have produced floating numbers")
_check(count <= 16, "floating number pool must be capped at 16, got %d" % count)
_record("pool", {"numbers": count, "cap": 16})
var report := battle.hud.floating_overlap_report()
var worst := float(report["worst_overlap_area"])
_check(worst <= 1.0, "floating numbers must not cover priority plates (worst overlap %.1f px^2)" % worst)
_record("overlap", report)
# Enable reduced motion and confirm numbers still confirm without drift.
battle.set_reduced_motion(true)
await process_frame
_check(battle.hud.reduced_motion, "reduced motion should propagate")
root.remove_child(scene)
scene.free()
_finish()
func _finish() -> void:
var passed := _problems.is_empty()
var report := {
"schema": 1, "kind": "windroost_busy_state_test",
"contract": "PRODUCTION/44 anti-goal: feedback must not cover priority state values",
"overall": "PASS" if passed else "FAIL",
"problems": _problems, "steps": _steps,
}
var artifact_dir := ProjectSettings.globalize_path("res://artifacts")
DirAccess.make_dir_recursive_absolute(artifact_dir)
var file := FileAccess.open(artifact_dir.path_join("busy_state_test.json"), FileAccess.WRITE)
if file != null:
file.store_string(JSON.stringify(report, "\t", true))
file.close()
for entry in _steps:
print("BUSY_STATE_STEP %s" % JSON.stringify(entry))
if passed:
print("BUSY_STATE_PASS %d stages verified" % _steps.size())
else:
print("BUSY_STATE_FAIL %s" % "; ".join(_problems))
quit(0 if passed else 1)
func _check(condition: bool, message: String) -> void:
if not condition:
_problems.append(message)
func _record(name: String, data: Dictionary) -> void:
var entry := data.duplicate()
entry["step"] = name
_steps.append(entry)