nx_caplab_sim.nx
buildroot/runtime/nx_caplab_sim.nx
about
nx_caplab_sim.nx -- Capitalism Lab R3: the simulation TICK LOOP (it becomes a
game, not a calculator). N firms compete over many turns: each tick the
market allocates demand by price (R1 share), each firm sells up to its
production capacity, and cash accumulates. Includes an AI competitor price
strategy and the CAPITALISM_LAB game config (the gmod/registry pattern).
Deterministic by construction (pure integer, no RNG) -> replay-identical.
MODEL (per tick):
demand[i] = R1 appeal-share split of market_m by price
sold[i] = min(demand[i], capacity[i]) (capacity caps sales)
cash[i] += (price[i] - unit_cost[i]) * sold[i]
nx_safety_envelope:
intended_use: capitalism-lab simulation core (pure functions, no I/O)
sil_target: SIL1
verdict: NOT_YET_EVALUATED
genealogy_id: capitalism_lab_simulation_canon
lineage_id: nx_caplab_sim_v1
dependencies 3 imports · 2 importers
imports: nx_syscalls.nxnx_tier.nxnx_caplab_compete.nx
imported by: nx_caplab_sim_test.nxnx_econsim_page.nx
structs
| none |
consts
| 61 | const NX_CLAB_MODE_ID: nx_int = 100 |
| 62 | const NX_CLAB_CFG_STRIDE: nx_int = 6 |
| 63 | const NX_CLAB_CFG_MODE: nx_int = 0 |
| 64 | const NX_CLAB_CFG_START_CASH: nx_int = 1 |
| 65 | const NX_CLAB_CFG_MARKET_M: nx_int = 2 |
| 66 | const NX_CLAB_CFG_CHOKE: nx_int = 3 |
| 67 | const NX_CLAB_CFG_TICKS: nx_int = 4 |
| 68 | const NX_CLAB_CFG_N_FIRMS: nx_int = 5 |
functions
| 26 | func nx_clab_sim_tick(n: nx_int, prices: *i64, unit_costs: *i64, caps: *i64, |
| 41 | func nx_clab_sim_run(n: nx_int, prices: *i64, unit_costs: *i64, caps: *i64, |
| 53 | func nx_clab_ai_price(rival_price: nx_int, my_cost: nx_int, delta: nx_int) -> nx_int called by 1: main |
| 71 | func nx_clab_mode_init(cfg: *i64) called by 1: main |