code wiki / (root) / nx_caplab_market.nx

nx_caplab_market.nx

buildroot/runtime/nx_caplab_market.nx

2658 B67 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic caplab
docsdependenciesstructsconstsfunctions

about

nx_caplab_market.nx -- Capitalism Lab R0: the single-firm market atom. The economic "atom" of the capitalism sim: ONE firm sells ONE product into ONE market. Demand falls linearly with price; profit per unit is (price - unit_cost). Everything above this rung -- multi-firm competition, supply chains, the tick loop, multiplayer -- composes from this one tick. All integer math (currency + quantity in whole units) so the gate is bit-exact and reproducible; fixed-point elasticity is a later rung, not an R0 dependency. MODEL: demand(p) = max(0, a - b*p) a = max units demanded at price 0 b = units lost per unit of price revenue(p) = p * demand(p) profit(p) = (p - unit_cost) * demand(p) optimal = argmax_p profit(p) (monopoly price; deterministic scan) nx_safety_envelope: intended_use: capitalism-lab economic core (pure functions, no I/O) sil_target: SIL1 verdict: NOT_YET_EVALUATED genealogy_id: capitalism_lab_market_canon lineage_id: nx_caplab_market_v1

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_tier.nx nx_caplab_market.nx nx_caplab_market_test.nx nx_caplab_supply_test.nx nx_econsim_page.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_caplab_market_test.nxnx_caplab_supply_test.nxnx_econsim_page.nx

structs

none

consts

none

functions

30func nx_clab_demand(a: nx_int, b: nx_int, price: nx_int) -> nx_int
36func nx_clab_revenue(a: nx_int, b: nx_int, price: nx_int) -> nx_int
called by 2: mainmain calls 1: nx_clab_demand
40func nx_clab_cost(a: nx_int, b: nx_int, price: nx_int, unit_cost: nx_int) -> nx_int
calls 1: nx_clab_demand
46func nx_clab_profit(a: nx_int, b: nx_int, price: nx_int, unit_cost: nx_int) -> nx_int
54func nx_clab_optimal_price(a: nx_int, b: nx_int, unit_cost: nx_int) -> nx_int