Update export presets, project version, and enhance civilization simulation rules

- Updated export path and version code in export_presets.cfg
- Changed project version in project.godot to 0.7.0
- Expanded simulation rules in simulation_rules.md to clarify resource management
- Improved testing framework in tests/README.md to include new civilization budget checks
- Added new tests for batch boundaries and civilization state transitions
- Enhanced civilization_state.gd with shared budget and transition logic
- Refactored owniverse.gd to enforce capacity during life batch initialization
This commit is contained in:
Kirill
2026-09-16 07:58:19 +03:00
parent 5f3875bc14
commit 5ea65a7e9b
9 changed files with 250 additions and 8 deletions
+2
View File
@@ -60,3 +60,5 @@ godot --headless --path Owniverse.GI --script res://tests/test_life.gd
```sh
godot --headless --path Owniverse.GI --script res://tests/test_civilization_state.gd
```
Тест цивилизаций дополнительно проверяет общий звёздный бюджет, повторное использование резерва при переходе, звёзды в структурах, массовый эквивалент SMBH, блокировку неподдержанного прогресса, каскад деградации и повторное применение ограничений без потерь.
+57
View File
@@ -0,0 +1,57 @@
extends SceneTree
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:
checks += 1
if not condition:
failures += 1
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])
world.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.state.amount.N = 1.0
return world
func dispose(world) -> void:
for entity in world.entities.values():
entity.free()
world.free()
func run() -> void:
var world = fixture()
world.state.batch_origins.LGRB = 10357034.80000000074505806
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])
var total: float = 0.0
var last: float = -INF
for batch: Dictionary in world.state.batches.LGRB:
total += batch.amount
check(batch.created_from > last, "Batch windows advance monotonically")
check(batch.created_to > batch.created_from, "Positive window duration")
check(batch.amount >= 0.0, "No negative batch amounts")
last = batch.created_from
check(total == 100.0, "Boundary correction preserves all objects")
check(world.state.batches.LGRB.size() <= 7, "Finite number of windows")
dispose(world)
print("Batch boundaries: %d checks, %d failures" % [checks, failures])
quit(0 if failures == 0 else 1)
+1
View File
@@ -0,0 +1 @@
uid://dq86k8bto42xl
+52
View File
@@ -41,6 +41,7 @@ func run() -> void:
check(global.CivilizationRules.size() == 43, "Load all ethical civilization stages")
for row: Dictionary in global.CivilizationRules.values():
check(row.ethics.size() == 6, "Every ethical stage has six rules")
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()
@@ -65,11 +66,62 @@ func run() -> void:
dispose(restored)
dispose(world)
world = fixture()
world.state.amount.RD = 10.0
world.entities["C1.9"].output_and = {"C2.0": 1.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)
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")
world = fixture()
world.state.amount.RD = 10.0
world.state.amount["C2.0"] = 8.0
var budget: Dictionary = capacity.stellar_budget(world, world.state, global.CivilizationRules)
check(capacity.admit_transition(budget, global.CivilizationRules, "C1.9", "C2.0", 5.0) == 2.0, "Growth consumes only remaining stellar capacity")
check(capacity.admit_transition(budget, global.CivilizationRules, "C1.9", "C2.0", 5.0) == 0.0, "A reservation cannot be spent twice")
world.state.amount["C2.0"] = 1.0
budget = capacity.stellar_budget(world, world.state, global.CivilizationRules)
check(capacity.admit_transition(budget, global.CivilizationRules, "C2.0", "C2.1", 1.0) == 1.0, "A transition reuses the source reservation")
check(budget.free.DwStar == 0.0, "C2.1 reserves ten dwarf stars")
world.state.amount["C2.0"] = 0.0
world.state.binds.SC = {"RD": 10.0}
budget = capacity.stellar_budget(world, world.state, global.CivilizationRules)
check(budget.capacity.DwStar == 20.0, "Stars inside structures are counted once")
dispose(world)
world = fixture()
world.state.amount.RD = 12.0
world.state.amount["C2.1"] = 2.0
world.state.amount["C2.0"] = 5.0
world.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()
check(world.state == snapshot, "Capacity enforcement is idempotent")
world.state.amount.RD = 0.0
world.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")
dispose(world)
world = fixture()
world.state.amount.SMBH = 2.0e22
world.state.amount["C4.2"] = 3.0
world.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(root.get_node("SaveManager").validate_data({"state": world.state}) == "", "Capacity-limited state validates")
dispose(world)
world = fixture()
world.state.amount.RD = 2.0
world.entities["C1.9"].output_and = {"C2.0": 1.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)
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])
quit(0 if failures == 0 else 1)