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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user