-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfull_stack.py
More file actions
81 lines (63 loc) Β· 2.37 KB
/
Copy pathfull_stack.py
File metadata and controls
81 lines (63 loc) Β· 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""Wire the full Earth-realism stack on a Simulation (post-construct).
Used by ``run.py`` presets ``realism`` / ``terre`` and
``civilization_pipeline.py``.
"""
from __future__ import annotations
import os
from typing import Any, Dict, Optional
from engine.world_genesis import GenesisParams
def wire_full_stack(
sim,
*,
genesis: bool = True,
rust_worldgraph: bool = True,
mp_api: bool = True,
five_cd: bool = True,
macro_commerce: bool = True,
genesis_resolution: int = 64,
) -> Dict[str, Any]:
"""Idempotent post-``Simulation()`` wiring. Returns status dict."""
out: Dict[str, Any] = {
"genesis_bootstrapped": False,
"rust_worldgraph": False,
"macro_commerce": False,
"mp_api_records": 0,
"five_cd": False,
}
if genesis:
existing = getattr(sim, "_genesis_bootstrap_state", None)
if existing is None:
from engine.genesis_bootstrap import bootstrap_genesis_sim
seed = int(sim.cfg.seed) & 0xFFFFFFFFFFFFFFFF
gp = GenesisParams(
seed=seed,
resolution=genesis_resolution,
n_plates=8,
erosion_iters=12,
rain_iters=3,
)
bootstrap_genesis_sim(sim, seed=seed, genesis_params=gp)
out["genesis_bootstrapped"] = True
if rust_worldgraph:
from engine.rust_worldgraph_tick import install_rust_worldgraph
prod = bool(getattr(sim.cfg, "rust_worldgraph_prod", False))
install_rust_worldgraph(sim, prod_mode=prod)
out["rust_worldgraph"] = True
out["rust_worldgraph_prod"] = prod
if macro_commerce and getattr(sim.cfg, "macro_commerce", False):
from engine.commerce_emergence import install_commerce_emergence
install_commerce_emergence(sim)
out["macro_commerce"] = True
if mp_api and getattr(sim, "_materials_project", None) is not None:
from engine.materials_project import try_fetch_mp_bootstrap
out["mp_api_records"] = try_fetch_mp_bootstrap(sim)
if five_cd and not getattr(sim, "_5cd_installed", False):
try:
from engine.sim_5cd_integration import install
install(sim)
sim._5cd_installed = True
out["five_cd"] = True
except Exception:
out["five_cd"] = False
return out
__all__ = ["wire_full_stack"]