extends SceneTree var failures: Array[String] = [] func _initialize() -> void: call_deferred("_run") func _run() -> void: var creature := CreatureVisual.new() root.add_child(creature) creature.global_position = Vector3.ZERO creature.set_sim_position(Vector3.ZERO) for _frame in 12: await physics_frame _check( creature.path_query_count == 0, "A creature already at its authoritative position should not request a path" ) creature.set_sim_position(Vector3(12.0, 0.0, 0.0)) for _frame in 6: await physics_frame var first_query_count := creature.path_query_count _check(first_query_count == 1, "A true retarget should request one navigation path") for _frame in 20: await physics_frame _check( creature.path_query_count == first_query_count, "An unreachable target should not be queried again every physics frame" ) for _frame in 120: await physics_frame _check( creature.path_query_count <= 4, "Unreachable navigation retries should follow bounded exponential backoff" ) var before_retarget := creature.path_query_count creature.set_sim_position(Vector3(24.0, 0.0, 0.0)) for _frame in 4: await physics_frame _check( creature.path_query_count == before_retarget + 1, "Moving the authoritative target should bypass stale retry delay once" ) creature.free() if failures.is_empty(): print("[TEST] Creature path retry passed: stationary -> backoff -> retarget") quit(0) return for failure in failures: push_error("[TEST] " + failure) quit(1) func _check(condition: bool, message: String) -> void: if not condition: failures.append(message)