code wiki / (root) / nx_caplab_sim.nx

nx_caplab_sim.nx

buildroot/runtime/nx_caplab_sim.nx

3162 B78 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic caplab
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_tier.nx nx_caplab_compete.nx nx_caplab_sim.nx nx_caplab_sim_test.nx nx_econsim_page.nx

imports: nx_syscalls.nxnx_tier.nxnx_caplab_compete.nx

imported by: nx_caplab_sim_test.nxnx_econsim_page.nx

structs

none

consts

61const NX_CLAB_MODE_ID: nx_int = 100
62const NX_CLAB_CFG_STRIDE: nx_int = 6
63const NX_CLAB_CFG_MODE: nx_int = 0
64const NX_CLAB_CFG_START_CASH: nx_int = 1
65const NX_CLAB_CFG_MARKET_M: nx_int = 2
66const NX_CLAB_CFG_CHOKE: nx_int = 3
67const NX_CLAB_CFG_TICKS: nx_int = 4
68const NX_CLAB_CFG_N_FIRMS: nx_int = 5

functions

26func nx_clab_sim_tick(n: nx_int, prices: *i64, unit_costs: *i64, caps: *i64,
41func nx_clab_sim_run(n: nx_int, prices: *i64, unit_costs: *i64, caps: *i64,
called by 2: mainmain calls 2: sys_mmapnx_clab_sim_tick
53func nx_clab_ai_price(rival_price: nx_int, my_cost: nx_int, delta: nx_int) -> nx_int
called by 1: main
71func nx_clab_mode_init(cfg: *i64)
called by 1: main