Add core simulation modules for owniverse mechanics
- Introduced `life_evolution.gd` to manage life evolution processes. - Implemented `manual_production.gd` for handling production mechanics, including resource management and production steps. - Created `object_batches.gd` to manage batches of objects, including scaling and appending batches. - Developed `object_ledger.gd` for tracking physical amounts, available resources, and binding ownerships. - Added `simulation_module.gd` as a base class for simulation modules, providing a weak reference to the world. - Established `stellar_rules.gd` for managing stellar evolution and destruction mechanics. - Introduced `universe_environment.gd` to calculate environmental parameters based on the current state of the universe.
This commit is contained in:
+7
-1
@@ -1,5 +1,11 @@
|
||||
# Проверки поэтапного переноса из Owniverse.U
|
||||
|
||||
## Модули симуляции
|
||||
|
||||
`godot --headless --path Owniverse.GI --script res://tests/test_module_lifecycle.gd`
|
||||
|
||||
Проверяются отдельные экземпляры модулей и состояния для каждой вселенной, слабая обратная ссылка, освобождение модулей вместе с миром и защита от некорректного delta. Остальные тесты используют прямые API batches, ledger, production, automatic, stellar, life, environment и evolution; временные методы-переадресации Owniverse удалены. Описание границ модулей и порядка фаз: `../world/owniverse/README.md`.
|
||||
|
||||
## Математика распределений и каталог
|
||||
|
||||
`godot --headless --path Owniverse.GI --script res://tests/test_quantity_catalog.gd`
|
||||
@@ -43,7 +49,7 @@ godot --headless --path Owniverse.GI --script res://tests/test_ui_updates.gd
|
||||
|
||||
Тест сохранений пишет только в уникальную временную папку `/tmp`, затем удаляет собственные файлы. Проверяются независимость снимка, работа кадров при записи, объединение запросов, диагностическая копия, сохранность предыдущего файла при ошибках и завершение очереди при уничтожении менеджера. Сообщения `Invalid save`, `Save blocked` и `Cannot write` в этом тесте ожидаемы.
|
||||
|
||||
Счётчики, время и кнопки производства обновляются раз в 0,1 секунды. Изменения симуляции помечают суммы для пересчёта; сами суммы вычисляются при обновлении интерфейса. Текст счётчиков применяется только к видимым элементам и только при изменении строки. Переход между страницами, выбор элемента и производство вызывают немедленное обновление. Описания сохраняют прежний интервал 0,25 секунды. Тест интерфейса использует игровую сцену с отключёнными загрузкой, сохранением и автоматической симуляцией, не обращаясь к сохранению игрока.
|
||||
Тест интерфейса проверяет передачу количеств из presentation в контролы, очистку очереди после публикации, отложенное и принудительное обновление, производство по нажатию и формат времени. Stage в текущей реализации применяет очередь счётчиков и время каждый кадр; интервал 0,1 секунды используется для индикаторов. Рефакторинг этот порядок не меняет. Тест использует игровую сцену с отключёнными загрузкой, сохранением и автоматической симуляцией, не обращаясь к сохранению игрока.
|
||||
|
||||
## Время: шаг 0,1 игрового года
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
extends "res://world/owniverse/owniverse.gd"
|
||||
|
||||
# Keep the old materialized-batch path as an independent comparison mode.
|
||||
func _uses_short_lived_fast_path(_id: String) -> bool:
|
||||
return false
|
||||
# Compare with the materialized-batch path, without overriding the coordinator.
|
||||
func _init() -> void:
|
||||
stellar.direct_completions = false
|
||||
|
||||
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -41,7 +41,7 @@ func run() -> void:
|
||||
var boundary: float = 41215289.79999999701976776
|
||||
for interval in [[boundary - 2.5, boundary + 2.25], [boundary, boundary + 2.0]]:
|
||||
world.state.batches.LGRB = []
|
||||
world._append_batch(world.state, "LGRB", 100.0, interval[0], interval[1])
|
||||
world.batches.append_batch(world.state, "LGRB", 100.0, interval[0], interval[1])
|
||||
var total: float = 0.0
|
||||
var last: float = -INF
|
||||
for batch: Dictionary in world.state.batches.LGRB:
|
||||
|
||||
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -39,7 +39,7 @@ func seed_population(world, id: String, count: float, time: float = 1.0) -> void
|
||||
world.state.amount.N = 0.0
|
||||
world.state.amount[id] = count
|
||||
world.state.batches[id] = [{"amount": count, "start_year": time, "end_year": time}]
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
|
||||
func sum_ethics(world, id: String) -> float:
|
||||
var result: float = 0.0
|
||||
@@ -47,7 +47,7 @@ func sum_ethics(world, id: String) -> float:
|
||||
return result
|
||||
|
||||
func invariants(world) -> void:
|
||||
var physical: Dictionary = world._physical_amounts(world.state)
|
||||
var physical: Dictionary = world.ledger.physical_amounts(world.state)
|
||||
for id in world.state.ethics:
|
||||
check(sum_ethics(world, id) == physical.get(id, 0.0), "Ethics equal physical population for " + id)
|
||||
for n in world.state.ethics[id].values():
|
||||
@@ -59,7 +59,7 @@ func run() -> void:
|
||||
var baseline: Dictionary = global.CivilizationRules.duplicate(true)
|
||||
var world = fixture()
|
||||
seed_population(world, "C0.2", 60000.0)
|
||||
world._evolve_batches(world.state, 1.0)
|
||||
world.evolution.evolve_batches(world.state, 1.0)
|
||||
check(world.state.amount["C0.3"] > 0.0, "C0.2 actually progresses")
|
||||
check(world.state.amount["C0.1"] > 0.0, "C0.2 actually degrades")
|
||||
check(world.state.civilization_stats.get("wars", 0.0) == 0.0, "Table disables early wars")
|
||||
@@ -69,8 +69,8 @@ func run() -> void:
|
||||
invariants(world)
|
||||
var restored = fixture()
|
||||
restored.state = bytes_to_var(var_to_bytes(world.state))
|
||||
world._evolve_batches(world.state, 2100.0)
|
||||
restored._evolve_batches(restored.state, 2100.0)
|
||||
world.evolution.evolve_batches(world.state, 2100.0)
|
||||
restored.evolution.evolve_batches(restored.state, 2100.0)
|
||||
check(world.state == restored.state, "Save resumes deterministic ethical evolution")
|
||||
invariants(world)
|
||||
dispose(restored)
|
||||
@@ -80,8 +80,8 @@ func run() -> void:
|
||||
world.state.amount.RD = 1e8
|
||||
seed_population(world, "C2.0", 60000.0)
|
||||
world.state.amount["C1.9"] = 10000.0
|
||||
world.initialize_life_batches()
|
||||
world._evolve_batches(world.state, 1.0)
|
||||
world.evolution.initialize_life_batches()
|
||||
world.evolution.evolve_batches(world.state, 1.0)
|
||||
check(world.state.civilization_stats.wars > 0.0, "Wars execute when enabled")
|
||||
check(world.state.civilization_stats.collateral > 0.0, "Wars affect previous-stage populations")
|
||||
check(world.state.amount["C2.1"] > 0.0, "Winners and peaceful progress reach next stage")
|
||||
@@ -93,14 +93,14 @@ func run() -> void:
|
||||
world.state.binds.RD = {"HP": 5.0, "GG": 5.0, "AB": 5.0, "RP": 5.0}
|
||||
seed_population(world, "C1.6", 60000.0)
|
||||
for row: Dictionary in global.CivilizationRules["C1.6"].ethics.values(): row.degradation = "0"
|
||||
world._evolve_batches(world.state, 1.0)
|
||||
var after: Dictionary = world._physical_amounts(world.state)
|
||||
world.evolution.evolve_batches(world.state, 1.0)
|
||||
var after: Dictionary = world.ledger.physical_amounts(world.state)
|
||||
check(world.state.civilization_stats.colonies == 20.0, "Colonization limited to real targets")
|
||||
check(after.HP + after.GG + after.AB + after.RP == 0.0, "Colonized objects consumed once")
|
||||
check(world.state.binds.RD.get("C1.4", 0.0) == 20.0, "Colonies retain target host and use two-stages-earlier level")
|
||||
var totals: float = 0.0
|
||||
for id in after:
|
||||
if world.entities[id].group_as == "Planet": totals += after[id]
|
||||
if world.catalog.entities[id].group_as == "Planet": totals += after[id]
|
||||
check(totals == 60020.0, "Colonization replaces planets, does not create extra worlds")
|
||||
invariants(world)
|
||||
dispose(world)
|
||||
@@ -114,8 +114,8 @@ func run() -> void:
|
||||
world.state.amount.MGT = 1e25
|
||||
world.state.amount.BH25 = 1e25
|
||||
world.state.amount.SMBH = 1e26
|
||||
for id in world.entities:
|
||||
if world.entities[id].claim != "": world.state.amount[id] = 1e12
|
||||
for id in world.catalog.entities:
|
||||
if world.catalog.entities[id].claim != "": world.state.amount[id] = 1e12
|
||||
# Accelerated deterministic fixture traverses every enabled stage, including Ct.
|
||||
for id in global.CivilizationRules:
|
||||
if id == "Ct": continue
|
||||
@@ -125,11 +125,11 @@ func run() -> void:
|
||||
for row: Dictionary in global.CivilizationRules[id].ethics.values():
|
||||
row.progress = "1"
|
||||
row.degradation = "0"
|
||||
world.entities[id].lifespan = 1.0
|
||||
world.entities[id].lifespan_delta = 1.0
|
||||
world.catalog.entities[id].lifespan = 1.0
|
||||
world.catalog.entities[id].lifespan_delta = 1.0
|
||||
global.CivilizationRules[id].span = 1.0
|
||||
seed_population(world, "C0.2", 6.0)
|
||||
world._evolve_batches(world.state, 1000.0)
|
||||
world.evolution.evolve_batches(world.state, 1000.0)
|
||||
check(world.state.amount.Ct == 6.0, "Complete C0.2 -> C4.4 -> Ct chain runs")
|
||||
check(not world.state.batches.has("Ct"), "Transcendence is terminal")
|
||||
invariants(world)
|
||||
@@ -140,7 +140,7 @@ func run() -> void:
|
||||
world.state.amount.RD = 10000.0
|
||||
world.state.amount.SCS = 1.0
|
||||
world.state.amount["C2.4"] = 1.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
var span: float = world.state.batches["C2.4"][0].start_year
|
||||
check(is_equal_approx(span, 20000.0 / 3.6), "Structure bonus shortens newly registered lifespan")
|
||||
dispose(world)
|
||||
@@ -156,7 +156,7 @@ func run() -> void:
|
||||
world.state.amount.RD = 1e15
|
||||
world.state.amount.BG = 1e15
|
||||
world.state.amount["C3.0"] = 6.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.amount["C3.0"] == 0.0 and world.state.amount["C2.9"] == 6.0, "Missing mandatory structures degrade existing civilizations")
|
||||
invariants(world)
|
||||
dispose(world)
|
||||
|
||||
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -44,24 +44,24 @@ func run() -> void:
|
||||
world.state.amount.RD = 12.0
|
||||
world.state.amount["C0.2"] = 8.0
|
||||
world.state.binds.RD = {"C2.0": 12.0, "C1.9": 3.0}
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.amount["C2.0"] == 12.0 and world.state.binds.RD["C2.0"] == 0.0, "Old space civilizations detach without loss")
|
||||
check(world.state.binds.RD["C1.9"] == 3.0, "Planetary civilizations retain their host")
|
||||
check(world.state.ethics["C0.2"] == {"m": 2.0, "l": 2.0, "w": 1.0, "d": 1.0, "c": 1.0, "b": 1.0}, "Migration uses equal ethics and deterministic remainder")
|
||||
check(world.state.ethics["C2.0"].values().all(func(n): return n == 2.0), "Bound civilization ethics count physical population")
|
||||
var before: Dictionary = world.state.duplicate(true)
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state == before, "Repeated initialization preserves ethics")
|
||||
world.state.ethics["C0.2"] = {"m": 8.0, "l": 0.0, "w": 0.0, "d": 0.0, "c": 0.0, "b": 0.0}
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.ethics["C0.2"].m == 8.0, "Existing unequal distribution is retained")
|
||||
world.state.amount["C0.2"] = 3.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.ethics["C0.2"].m == 3.0, "Losses reduce ethics without inventing population")
|
||||
check(root.get_node("SaveManager").validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Ethics state validates")
|
||||
var restored = fixture()
|
||||
restored.state = bytes_to_var(var_to_bytes(world.state))
|
||||
restored.initialize_life_batches()
|
||||
restored.evolution.initialize_life_batches()
|
||||
check(restored.state == world.state, "Save roundtrip preserves ethics and ownership")
|
||||
dispose(restored)
|
||||
dispose(world)
|
||||
@@ -73,7 +73,7 @@ func run() -> void:
|
||||
row.colonization = "0"
|
||||
world.state.binds.RD = {"C1.9": 10.0}
|
||||
world.state.batches["C1.9"] = [{"amount": 10.0, "start_year": 1.0, "end_year": 1.0}]
|
||||
world._evolve_batches(world.state, 1.0)
|
||||
world.evolution.evolve_batches(world.state, 1.0)
|
||||
check(world.state.amount["C2.0"] == 10.0 and world.state.binds.RD.get("C2.0", 0.0) == 0.0, "Space successor does not inherit planetary binding")
|
||||
dispose(world)
|
||||
var capacity = load("res://world/owniverse/civilization_state.gd")
|
||||
@@ -97,25 +97,25 @@ func run() -> void:
|
||||
world.state.amount.RD = 12.0
|
||||
world.state.amount["C2.1"] = 2.0
|
||||
world.state.amount["C2.0"] = 5.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.amount["C2.1"] == 1.0 and world.state.amount["C2.0"] == 2.0, "Shared budget supports advanced civilizations first")
|
||||
check(world.state.binds.RD["C1.9"] == 4.0, "Excess cascades to supported planetary stage")
|
||||
var snapshot: Dictionary = world.state.duplicate(true)
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state == snapshot, "Capacity enforcement is idempotent")
|
||||
world.state.amount.RD = 0.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.amount["C2.1"] == 0.0 and world.state.amount["C2.0"] == 0.0, "Vanished stars force all unsupported space civilizations down")
|
||||
check(world._physical_amounts(world.state)["C1.9"] == 7.0, "Forced degradation conserves civilizations")
|
||||
check(world.ledger.physical_amounts(world.state)["C1.9"] == 7.0, "Forced degradation conserves civilizations")
|
||||
dispose(world)
|
||||
|
||||
world = fixture()
|
||||
world.state.amount.LGW = 20.0
|
||||
world.state.amount.SMBH = 2.0e22
|
||||
world.state.amount["C4.2"] = 3.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.amount["C4.2"] == 2.0, "SMBH capacity uses stellar mass equivalent")
|
||||
check(world._physical_amounts(world.state)["C1.9"] == 1.0, "Unsupported civilization degrades through missing habitat families")
|
||||
check(world.ledger.physical_amounts(world.state)["C1.9"] == 1.0, "Unsupported civilization degrades through missing habitat families")
|
||||
check(root.get_node("SaveManager").validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Capacity-limited state validates")
|
||||
dispose(world)
|
||||
|
||||
@@ -127,7 +127,7 @@ func run() -> void:
|
||||
row.colonization = "0"
|
||||
world.state.binds.RD = {"C1.9": 5.0}
|
||||
world.state.batches["C1.9"] = [{"amount": 5.0, "start_year": 1.0, "end_year": 1.0}]
|
||||
world._evolve_batches(world.state, 1.0)
|
||||
world.evolution.evolve_batches(world.state, 1.0)
|
||||
check(world.state.amount["C2.0"] == 2.0 and world.state.binds.RD["C1.9"] == 3.0, "Unfunded transition retains the original planetary civilization")
|
||||
dispose(world)
|
||||
print("Civilization state: %d checks, %d failures" % [checks, failures])
|
||||
|
||||
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -65,11 +65,11 @@ func run() -> void:
|
||||
world.state.amount.EON1 = 2.0
|
||||
world.state.binds.G.EON2 = 3.0
|
||||
var saved_state: Dictionary = world.state.duplicate(true)
|
||||
var counters: Dictionary = world.get_item_amounts()
|
||||
var counters: Dictionary = world.presentation.amounts(world.state, world.catalog)
|
||||
check(counters.HP == 7.0 and counters.LP == 5.0 and counters.Planet == 12.0, "Planet counters include bound objects and aggregate eons")
|
||||
check(counters.RD == 2.0, "Star counters retain available quantity")
|
||||
check(world.state == saved_state, "Reading counters does not mutate simulation")
|
||||
check(world.get_item_amounts(true).HP == 0.0, "Produced counters remain independent of current population")
|
||||
check(world.presentation.amounts(world.state, world.catalog, true).HP == 0.0, "Produced counters remain independent of current population")
|
||||
values = description.variables(world, global, "RD", 2.0)
|
||||
check(values.amount.contains("#40cc40") and values.amount.contains("+2.0"), "Increase green")
|
||||
var stage_script = load("res://stage/stage.gd")
|
||||
|
||||
+19
-19
@@ -17,42 +17,42 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
func run() -> void:
|
||||
var world = fixture()
|
||||
for id in world.entities:
|
||||
for id in world.catalog.entities:
|
||||
var expected: Array = []
|
||||
for key in world.entities:
|
||||
if world.entities[key].group_as == id:
|
||||
for key in world.catalog.entities:
|
||||
if world.catalog.entities[key].group_as == id:
|
||||
expected.append(key)
|
||||
check(world._is_group(id) == (not expected.is_empty()), "Group classification: " + id)
|
||||
check(world._members(id) == (expected if not expected.is_empty() else [id]), "Group members: " + id)
|
||||
var members: Array = world._members("Star")
|
||||
check(world.catalog.is_group(id) == (not expected.is_empty()), "Group classification: " + id)
|
||||
check(world.catalog.members(id) == (expected if not expected.is_empty() else [id]), "Group members: " + id)
|
||||
var members: Array = world.catalog.members("Star")
|
||||
members.clear()
|
||||
check(not world._members("Star").is_empty(), "Returned members are independent")
|
||||
world.entities.N.group_as = "TestGroup"
|
||||
world.rebuild_group_index()
|
||||
check(world._members("TestGroup") == ["N"], "Explicit definition reload")
|
||||
world.entities.N.free()
|
||||
world.entities.erase("N")
|
||||
check(not world._is_group("TestGroup"), "Removed definition invalidates index")
|
||||
check(not world.catalog.members("Star").is_empty(), "Returned members are independent")
|
||||
world.catalog.entities.N.group_as = "TestGroup"
|
||||
world.catalog.rebuild_group_index()
|
||||
check(world.catalog.members("TestGroup") == ["N"], "Explicit definition reload")
|
||||
world.catalog.entities.N.free()
|
||||
world.catalog.entities.erase("N")
|
||||
check(not world.catalog.is_group("TestGroup"), "Removed definition invalidates index")
|
||||
print("Group index: %d checks, %d failures" % [checks, failures])
|
||||
dispose(world)
|
||||
quit(1 if failures else 0)
|
||||
|
||||
+24
-24
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -39,25 +39,25 @@ func run() -> void:
|
||||
var world = fixture()
|
||||
world.state.amount.N = 0.0
|
||||
world.state.amount.HP = 40000.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.batches.HP.size() == 1, "Old HP receives life cohort")
|
||||
check(world.state.batches.HP[0].start_year == 5e6, "HP uses source span")
|
||||
var before: Dictionary = world.state.duplicate(true)
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state == before, "Initialization is idempotent")
|
||||
world._evolve_batches(world.state, 5e6 + 5e6 / 40.0)
|
||||
world.evolution.evolve_batches(world.state, 5e6 + 5e6 / 40.0)
|
||||
check(world.state.amount.EON1 == 10.0, "HP abiogenesis follows source probability")
|
||||
check(world.state.amount.RP == 100.0, "HP degradation produces RP")
|
||||
check(world.state.amount.HP == 39890.0, "Unchanged planets retry, not disappear")
|
||||
check(world.state.stats.total_amount.HP == 0.0, "Retry does not inflate creation statistics")
|
||||
check(world.state.batches.HP.size() > 0, "Survivors get next attempt")
|
||||
var physical: Dictionary = world._physical_amounts(world.state)
|
||||
var physical: Dictionary = world.ledger.physical_amounts(world.state)
|
||||
check(physical.HP + physical.EON1 + physical.RP == 40000.0, "Life conserves planets")
|
||||
check(root.get_node("SaveManager").validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Life save validates")
|
||||
var restored = fixture()
|
||||
restored.state = bytes_to_var(var_to_bytes(world.state))
|
||||
world._evolve_batches(world.state, 11e6)
|
||||
restored._evolve_batches(restored.state, 11e6)
|
||||
world.evolution.evolve_batches(world.state, 11e6)
|
||||
restored.evolution.evolve_batches(restored.state, 11e6)
|
||||
check(world.state == restored.state, "Life continuation preserves cohorts and carries")
|
||||
dispose(restored)
|
||||
dispose(world)
|
||||
@@ -65,8 +65,8 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.RD = 1.0
|
||||
world.state.binds.RD = {"EON5": 40000.0}
|
||||
world.initialize_life_batches()
|
||||
world._evolve_batches(world.state, 5e5 + 5e5 / 40.0)
|
||||
world.evolution.initialize_life_batches()
|
||||
world.evolution.evolve_batches(world.state, 5e5 + 5e5 / 40.0)
|
||||
check(world.state.binds.RD["C0.0"] == 10.0, "Intelligence emerges at the same host star")
|
||||
check(world.state.amount["C0.0"] == 0.0, "Life transition keeps planet bound")
|
||||
check(world.state.batches.has("C0.0"), "New C0.0 starts civilization evolution")
|
||||
@@ -77,7 +77,7 @@ func run() -> void:
|
||||
var degraded: float = 0.0
|
||||
var valid_outcomes: bool = true
|
||||
for i in 4001:
|
||||
var products: Dictionary = world._life_products(world.state, world.entities.HP, 1.0)
|
||||
var products: Dictionary = world.life.life_products(world.state, world.catalog.entities.HP, 1.0)
|
||||
var total: float = 0.0
|
||||
for value in products.values():
|
||||
total += value
|
||||
@@ -92,29 +92,29 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.time = {"datetime": 123.4, "year": 123.4}
|
||||
world.state.binds.RD = {"HP": 2.0}
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.batches.HP[0].created_from == 123.4, "Old bound worlds begin life at load time")
|
||||
world._destroy_planets(world.state, "RD", 1.0, 1)
|
||||
world._evolve_batches(world.state, 1e7)
|
||||
check(world._physical_amounts(world.state).HP == 0.0 and world.state.binds.RD.RP == 2.0, "Destroyed life does not resurrect from cohort")
|
||||
world.stellar.destroy_planets(world.state, "RD", 1.0, 1)
|
||||
world.evolution.evolve_batches(world.state, 1e7)
|
||||
check(world.ledger.physical_amounts(world.state).HP == 0.0 and world.state.binds.RD.RP == 2.0, "Destroyed life does not resurrect from cohort")
|
||||
dispose(world)
|
||||
world = fixture()
|
||||
world.state.time = {"datetime": 123.4, "year": 123.4}
|
||||
world.state.amount["C0.0"] = 40000.0
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state.batches["C0.0"][0].created_from == 123.4, "Civilization cohorts begin at the current time")
|
||||
before = world.state.duplicate(true)
|
||||
world.initialize_life_batches()
|
||||
world.evolution.initialize_life_batches()
|
||||
check(world.state == before, "Life batch initialization is idempotent")
|
||||
world._evolve_batches(world.state, 2173.4)
|
||||
world.evolution.evolve_batches(world.state, 2173.4)
|
||||
check(world.state.amount["C0.1"] == 700.0 and world.state.amount.EON5 == 1000.0, "C0.0 progresses and degrades by Unity rates")
|
||||
check(world.state.amount["C0.0"] == 38300.0, "C0.0 remainder stays alive")
|
||||
dispose(world)
|
||||
world = fixture()
|
||||
world.state.amount.RD = 1.0
|
||||
world.state.binds.RD = {"C0.1": 40000.0}
|
||||
world.initialize_life_batches()
|
||||
world._evolve_batches(world.state, 2050.0)
|
||||
world.evolution.initialize_life_batches()
|
||||
world.evolution.evolve_batches(world.state, 2050.0)
|
||||
check(world.state.binds.RD["C0.2"] == 700.0, "C0.1 reaches ethical civilization without losing host")
|
||||
check(world.state.binds.RD["C0.0"] == 1000.0, "C0.1 degradation follows Unity")
|
||||
check(root.get_node("SaveManager").validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Extended life save validates")
|
||||
|
||||
+11
-11
@@ -28,10 +28,10 @@ func run() -> void:
|
||||
world.state.stats.total_amount["C0.0"] = 3.0
|
||||
var before: Dictionary = world.state.duplicate(true)
|
||||
stage._refresh_universe_ui()
|
||||
var counts: Dictionary = world.get_item_amounts()
|
||||
var counts: Dictionary = world.presentation.amounts(world.state, world.catalog)
|
||||
check(counts.EON1 == 12.0 and counts.EON2 == 4.0 and counts.LP == 16.0, "Individual eons and their total include bound planets")
|
||||
check(counts["C0.0"] == 3.0 and counts.C0 == 3.0 and counts.Planet == 19.0, "Civilization detail does not double the planetary total")
|
||||
check(world.get_item_amounts(true).EON1 == 12.0 and world.get_item_amounts(true).LP == 16.0, "Historical counts retain individual and aggregate values")
|
||||
check(world.presentation.amounts(world.state, world.catalog, true).EON1 == 12.0 and world.presentation.amounts(world.state, world.catalog, true).LP == 16.0, "Historical counts retain individual and aggregate values")
|
||||
check(world.state == before, "Presentation does not modify simulation state")
|
||||
var pending: Array = ["EON1", "EON2", "EON3", "C0.0"]
|
||||
var pending_before: Array = pending.duplicate()
|
||||
@@ -40,16 +40,16 @@ func run() -> void:
|
||||
for id in ["EON1", "EON2", "LP", "C0.0", "C0"]:
|
||||
check(decision.visible.has(id), "Unlock projection includes detail and alias: " + id)
|
||||
check(pending == pending_before and world.state == before, "Unlock evaluation leaves inputs untouched")
|
||||
var snapshot: Dictionary = world.items_to_update.duplicate()
|
||||
world.defer_item_updates = true
|
||||
var snapshot: Dictionary = world.presentation.pending_amounts.duplicate()
|
||||
world.presentation.deferred_updates = true
|
||||
world.state.amount.EON1 += 1.0
|
||||
world.refresh_item_amounts()
|
||||
check(world.item_amounts_dirty and world.items_to_update == snapshot, "Deferred refresh retains pending snapshot")
|
||||
world.refresh_item_amounts(true)
|
||||
check(not world.item_amounts_dirty and world.items_to_update.EON1 == 13.0, "Forced refresh publishes latest amounts")
|
||||
world.presentation.refresh(world.state, world.catalog)
|
||||
check(world.presentation.dirty and world.presentation.pending_amounts == snapshot, "Deferred refresh retains pending snapshot")
|
||||
world.presentation.refresh(world.state, world.catalog, true)
|
||||
check(not world.presentation.dirty and world.presentation.pending_amounts.EON1 == 13.0, "Forced refresh publishes latest amounts")
|
||||
world.state.amount.EON1 -= 1.0
|
||||
world.defer_item_updates = false
|
||||
world.refresh_item_amounts()
|
||||
world.presentation.deferred_updates = false
|
||||
world.presentation.refresh(world.state, world.catalog)
|
||||
for id in ["EON1", "EON2", "LP", "C0.0", "C0"]:
|
||||
check(stage.owniverse_items[id].visible, "Unlock both levels: " + id)
|
||||
check(stage.owniverse_items[id].description.text != "", "Populate the icon counter: " + id)
|
||||
@@ -61,7 +61,7 @@ func run() -> void:
|
||||
world.state.binds.RD.EON2 = 0.0
|
||||
stage._refresh_universe_ui()
|
||||
check(stage.owniverse_items.EON2.visible and stage.owniverse_items.EON2.description.text == "", "Previously reached stage stays unlocked after extinction with no stale count")
|
||||
for entity in world.entities.values(): entity.free()
|
||||
for entity in world.catalog.entities.values(): entity.free()
|
||||
world.free()
|
||||
scene.free()
|
||||
print("Life icons: %d checks, %d failures" % [checks, failures])
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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")
|
||||
var first = World.new()
|
||||
var second = World.new()
|
||||
var names: Array = ["batches", "ledger", "production", "automatic", "stellar", "life", "environment", "evolution"]
|
||||
var references: Array = []
|
||||
for name in names:
|
||||
check(first.get(name) != second.get(name), "World has its own " + name)
|
||||
check(first.get(name).world == first, "Module refers to its owner: " + name)
|
||||
references.append(weakref(first.get(name)))
|
||||
first.state.amount.H = 123.0
|
||||
first.presentation.pending_amounts.H = 123.0
|
||||
check(not second.state.amount.has("H") and second.presentation.pending_amounts.is_empty(), "State and pending presentation are isolated")
|
||||
first.free()
|
||||
for reference in references:
|
||||
check(reference.get_ref() == null, "Module is released with its world")
|
||||
check(second.evolution.world == second, "Other world remains usable")
|
||||
var snapshot: Dictionary = second.state.duplicate(true)
|
||||
second.evolute(NAN)
|
||||
second.evolute(-1.0)
|
||||
check(second.state == snapshot, "Entry point rejects invalid time deltas")
|
||||
second.free()
|
||||
print("Module lifecycle: %d checks, %d failures" % [checks, failures])
|
||||
quit(1 if failures else 0)
|
||||
@@ -0,0 +1 @@
|
||||
uid://d2xk4ldldsgo3
|
||||
@@ -17,39 +17,39 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
func run() -> void:
|
||||
var world = fixture()
|
||||
world.initialize_life_batches()
|
||||
world.entities.N.cost = {"H": 2.0}
|
||||
world.entities.N.bind = {"S": 3.0}
|
||||
world.evolution.initialize_life_batches()
|
||||
world.catalog.entities.N.cost = {"H": 2.0}
|
||||
world.catalog.entities.N.bind = {"S": 3.0}
|
||||
world.state.amount.H = 10.0
|
||||
world.state.amount.S = 0.0
|
||||
world.state.auto_resources = {"H": 10.0}
|
||||
world.state.batches.H = [{"amount": 10.0, "start_year": 1.0, "end_year": 2.0}]
|
||||
var before: Dictionary = world.state.duplicate(true)
|
||||
check(not world._try_production(world.state, world.entities.N, 1.0, true), "Binding failure rejects production")
|
||||
check(not world.production.try_production(world.state, world.catalog.entities.N, 1.0, true), "Binding failure rejects production")
|
||||
check(world.state == before, "Failure preserves costs, batches and budget")
|
||||
world.state.amount.S = 10.0
|
||||
var old_batches: Array = world.state.batches.H
|
||||
check(world._try_production(world.state, world.entities.N, 2.0, true), "Funded production succeeds")
|
||||
check(world.production.try_production(world.state, world.catalog.entities.N, 2.0, true), "Funded production succeeds")
|
||||
check(world.state.amount.H == 6.0 and world.state.amount.S == 4.0, "Exact cost and binding")
|
||||
check(world.state.auto_resources.H == 6.0, "Exact automatic budget")
|
||||
check(old_batches[0].amount == 10.0 and world.state.batches.H[0].amount == 6.0, "Consumed batches isolated")
|
||||
|
||||
@@ -14,16 +14,16 @@ func check(condition: bool, message: String) -> void:
|
||||
func fixture(legacy: bool):
|
||||
var world = load("res://tests/fixtures/legacy_stellar_events.gd" if legacy else "res://world/owniverse/owniverse.gd").new()
|
||||
for id in root.get_node("Global").OwniverseEntities:
|
||||
world.entities[id] = load("res://world/owniverse/owniverse_entity.gd").new(root.get_node("Global").OwniverseEntities[id])
|
||||
world.catalog.entities[id] = load("res://world/owniverse/owniverse_entity.gd").new(root.get_node("Global").OwniverseEntities[id])
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if world.entities[id].group_as != "":
|
||||
world.state.amount[world.entities[id].group_as] = 0.0
|
||||
world.state.stats.total_amount[world.entities[id].group_as] = 0.0
|
||||
if world.catalog.entities[id].group_as != "":
|
||||
world.state.amount[world.catalog.entities[id].group_as] = 0.0
|
||||
world.state.stats.total_amount[world.catalog.entities[id].group_as] = 0.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values(): entity.free()
|
||||
for entity in world.catalog.entities.values(): entity.free()
|
||||
world.free()
|
||||
|
||||
func equivalent(a: Variant, b: Variant) -> bool:
|
||||
@@ -55,11 +55,11 @@ func run() -> void:
|
||||
fast.state.batches[parent] = [{"amount": 20000.0, "start_year": 100.3, "end_year": 3000.7}]
|
||||
# Existing short-lived populations test integration with new arrivals.
|
||||
fast.state.amount.SN = 3.0
|
||||
fast._append_batch(fast.state, "SN", 3.0, 100.5, 100.5)
|
||||
fast.batches.append_batch(fast.state, "SN", 3.0, 100.5, 100.5)
|
||||
if year == 104.75: fast.state.energy = 7.0
|
||||
legacy.state = fast.state.duplicate(true)
|
||||
fast._evolve_batches(fast.state, year)
|
||||
legacy._evolve_batches(legacy.state, year)
|
||||
fast.evolution.evolve_batches(fast.state, year)
|
||||
legacy.evolution.evolve_batches(legacy.state, year)
|
||||
for field in fast.state:
|
||||
check(equivalent(fast.state[field], legacy.state[field]), "%s at %s: %s matches materialized events" % [parent, year, field])
|
||||
for id in ["SN", "DSN", "BSN", "HN", "GRB", "SGRB", "LGRB", "HGRB"]:
|
||||
@@ -68,7 +68,7 @@ func run() -> void:
|
||||
dispose(legacy)
|
||||
var fast = fixture(false)
|
||||
var pending: Dictionary = {}
|
||||
fast._append_batch(fast.state, "SN", 10000.0, 0.25, 1667.25, pending, 1667.25)
|
||||
fast.batches.append_batch(fast.state, "SN", 10000.0, 0.25, 1667.25, pending, 1667.25)
|
||||
check(fast.state.batches.SN.size() <= 2 and pending.SN.size() == 1, "Completed windows aggregate without transient batch allocation")
|
||||
var total: float = pending.SN[0].amount
|
||||
for batch in fast.state.batches.SN: total += batch.amount
|
||||
|
||||
+51
-51
@@ -16,72 +16,72 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
func run() -> void:
|
||||
var world = fixture()
|
||||
for id in ["DSN", "SN", "BSN", "HN", "SGRB", "GRB", "LGRB", "HGRB"]:
|
||||
check(world._evolution_products(world.state, world.entities[id], 3.0).blast == 3.0 * world.entities[id].blast, "Entity blast determines power: " + id)
|
||||
world.entities.SN.output_and.blast = 999.0
|
||||
world.entities.SN.blast = 4
|
||||
check(world._evolution_products(world.state, world.entities.SN, 2.0).blast == 8.0, "Imported output cannot override or double blast power")
|
||||
world.entities.SN.blast = 0
|
||||
check(not world._evolution_products(world.state, world.entities.SN, 2.0).has("blast"), "Zero entity blast disables external event")
|
||||
world.entities.SN.output_or = {"positive": "blast:999", "negative": "blast:999", "chance": 50.0}
|
||||
check(not world._evolution_products(world.state, world.entities.SN, 2.0).has("blast"), "Alternative output cannot restore disabled blast")
|
||||
check(world.stellar.evolution_products(world.state, world.catalog.entities[id], 3.0).blast == 3.0 * world.catalog.entities[id].blast, "Entity blast determines power: " + id)
|
||||
world.catalog.entities.SN.output_and.blast = 999.0
|
||||
world.catalog.entities.SN.blast = 4
|
||||
check(world.stellar.evolution_products(world.state, world.catalog.entities.SN, 2.0).blast == 8.0, "Imported output cannot override or double blast power")
|
||||
world.catalog.entities.SN.blast = 0
|
||||
check(not world.stellar.evolution_products(world.state, world.catalog.entities.SN, 2.0).has("blast"), "Zero entity blast disables external event")
|
||||
world.catalog.entities.SN.output_or = {"positive": "blast:999", "negative": "blast:999", "chance": 50.0}
|
||||
check(not world.stellar.evolution_products(world.state, world.catalog.entities.SN, 2.0).has("blast"), "Alternative output cannot restore disabled blast")
|
||||
dispose(world)
|
||||
world = fixture()
|
||||
var rd = world.entities.RD
|
||||
var rd = world.catalog.entities.RD
|
||||
check(rd.planets.HP.chance == 0.01, "Preserve fractional planet probability")
|
||||
check(rd.planets.GG.amount == 2.0 and rd.planets.GG.chance == 0.08, "Read count and chance separately")
|
||||
check(rd._parse_planet_string("HP:1:0.01") == {"HP": {"amount": 1.0, "chance": 0.01}}, "Accept a single planet term")
|
||||
check(rd._parse_planet_string("").is_empty(), "Empty planet definitions stay empty")
|
||||
for id in ["HP", "EON1", "C0.9", "C1.2"]:
|
||||
check(world.entities[id].blastability, "Blast vulnerable: " + id)
|
||||
check(world.catalog.entities[id].blastability, "Blast vulnerable: " + id)
|
||||
for id in ["RP", "GG", "AB", "C1.3", "C1.4", "C1.5"]:
|
||||
check(not world.entities[id].blastability, "Blast protected: " + id)
|
||||
check(not world.catalog.entities[id].blastability, "Blast protected: " + id)
|
||||
|
||||
# Actual GI table: HRG -> SN, with 1% GRB; no random rounding.
|
||||
var totals: Dictionary = {}
|
||||
for i in 100:
|
||||
var products: Dictionary = world._evolution_products(world.state, world.entities.HRG, 1.0)
|
||||
var products: Dictionary = world.stellar.evolution_products(world.state, world.catalog.entities.HRG, 1.0)
|
||||
for id in products:
|
||||
totals[id] = totals.get(id, 0.0) + products[id]
|
||||
check(totals.get("SN") == 99.0 and totals.get("GRB") == 1.0, "GI rare outcomes accumulate deterministically")
|
||||
var restored = fixture()
|
||||
restored.state = bytes_to_var(var_to_bytes(world.state))
|
||||
check(world._evolution_products(world.state, world.entities.HRG, 37.0) == restored._evolution_products(restored.state, restored.entities.HRG, 37.0), "Evolution carry survives serialization")
|
||||
check(world.stellar.evolution_products(world.state, world.catalog.entities.HRG, 37.0) == restored.stellar.evolution_products(restored.state, restored.catalog.entities.HRG, 37.0), "Evolution carry survives serialization")
|
||||
dispose(restored)
|
||||
|
||||
# Real RD lifespan, four stars spread over the existing lifespan/40 window.
|
||||
world.state.amount.N = 0.0
|
||||
world.state.amount.RD = 4.0
|
||||
world._append_batch(world.state, "RD", 4.0, 0.0, 0.0)
|
||||
world.batches.append_batch(world.state, "RD", 4.0, 0.0, 0.0)
|
||||
var lifespan: float = rd.lifespan
|
||||
var width: float = rd.lifespan_delta
|
||||
world._evolve_batches(world.state, lifespan)
|
||||
world.evolution.evolve_batches(world.state, lifespan)
|
||||
check(world.state.amount.RD == 4.0, "Window start does not kill the whole batch")
|
||||
world._evolve_batches(world.state, lifespan + width / 4.0)
|
||||
world.evolution.evolve_batches(world.state, lifespan + width / 4.0)
|
||||
check(world.state.amount.RD == 3.0 and world.state.amount.TWD == 1.0, "One quarter of a batch evolves")
|
||||
world._evolve_batches(world.state, lifespan + width / 2.0)
|
||||
world.evolution.evolve_batches(world.state, lifespan + width / 2.0)
|
||||
check(world.state.amount.RD == 2.0 and world.state.amount.TWD == 2.0, "Half the batch evolves")
|
||||
world._evolve_batches(world.state, lifespan + width)
|
||||
world.evolution.evolve_batches(world.state, lifespan + width)
|
||||
check(world.state.amount.RD == 0.0 and world.state.amount.TWD == 4.0, "Window end completes evolution")
|
||||
check(world.state.batches.RD.is_empty(), "Completed batch removed")
|
||||
dispose(world)
|
||||
@@ -89,7 +89,7 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.RD = 100.0
|
||||
for i in 100:
|
||||
world._create_planets(world.state, "RD", 1.0, 0.0, 0.0, 1.0)
|
||||
world.stellar.create_planets(world.state, "RD", 1.0, 0.0, 0.0, 1.0)
|
||||
check(world.state.binds.RD.HP == 1.0, "100 RD at metallicity 1 produce one HP")
|
||||
check(world.state.binds.RD.RP == 21.0, "Rocky planet probability retains fractions")
|
||||
check(world.state.binds.RD.GG == 16.0 and world.state.binds.RD.AB == 120.0, "Planet multiplicity applied")
|
||||
@@ -98,8 +98,8 @@ func run() -> void:
|
||||
check(saves.validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Planet carry save validates")
|
||||
restored = fixture()
|
||||
restored.state = bytes_to_var(var_to_bytes(world.state))
|
||||
world._create_planets(world.state, "RD", 37.0, 0.0, 0.0, 0.7)
|
||||
restored._create_planets(restored.state, "RD", 37.0, 0.0, 0.0, 0.7)
|
||||
world.stellar.create_planets(world.state, "RD", 37.0, 0.0, 0.0, 0.7)
|
||||
restored.stellar.create_planets(restored.state, "RD", 37.0, 0.0, 0.0, 0.7)
|
||||
check(world.state == restored.state, "Planet carry continues after save")
|
||||
dispose(restored)
|
||||
dispose(world)
|
||||
@@ -108,14 +108,14 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.RD = 4.0
|
||||
world.state.binds.RD = {"HP": 8.0, "RP": 4.0, "C1.2": 4.0, "C1.3": 4.0, "GG": 4.0}
|
||||
world._append_batch(world.state, "RD", 4.0, 0.0, 0.0)
|
||||
world._evolve_batches(world.state, lifespan + width / 2.0)
|
||||
world.batches.append_batch(world.state, "RD", 4.0, 0.0, 0.0)
|
||||
world.evolution.evolve_batches(world.state, lifespan + width / 2.0)
|
||||
check(world.state.amount.RD == 2.0 and world.state.amount.TWD == 2.0, "Partial star transition with planets")
|
||||
check(world.state.binds.RD.HP + world.state.binds.TWD.HP == 4.0, "Half of HP sterilized")
|
||||
check(world.state.binds.RD["C1.3"] == 2.0 and world.state.binds.TWD["C1.3"] == 2.0, "Protected civilization splits between parent and heir")
|
||||
check(world.state.binds.RD.RP + world.state.binds.TWD.RP == 10.0, "Sterilized planets become RP without loss")
|
||||
check(world.state.amount.RP == 0.0 and world.state.amount["C1.3"] == 0.0, "Inherited planets never become free")
|
||||
world._evolve_batches(world.state, lifespan + width)
|
||||
world.evolution.evolve_batches(world.state, lifespan + width)
|
||||
check(world.state.binds.RD["C1.3"] == 0.0 and world.state.binds.TWD["C1.3"] == 4.0, "No planets left at extinct parent type")
|
||||
check(saves.validate_data({"format_version": 2, "app_version": "", "ui": {"current_page": 0}, "state": world.state}) == "", "Inherited state validates")
|
||||
dispose(world)
|
||||
@@ -123,9 +123,9 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.WS = 2.0
|
||||
world.state.binds.WS = {"HP": 4.0, "C1.3": 4.0, "RP": 4.0, "GG": 4.0}
|
||||
world._append_batch(world.state, "WS", 2.0, 0.0, 0.0)
|
||||
world._evolve_batches(world.state, world.entities.WS.lifespan + world.entities.WS.lifespan_delta)
|
||||
var physical: Dictionary = world._physical_amounts(world.state)
|
||||
world.batches.append_batch(world.state, "WS", 2.0, 0.0, 0.0)
|
||||
world.evolution.evolve_batches(world.state, world.catalog.entities.WS.lifespan + world.catalog.entities.WS.lifespan_delta)
|
||||
var physical: Dictionary = world.ledger.physical_amounts(world.state)
|
||||
check(physical.HP == 0.0 and physical["C1.3"] == 0.0 and physical.RP == 0.0 and physical.GG == 0.0, "Level 2 removes all planets, including protected civilization")
|
||||
check(world.state.amount.LRG == 2.0, "Giant evolves after local destruction")
|
||||
dispose(world)
|
||||
@@ -133,10 +133,10 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.RD = 10.0
|
||||
world.state.binds.RD = {"HP": 10.0, "C1.2": 10.0, "C1.3": 10.0, "RP": 0.0}
|
||||
world._apply_blast(world.state, 5.0, {"blast": 1.0, "density": 1.0})
|
||||
world.stellar.apply_blast(world.state, 5.0, {"blast": 1.0, "density": 1.0})
|
||||
check(world.state.binds.RD.HP == 5.0 and world.state.binds.RD["C1.2"] == 5.0, "Blast damages vulnerable worlds proportionally")
|
||||
check(world.state.binds.RD["C1.3"] == 10.0 and world.state.binds.RD.RP == 10.0, "Blast protects C1.3 and creates RP")
|
||||
world._apply_blast(world.state, 1e6, {"blast": 1.0, "density": 1.0})
|
||||
world.stellar.apply_blast(world.state, 1e6, {"blast": 1.0, "density": 1.0})
|
||||
check(world.state.binds.RD.HP == 0.0 and world.state.binds.RD.RP == 20.0, "Overwhelming blast is capped at available planets")
|
||||
check(not world.state.amount.has("blast"), "Blast is not a resource")
|
||||
dispose(world)
|
||||
@@ -145,15 +145,15 @@ func run() -> void:
|
||||
world.state.amount.RD = 1.0
|
||||
world.state.binds.RD = {"HP": 1.0}
|
||||
for i in 10:
|
||||
world._apply_blast(world.state, 1.0, {"blast": 1.0, "density": 0.1})
|
||||
world.stellar.apply_blast(world.state, 1.0, {"blast": 1.0, "density": 0.1})
|
||||
check(world.state.binds.RD.HP == 0.0 and world.state.binds.RD.RP == 1.0, "Small blast effects accumulate across cycles")
|
||||
dispose(world)
|
||||
|
||||
# Actual supernova output: one SN gives a neutron star, resources, and an event.
|
||||
world = fixture()
|
||||
world.state.amount.SN = 1.0
|
||||
world._append_batch(world.state, "SN", 1.0, 0.0, 0.0)
|
||||
world._evolve_batches(world.state, 2.0)
|
||||
world.batches.append_batch(world.state, "SN", 1.0, 0.0, 0.0)
|
||||
world.evolution.evolve_batches(world.state, 2.0)
|
||||
check(world.state.amount.SN == 0.0 and world.state.amount.LNS == 1.0, "Supernova produces a remnant")
|
||||
check(world.state.amount.H == 8.0 and world.state.amount.He == 50.0 and world.state.amount.Met == 11.0, "Supernova returns table resources")
|
||||
check(not world.state.amount.has("blast"), "Supernova dispatches blast output")
|
||||
@@ -163,7 +163,7 @@ func run() -> void:
|
||||
world = fixture()
|
||||
world.state.amount.H = 1000.0
|
||||
world.state.amount.Met = 100.0
|
||||
check(world.produce("RD", 100.0) == 100.0, "Manual star creation succeeds")
|
||||
check(world.production.produce("RD", 100.0) == 100.0, "Manual star creation succeeds")
|
||||
check(world.state.binds.RD.HP >= 1.0, "Manual creation dispatches planet formation")
|
||||
check(world.state.amount.H == 900.0, "Planet creation does not duplicate or spend stellar fuel")
|
||||
dispose(world)
|
||||
@@ -180,25 +180,25 @@ func run() -> void:
|
||||
dispose(world)
|
||||
|
||||
world = fixture()
|
||||
world.entities.N.auto = 1.0
|
||||
world.catalog.entities.N.auto = 1.0
|
||||
# 1000 newly produced automatic H reserve 1 H, enough for 10 HBD.
|
||||
world.evolute(100.0)
|
||||
check(world.state.amount.HBD == 10.0, "Brown dwarfs form without existing ordinary stars")
|
||||
check(world.state.amount.H == 999.0 and world.state.auto_resources.H == 999.0, "Brown dwarfs consume exactly their reserved hydrogen")
|
||||
check(world.get_item_amounts().BD == 10.0 and world.state.batches.HBD.size() > 0, "Brown dwarfs appear in counter and evolution batches")
|
||||
world.entities.N.product_per_year_amount = 0.0
|
||||
check(world.presentation.amounts(world.state, world.catalog).BD == 10.0 and world.state.batches.HBD.size() > 0, "Brown dwarfs appear in counter and evolution batches")
|
||||
world.catalog.entities.N.product_per_year_amount = 0.0
|
||||
world.evolute(100.0)
|
||||
check(world.state.amount.HBD == 10.0, "Stored automatic budget is not taxed repeatedly")
|
||||
dispose(world)
|
||||
|
||||
world = fixture()
|
||||
world.entities.N.auto = 1.0
|
||||
world.catalog.entities.N.auto = 1.0
|
||||
world.state.amount.RD = 1.0
|
||||
world.evolute(50.0)
|
||||
check(world.state.amount.HBD == 5.0 and is_equal_approx(world.state.auto_star_deficits.HBD_fuel, 0.5), "Individual dwarfs retain prepaid fractional fuel")
|
||||
check(world.state.amount.H == 0.0, "Prepaid fuel is not available to ordinary stars")
|
||||
var resumed = fixture()
|
||||
resumed.entities.N.auto = 1.0
|
||||
resumed.catalog.entities.N.auto = 1.0
|
||||
resumed.state = bytes_to_var(var_to_bytes(world.state))
|
||||
world.evolute(50.0)
|
||||
resumed.evolute(50.0)
|
||||
@@ -206,8 +206,8 @@ func run() -> void:
|
||||
check(world.state == resumed.state, "Brown dwarf quota survives serialization deterministically")
|
||||
check(world.state.amount.RD == 1000.0 and world.state.amount.H == 0.0, "Shared automatic hydrogen is spent once")
|
||||
world.state.batches.HBD = [{"amount": 10.0, "start_year": 101.0, "end_year": 101.0}]
|
||||
world._evolve_batches(world.state, 101.0)
|
||||
check(world.state.amount.HBD == 0.0 and world.state.amount.CBD == 10.0 and world.get_item_amounts().BD == 10.0, "Cooling preserves aggregate brown dwarf count")
|
||||
world.evolution.evolve_batches(world.state, 101.0)
|
||||
check(world.state.amount.HBD == 0.0 and world.state.amount.CBD == 10.0 and world.presentation.amounts(world.state, world.catalog).BD == 10.0, "Cooling preserves aggregate brown dwarf count")
|
||||
dispose(resumed)
|
||||
dispose(world)
|
||||
|
||||
@@ -217,7 +217,7 @@ func run() -> void:
|
||||
world.state.amount.H += 1.0
|
||||
world.state.auto_resources.H = world.state.auto_resources.get("H", 0.0) + 1.0
|
||||
var before: float = world.state.amount.HBD
|
||||
world._produce_brown_dwarfs(world.state, 1.0, float(i), float(i + 1))
|
||||
world.automatic.produce_brown_dwarfs(world.state, 1.0, float(i), float(i + 1))
|
||||
var born: float = world.state.amount.HBD - before
|
||||
check(born == 0.0 or born == 1.0, "Small fuel increments produce individual dwarfs")
|
||||
saw_individual = saw_individual or born == 1.0
|
||||
@@ -228,23 +228,23 @@ func run() -> void:
|
||||
for simulation in [world, resumed]:
|
||||
simulation.state.amount.H += 1.0
|
||||
simulation.state.auto_resources.H += 1.0
|
||||
simulation._produce_brown_dwarfs(simulation.state, 1.0, float(i), float(i + 1))
|
||||
simulation.automatic.produce_brown_dwarfs(simulation.state, 1.0, float(i), float(i + 1))
|
||||
check(world.state == resumed.state, "Random sequence and prepaid fuel survive saving")
|
||||
check(is_equal_approx(world.state.amount.H + world.state.amount.HBD * 0.1 + world.state.auto_star_deficits.HBD_fuel, 500.0), "Individual production conserves fuel including prepaid reserve")
|
||||
check(is_equal_approx(world.state.amount.HBD + world.state.auto_star_deficits.HBD, 5.0), "Signed remainder preserves the 0.1 percent allocation")
|
||||
var paused_count: float = world.state.amount.HBD
|
||||
for i in 10: world._produce_brown_dwarfs(world.state, 0.0, 500.0, 501.0)
|
||||
for i in 10: world.automatic.produce_brown_dwarfs(world.state, 0.0, 500.0, 501.0)
|
||||
check(world.state.amount.HBD == paused_count, "No repeated random attempts without new fuel")
|
||||
dispose(resumed)
|
||||
dispose(world)
|
||||
|
||||
# Two simultaneous successors share surviving planets in the same 99:1 ratio.
|
||||
world = fixture()
|
||||
world.entities.HRG.destroy_level = 0
|
||||
world.catalog.entities.HRG.destroy_level = 0
|
||||
world.state.amount.HRG = 100.0
|
||||
world.state.binds.HRG = {"C1.3": 100.0}
|
||||
world.state.batches.HRG = [{"start_year": 0.1, "end_year": 0.1, "amount": 100.0}]
|
||||
world._evolve_batches(world.state, 0.1)
|
||||
world.evolution.evolve_batches(world.state, 0.1)
|
||||
check(world.state.binds.SN["C1.3"] == 99.0 and world.state.binds.GRB["C1.3"] == 1.0, "Planets split among actual alternative successors")
|
||||
check(world.state.binds.HRG["C1.3"] == 0.0, "Alternative evolution leaves no orphan bindings")
|
||||
dispose(world)
|
||||
|
||||
+8
-8
@@ -17,21 +17,21 @@ func fixture():
|
||||
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])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
world.state.amount[entity.group_as] = 0.0
|
||||
world.state.stats.total_amount[entity.group_as] = 0.0
|
||||
world.entities["N"].life_product = {}
|
||||
world.entities["N"].product_per_year_type = "H"
|
||||
world.entities["N"].product_per_year_amount = 10.0
|
||||
world.entities["N"].auto = 0.0
|
||||
world.catalog.entities["N"].life_product = {}
|
||||
world.catalog.entities["N"].product_per_year_type = "H"
|
||||
world.catalog.entities["N"].product_per_year_amount = 10.0
|
||||
world.catalog.entities["N"].auto = 0.0
|
||||
world.state.amount.N = 1.0
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values():
|
||||
for entity in world.catalog.entities.values():
|
||||
entity.free()
|
||||
world.free()
|
||||
|
||||
@@ -80,8 +80,8 @@ func run() -> void:
|
||||
dispose(world)
|
||||
|
||||
world = fixture()
|
||||
world.entities.N.output_and = {"He": 1.0}
|
||||
world.entities.N.output_or = {}
|
||||
world.catalog.entities.N.output_and = {"He": 1.0}
|
||||
world.catalog.entities.N.output_or = {}
|
||||
world.state.batches.N = [{"start_year": 0.1, "end_year": 0.1, "amount": 1.0}]
|
||||
world.evolute(0.1)
|
||||
check(world.state.amount.N == 0.0 and world.state.amount.He == 1.0, "Existing evolution executes at fractional boundary")
|
||||
|
||||
+20
-15
@@ -24,31 +24,36 @@ func run() -> void:
|
||||
await process_frame
|
||||
stage.owniverse.state.amount.H = 1000.0
|
||||
stage.owniverse.state.amount.RD = 2.0
|
||||
stage.owniverse.refresh_item_amounts()
|
||||
stage._update_ui(0.0)
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
||||
stage.set_owniverse_item_value()
|
||||
var hydrogen = stage.owniverse_items.H
|
||||
var dwarf = stage.owniverse_items.RD
|
||||
check(hydrogen.description.text == "1 000", "Visible page updates immediately on navigation")
|
||||
check(dwarf.description.text == "", "Offscreen counters are not rendered")
|
||||
check(hydrogen.description.text == "1 000", "Pending quantities reach controls")
|
||||
check(dwarf.description.text == "2", "Other page receives its current quantity")
|
||||
check(stage.owniverse.presentation.pending_amounts.is_empty(), "Published queue is consumed by Stage")
|
||||
stage.owniverse.presentation.deferred_updates = true
|
||||
stage.owniverse.state.amount.H = 2000.0
|
||||
stage.owniverse.refresh_item_amounts()
|
||||
check(stage.owniverse.item_amounts_dirty and stage.owniverse.items_to_update.H == 1000.0, "Simulation invalidates without recalculating display sums")
|
||||
stage._update_ui(0.05)
|
||||
check(hydrogen.description.text == "1 000", "No refresh before interval")
|
||||
stage._update_ui(0.051)
|
||||
check(hydrogen.description.text == "2 000" and not stage.owniverse.item_amounts_dirty, "Latest state appears at interval")
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
||||
check(stage.owniverse.presentation.dirty and stage.owniverse.presentation.pending_amounts.is_empty(), "Deferred refresh marks dirty without republishing")
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == "1 000", "Labels retain last published quantity")
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog, true)
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == "2 000" and not stage.owniverse.presentation.dirty, "Forced refresh publishes latest state")
|
||||
stage.owniverse.presentation.deferred_updates = false
|
||||
stage.item_activated(hydrogen)
|
||||
check(hydrogen.description.text == root.get_node("Global").format_number(stage.owniverse.state.amount.H), "Player production updates counter immediately")
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == root.get_node("Global").format_number(stage.owniverse.state.amount.H), "Player production publishes the new quantity")
|
||||
check(stage.owniverse.state.amount.H > 2000.0, "Production action actually executed")
|
||||
dwarf.visible = true
|
||||
stage.stage_page_scroller.scroll_horizontal = 2 * stage.PAGE_WIDTH
|
||||
await process_frame
|
||||
stage._update_ui(0.0)
|
||||
stage._refresh_universe_ui()
|
||||
check(dwarf.description.text == "2", "Newly visible page receives cached latest values")
|
||||
stage.owniverse.state.time.year = 1234.5
|
||||
stage._update_ui(0.1)
|
||||
check(stage.date_time.text == "1 234.5", "Time uses throttled display with tenths")
|
||||
for entity in stage.owniverse.entities.values(): entity.free()
|
||||
stage._refresh_universe_ui()
|
||||
check(stage.date_time.text == "1 234.5", "Time displays tenths with thousands separator")
|
||||
for entity in stage.owniverse.catalog.entities.values(): entity.free()
|
||||
stage.owniverse.free()
|
||||
scene.free()
|
||||
print("UI updates: %d checks, %d failures" % [checks, failures])
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
extends SceneTree
|
||||
const CivilizationState = preload("res://world/owniverse/civilization_state.gd")
|
||||
const CivilizationEvolution = preload("res://world/owniverse/civilization_evolution.gd")
|
||||
|
||||
const Parameters = preload("res://world/owniverse/world_parameters.gd")
|
||||
const Descriptions = preload("res://world/owniverse/item_description.gd")
|
||||
@@ -18,7 +20,7 @@ func fixture():
|
||||
var world = load("res://world/owniverse/owniverse.gd").new()
|
||||
for id in root.get_node("Global").OwniverseEntities:
|
||||
var entity = load("res://world/owniverse/owniverse_entity.gd").new(root.get_node("Global").OwniverseEntities[id])
|
||||
world.entities[id] = entity
|
||||
world.catalog.entities[id] = entity
|
||||
world.state.amount[id] = 0.0
|
||||
world.state.stats.total_amount[id] = 0.0
|
||||
if entity.group_as != "":
|
||||
@@ -27,49 +29,49 @@ func fixture():
|
||||
return world
|
||||
|
||||
func dispose(world) -> void:
|
||||
for entity in world.entities.values(): entity.free()
|
||||
for entity in world.catalog.entities.values(): entity.free()
|
||||
world.free()
|
||||
|
||||
func run() -> void:
|
||||
var global: Node = root.get_node("Global")
|
||||
var world = fixture()
|
||||
world.state.amount.RD = 400.0
|
||||
world._append_batch(world.state, "RD", 400.0, 0.0, 0.0)
|
||||
world.batches.append_batch(world.state, "RD", 400.0, 0.0, 0.0)
|
||||
var end: float = world.state.batches.RD[0].end_year
|
||||
world.modify_world_parameter("Bur", 9.0)
|
||||
world.environment.modify_world_parameter("Bur", 9.0)
|
||||
check(is_equal_approx(world.state.batches.RD[0].end_year, end / 10.0), "Burnability accelerates existing cohorts")
|
||||
var count: float = world.state.batches.RD[0].amount
|
||||
world.modify_world_parameter("Bur", -9.0)
|
||||
world.environment.modify_world_parameter("Bur", -9.0)
|
||||
check(is_equal_approx(world.state.batches.RD[0].end_year, end) and world.state.batches.RD[0].amount == count, "Changing burnability back preserves population and lifetime")
|
||||
world.modify_world_parameter("Bur", 9.0)
|
||||
world._append_batch(world.state, "YD", 10.0, 0.0, 0.0)
|
||||
check(is_equal_approx(world.state.batches.YD[0].start_year, world.entities.YD.lifespan / 10.0), "New stars use the same burnability")
|
||||
world.environment.modify_world_parameter("Bur", 9.0)
|
||||
world.batches.append_batch(world.state, "YD", 10.0, 0.0, 0.0)
|
||||
check(is_equal_approx(world.state.batches.YD[0].start_year, world.catalog.entities.YD.lifespan / 10.0), "New stars use the same burnability")
|
||||
world.state.time = {"datetime": end / 10.0 - 0.1, "year": end / 10.0 - 0.1}
|
||||
world._withdraw_batches(world.state, "RD", world.state.time.year)
|
||||
world.modify_world_parameter("Bur", -18.0)
|
||||
world.batches.withdraw_batches(world.state, "RD", world.state.time.year)
|
||||
world.environment.modify_world_parameter("Bur", -18.0)
|
||||
check(world.state.batches.RD[0].end_year >= world.state.time.year, "Slowing a partially evolved cohort keeps its remaining window in the future")
|
||||
world.modify_world_parameter("Exp", 9.0)
|
||||
check(world._evolution_products(world.state, world.entities.SN, 2.0).blast == 180.0, "Explosion power includes world explosiveness")
|
||||
var products: Dictionary = world._evolution_products(world.state, world.entities.HRG, 1000.0)
|
||||
world.environment.modify_world_parameter("Exp", 9.0)
|
||||
check(world.stellar.evolution_products(world.state, world.catalog.entities.SN, 2.0).blast == 180.0, "Explosion power includes world explosiveness")
|
||||
var products: Dictionary = world.stellar.evolution_products(world.state, world.catalog.entities.HRG, 1000.0)
|
||||
check(products.get("GRB", 0.0) == 100.0 and products.get("SN", 0.0) == 900.0, "Explosiveness raises rare-event probability without duplicating stars")
|
||||
world.entities.HRG.output_or.chance = 50.0
|
||||
products = world._evolution_products(world.state, world.entities.HRG, 100.0)
|
||||
world.catalog.entities.HRG.output_or.chance = 50.0
|
||||
products = world.stellar.evolution_products(world.state, world.catalog.entities.HRG, 100.0)
|
||||
check(products.get("GRB", 0.0) == 100.0 and products.get("SN", 0.0) == 0.0, "Rare-event probability is bounded at one")
|
||||
dispose(world)
|
||||
|
||||
world = fixture()
|
||||
var ordinary: Dictionary = world._life_products(world.state, world.entities.HP, 1000000.0)
|
||||
var ordinary: Dictionary = world.life.life_products(world.state, world.catalog.entities.HP, 1000000.0)
|
||||
world.state.life_remainders.clear()
|
||||
world.modify_world_parameter("Agg", 9.0)
|
||||
var aggressive: Dictionary = world._life_products(world.state, world.entities.HP, 1000000.0)
|
||||
world.environment.modify_world_parameter("Agg", 9.0)
|
||||
var aggressive: Dictionary = world.life.life_products(world.state, world.catalog.entities.HP, 1000000.0)
|
||||
check(aggressive.EON1 > ordinary.EON1, "Aggression accelerates primitive evolution")
|
||||
world.state.life_remainders.clear()
|
||||
world.state.world_parameters.Order = 10.0
|
||||
var orderly: Dictionary = world._life_products(world.state, world.entities.HP, 1000000.0)
|
||||
var orderly: Dictionary = world.life.life_products(world.state, world.catalog.entities.HP, 1000000.0)
|
||||
check(orderly.RP < aggressive.RP, "Order reduces degradation")
|
||||
world.state.life_remainders.clear()
|
||||
world.state.world_parameters.Enlightenment = 10.0
|
||||
var enlightened: Dictionary = world._life_products(world.state, world.entities.HP, 1000000.0)
|
||||
var enlightened: Dictionary = world.life.life_products(world.state, world.catalog.entities.HP, 1000000.0)
|
||||
check(enlightened.EON1 > orderly.EON1, "Enlightenment increases primitive progress")
|
||||
dispose(world)
|
||||
|
||||
@@ -77,8 +79,8 @@ func run() -> void:
|
||||
var hotter = fixture()
|
||||
for simulation in [world, hotter]:
|
||||
simulation.state.amount.RD = 1000000.0
|
||||
simulation._append_batch(simulation.state, "RD", 1000000.0, 0.0, 0.0)
|
||||
hotter.modify_world_parameter("Bur", 9.0)
|
||||
simulation.batches.append_batch(simulation.state, "RD", 1000000.0, 0.0, 0.0)
|
||||
hotter.environment.modify_world_parameter("Bur", 9.0)
|
||||
world.evolute(1000.0)
|
||||
hotter.evolute(1000.0)
|
||||
check(hotter.state.amount.S > world.state.amount.S, "Burnability changes actual space production")
|
||||
@@ -96,8 +98,8 @@ func run() -> void:
|
||||
var outcomes: Array = []
|
||||
for target in [baseline, advanced]:
|
||||
var expired: Dictionary = {"C0.2": [{"amount": 1000000.0, "from": 0.0, "to": 1.0}]}
|
||||
var budget: Dictionary = world.CivilizationState.stellar_budget(world, target, global.CivilizationRules)
|
||||
world.CivilizationEvolution.prepare(world, target, expired, 1.0, budget, global.CivilizationRules)
|
||||
var budget: Dictionary = CivilizationState.stellar_budget(world, target, global.CivilizationRules)
|
||||
CivilizationEvolution.prepare(world, target, expired, 1.0, budget, global.CivilizationRules)
|
||||
outcomes.append(expired["C0.2"][0].products.get(next_stage, 0.0))
|
||||
check(outcomes[1] > outcomes[0], "Aggression changes actual ethical civilization transitions")
|
||||
dispose(world)
|
||||
|
||||
Reference in New Issue
Block a user