Add new tests and implement frame budget management

- Introduced `civilization_benchmark.gd` and `legacy_quantity_math.gd` for benchmarking and legacy quantity calculations.
- Created `test_dynamic_math.gd`, `test_frame_evolution.gd`, and `test_sparse_batches.gd` to validate mathematical operations and frame evolution logic.
- Implemented `frame_budget.gd` to manage cooperative work on the main thread, ensuring no partially calculated state is published.
- Added UID files for all new scripts to maintain unique identifiers.
This commit is contained in:
Kirill
2026-10-01 23:43:34 +03:00
parent f51eea6c0f
commit c4e7302567
53 changed files with 1313 additions and 397 deletions
+18 -2
View File
@@ -38,8 +38,11 @@ func equivalent(a: Variant, b: Variant) -> bool:
for i in a.size():
if (not equivalent(a[i], b[i])): return false
return true
if ((((a is float) or (a is int))) and (((b is float) or (b is int)))):
return E.lt(E.absolute(E.subtract(E.of(a), E.of(b))), E.of("1e-6"))
if E.numeric(a) and E.numeric(b):
# Counts must match exactly. Fractional float remainders can differ
# when the analytic integral replaces thousands of subtractions.
if not E.eq(E.floor_value(a), E.floor_value(b)): return false
return E.le(E.absolute(E.subtract(a, b)), E.of("1e-8"))
return E.eq(a, b)
func run() -> void:
@@ -75,6 +78,19 @@ func run() -> void:
for batch in fast.state.batches.SN: total = E.add(total, batch.amount)
check(E.eq(total, 10000), "Direct completions plus survivors conserve event count")
dispose(fast)
# Dense completed events must not iterate a million elapsed windows.
# An aligned, fully completed cohort produces exactly count * lifespan.
fast = fixture(false)
pending = {}
var lifespan: Variant = fast.catalog.entities.SN.lifespan
var window: Variant = E.divide(lifespan, root.get_node("Global").batch_count) if E.gt(lifespan, 10) else lifespan
var creation_end: Variant = E.multiply(window, 1000000)
var dense_count: Variant = E.of("1e20")
var integral: Variant = fast.batches.append_batch(fast.state, "SN", dense_count, 0, creation_end, pending, E.add(creation_end, lifespan))
check(E.eq(pending.SN[0].amount, dense_count), "Million-window aggregation conserves every event")
check(E.eq(integral, E.multiply(dense_count, lifespan)), "Million-window aggregation preserves lifetime integral")
check(fast.state.batches.SN.is_empty(), "Completed million-window cohort leaves no transient batches")
dispose(fast)
# Sparse explosions: thousands of time windows but very few actual events.
# Exact interval edges and partial final windows exercise the jump boundary.
for count in [1, 3, 17]: