code wiki / (root) / nx_caplab_compete.nx

nx_caplab_compete.nx

buildroot/runtime/nx_caplab_compete.nx

3417 B98 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind librarytopic caplab
docsdependenciesstructsconstsfunctions

about

nx_caplab_compete.nx -- Capitalism Lab R1: multi-firm price competition. Builds on the R0 atom (nx_caplab_market): instead of one firm, N firms set prices into ONE market. A single market willingness-to-pay (choke price A) bounds demand; each firm's "appeal" is how far it undercuts the choke; the market's customers split among firms in proportion to appeal (cheaper -> bigger share). Allocation uses largest-remainder so the split is CONSERVED: sum of firm quantities == total market customers (no customers vanish or get invented), unless every firm is priced out. MODEL: appeal_i = max(0, A - price_i) (0 if priced >= choke) share_i = market_M * appeal_i / sum(appeal) (largest-remainder) profit_i = (price_i - unit_cost_i) * share_i This is the heart of "capitalism": a lower price wins more of the market, but margin x volume decides who actually earns the most. nx_safety_envelope: intended_use: capitalism-lab competition core (pure functions, no I/O) sil_target: SIL1 verdict: NOT_YET_EVALUATED genealogy_id: capitalism_lab_competition_canon lineage_id: nx_caplab_compete_v1

dependencies 2 imports · 3 importers

nx_syscalls.nx nx_tier.nx nx_caplab_compete.nx nx_caplab_compete_test.nx nx_caplab_sim.nx nx_econsim_page.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_caplab_compete_test.nxnx_caplab_sim.nxnx_econsim_page.nx

structs

none

consts

none

functions

31func nx_clab_appeal(choke_a: nx_int, price: nx_int) -> nx_int
37func nx_clab_appeal_sum(n: nx_int, prices: *i64, choke_a: nx_int) -> nx_int
called by 1: nx_clab_split calls 1: nx_clab_appeal
51func nx_clab_split(n: nx_int, prices: *i64, choke_a: nx_int,
96func nx_clab_firm_profit(price: nx_int, unit_cost: nx_int, qty: nx_int) -> nx_int
called by 2: mainmain