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