2026-09-16 07:58:19 +03:00
|
|
|
extends SceneTree
|
2026-09-30 08:08:27 +03:00
|
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
2026-09-16 07:58:19 +03:00
|
|
|
const Clock = preload("res://world/owniverse/simulation_time.gd")
|
|
|
|
|
var checks: int = 0
|
|
|
|
|
var failures: int = 0
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
call_deferred("run")
|
|
|
|
|
|
|
|
|
|
func check(condition: bool, message: String) -> void:
|
2026-09-30 08:08:27 +03:00
|
|
|
checks = E.add(checks, 1)
|
|
|
|
|
if (not condition):
|
|
|
|
|
failures = E.add(failures, 1)
|
2026-09-16 07:58:19 +03:00
|
|
|
push_error(message)
|
|
|
|
|
|
|
|
|
|
func fixture():
|
|
|
|
|
var world = load("res://world/owniverse/owniverse.gd").new()
|
|
|
|
|
var global: Node = root.get_node("Global")
|
|
|
|
|
for id in global.OwniverseEntities:
|
|
|
|
|
var entity = load("res://world/owniverse/owniverse_entity.gd").new(global.OwniverseEntities[id])
|
2026-09-29 20:23:20 +03:00
|
|
|
world.catalog.entities[id] = entity
|
2026-09-30 08:08:27 +03:00
|
|
|
world.state.amount[id] = 0
|
|
|
|
|
world.state.stats.total_amount[id] = 0
|
|
|
|
|
if E.ne(entity.group_as, ""):
|
|
|
|
|
world.state.amount[entity.group_as] = 0
|
|
|
|
|
world.state.stats.total_amount[entity.group_as] = 0
|
2026-09-29 20:23:20 +03:00
|
|
|
world.catalog.entities["N"].life_product = {}
|
|
|
|
|
world.catalog.entities["N"].product_per_year_type = "H"
|
2026-09-30 08:08:27 +03:00
|
|
|
world.catalog.entities["N"].product_per_year_amount = 10
|
|
|
|
|
world.catalog.entities["N"].auto = 0
|
|
|
|
|
world.state.amount.N = 1
|
2026-09-16 07:58:19 +03:00
|
|
|
return world
|
|
|
|
|
|
|
|
|
|
func dispose(world) -> void:
|
2026-09-29 20:23:20 +03:00
|
|
|
for entity in world.catalog.entities.values():
|
2026-09-16 07:58:19 +03:00
|
|
|
entity.free()
|
|
|
|
|
world.free()
|
|
|
|
|
|
|
|
|
|
func run() -> void:
|
|
|
|
|
var world = fixture()
|
2026-09-30 08:08:27 +03:00
|
|
|
world.state.batch_origins.LGRB = E.of("10357034.80000000074505806")
|
|
|
|
|
var boundary: Variant = E.of("41215289.79999999701976776")
|
|
|
|
|
for interval in [[E.subtract(boundary, E.of("2.5")), E.add(boundary, E.of("2.25"))], [boundary, E.add(boundary, 2)]]:
|
2026-09-16 07:58:19 +03:00
|
|
|
world.state.batches.LGRB = []
|
2026-09-30 08:08:27 +03:00
|
|
|
world.batches.append_batch(world.state, "LGRB", 100, interval[0], interval[1])
|
|
|
|
|
var total: Variant = 0
|
|
|
|
|
var last: Variant = E.neg(INF)
|
|
|
|
|
for batch : Dictionary in world.state.batches.LGRB:
|
|
|
|
|
total = E.add(total, batch.amount)
|
|
|
|
|
check(E.gt(batch.created_from, last), "Batch windows advance monotonically")
|
|
|
|
|
check(E.gt(batch.created_to, batch.created_from), "Positive window duration")
|
|
|
|
|
check(E.ge(batch.amount, 0), "No negative batch amounts")
|
2026-09-16 07:58:19 +03:00
|
|
|
last = batch.created_from
|
2026-09-30 08:08:27 +03:00
|
|
|
check(E.eq(total, 100), "Boundary correction preserves all objects")
|
|
|
|
|
check(E.le(world.state.batches.LGRB.size(), 7), "Finite number of windows")
|
2026-09-16 07:58:19 +03:00
|
|
|
dispose(world)
|
2026-09-30 08:08:27 +03:00
|
|
|
print(("Batch boundaries: %d checks, %d failures" % [checks, failures]))
|
|
|
|
|
quit((0 if E.eq(failures, 0) else 1))
|