273093bd9e
Счётчик времени UI обновляется до 10 Гц по запрошенному времени, а тяжёлые циклы по-прежнему запускаются с адаптивным интервалом и обрабатывают весь накопленный промежуток. Обновить тесты и описание модели.
58 lines
2.3 KiB
GDScript
58 lines
2.3 KiB
GDScript
extends SceneTree
|
|
|
|
var checks: int = 0
|
|
var failures: int = 0
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
|
|
func check(condition: bool, message: String) -> void:
|
|
checks += 1
|
|
if not condition:
|
|
failures += 1
|
|
push_error(message)
|
|
|
|
func run() -> void:
|
|
var world = load("res://world/owniverse/owniverse.gd").new()
|
|
world.adaptive_cadence = false
|
|
world.update_adaptive_quality(250000)
|
|
check(world.adaptive_quality == 2, "A slow cycle selects the medium approximation")
|
|
world.update_adaptive_quality(250000)
|
|
check(world.adaptive_quality == 3, "A slow medium-approximation cycle selects the coarse mode")
|
|
check(world.adaptive_generation_phase == 1, "Coarse generation phase alternates")
|
|
for i in 36: world.update_adaptive_quality(100000)
|
|
check(world.adaptive_quality == 2, "Thirty consecutive recovery cycles lower quality by one level")
|
|
for i in 30: world.update_adaptive_quality(100000)
|
|
check(world.adaptive_quality == 1, "Sustained headroom lowers quality gradually")
|
|
for i in 30: world.update_adaptive_quality(100000)
|
|
check(world.adaptive_quality == 0, "The exact mode returns after sustained headroom")
|
|
|
|
var cadence_world = load("res://world/owniverse/owniverse.gd").new()
|
|
for i in 3: cadence_world.update_adaptive_quality(350000)
|
|
check(cadence_world.cadence_level == 3, "Sustained 350 ms cycles select the 2 Hz cadence")
|
|
check(is_equal_approx(cadence_world.frame_step_seconds, 0.5), "The lowest cadence uses a 0.5 second frame step")
|
|
cadence_world.free()
|
|
|
|
var rows: Array = []
|
|
for node in 12:
|
|
var edges: Dictionary = {}
|
|
var outgoing: float = 0.0
|
|
if node < 6:
|
|
edges[node + 6] = 0.25
|
|
outgoing = 0.25
|
|
rows.append({"edges": edges, "outgoing": outgoing})
|
|
var generator: Dictionary = {"rows": rows, "index": {"source": 0}}
|
|
var solved: Dictionary = world.civilization_flow._solve_single_step(generator, "source", 2.0)
|
|
for ethic in 6:
|
|
var mass: float = 0.0
|
|
var occupation: float = 0.0
|
|
for node in range(ethic, 12, 6):
|
|
mass += solved.mass[node]
|
|
occupation += solved.occupation[node]
|
|
check(absf(mass - 1.0) < 1e-12, "Approximate transition conserves ethic mass %d" % ethic)
|
|
check(absf(occupation - 2.0) < 1e-12, "Approximate transition conserves integrated time %d" % ethic)
|
|
|
|
world.free()
|
|
print("Adaptive quality: %d checks, %d failures" % [checks, failures])
|
|
quit(1 if failures else 0)
|