extends SceneTree const E = preload("res://world/owniverse/math/exact.gd") var checks: int = 0 var failures: int = 0 func _initialize(): call_deferred("run") func check(condition: bool, message: String): checks += 1 if not condition: failures += 1 push_error(message) func fixture(id: String, speed: int): var world = load("res://world/owniverse/owniverse.gd").new() world.catalog.load_definitions(root.get_node("Global").OwniverseEntities) for entity in world.catalog.entities.values(): world.state.amount[entity.id] = 0 world.state.stats.total_amount[entity.id] = 0 if entity.group_as != "": world.state.amount[entity.group_as] = 0 world.state.stats.total_amount[entity.group_as] = 0 world.state.amount.RD = 1 world.state.binds.RD = {id: 40000} world.state.batches[id] = [{"amount": 40000, "start_year": 1, "end_year": 1}] # A saved origin off the new grid must not backdate rounded successors. world.state.batch_origins[id] = 500 world.speed = speed world.profile_enabled = true return world func dispose(world): for entity in world.catalog.entities.values(): entity.free() world.free() func run(): for id in ["C0.0", "C0.1", "C0.2"]: var world = fixture(id, 6) world.evolution.evolute_to_datetime(10000) var physical: Dictionary = world.ledger.physical_amounts(world.state) var population: Variant = 0 for stage in physical: if world.catalog.entities[stage].group_as == "Planet": population = E.add(population, physical[stage]) check(E.eq(population, 40000), "Coarse transitions preserve all whole populations: " + id) for batches: Array in world.state.batches.values(): for batch: Dictionary in batches: check(E.gt(batch.start_year, 10000), "Successors cannot expire inside their birth bucket: " + id) if id == "C0.0": check(E.eq(physical.get("C0.0", 0), 38300), "C0.0 attempts evolution once") check(E.eq(physical.get("C0.1", 0), 700), "C0.0 progress rate is applied once") check(E.eq(physical.get("EON5", 0), 1000), "C0.0 degradation rate is applied once") elif id == "C0.1": check(E.eq(physical.get("C0.1", 0), 38300), "C0.1 attempts evolution once") check(E.eq(physical.get("C0.2", 0), 700), "C0.1 successor does not immediately attempt again") else: check(world.profile.civilization_flow_plan[1] == 1, "Ethical civilization uses one continuous interval plan") var before: Dictionary = world.state.duplicate(true) world.evolution.evolute_to_datetime(10000) check(E.eq(world.state, before), "Repeating completed clock does not repeat transitions") var validation: String = root.get_node("SaveManager").validate_data({"format_version": 6, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) check(validation.is_empty(), "Coarse state validates: " + validation) world.evolution.evolute_to_datetime(20000) if id in ["C0.0", "C0.1"]: check(E.lt(world.ledger.physical_amounts(world.state)[id], 38300), "The next bucket still processes legitimate evolution: " + id) dispose(world) var fine = fixture("C0.0", 1) fine.evolution.evolute_to_datetime(10000) check(E.lt(fine.ledger.physical_amounts(fine.state)["C0.0"], 38300), "Low speeds retain multiple chronological generations") dispose(fine) var large = fixture("C0.0", 6) var count: Variant = E.of("10000000000000000000000000000000000000001") large.state.binds.RD["C0.0"] = count large.state.batches["C0.0"][0].amount = count var reference: Dictionary = large.state.duplicate(true) var products: Dictionary = large.life.life_products(reference, large.catalog.entities["C0.0"], count) large.evolution.evolute_to_datetime(10000) var physical: Dictionary = large.ledger.physical_amounts(large.state) for id in products: check(E.eq(physical.get(id, 0), products[id]), "Large whole population undergoes one transition: " + id) check(E.eq(large.state.life_remainders, reference.life_remainders), "Coarse timing preserves the single attempt's fractional carry") dispose(large) print("Coarse generations: %d checks, %d failures" % [checks, failures]) quit(1 if failures else 0)