code wiki / _hdl_build / nx_coc_engine.nx

nx_coc_engine.nx

buildroot/runtime/_hdl_build/nx_coc_engine.nx

11276 B231 linesdepth 4pulls 8 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_coc_engine.nx -- M1 MILESTONE: a Corruption-of-Champions-class TEXT-RPG ENGINE emitted by COMPOSING certified parts. This is the recombinator claim made concrete for the adult-emitter program: a playable branching text RPG with stats, transformation, adult-gated wardrobe, and persistence -- ZERO new game logic, only composition of parts each certified-to-exceed ONCE (game_parts.tsv doctrine). PLOT nx_plotgen (pg_gen) -- generates a SOLVABLE branching narrative graph EXECUTION nx_story_vm (sv_choose) -- runs the graph as a data-driven state machine STATS nx_rpgstats (rs_*) -- XP curve, level, saturating HP, skill BODY nx_wardrobe_state (ws_*) -- clothing/exposure/TRANSFORMATION, ADULT-GATED by construction SAVE nx_gamesave (gs_save) -- atomic bit-exact persistence SELF-PROVING (self-gating like nx_frontier_engine): P1 winnable, P2 LOSABLE (a CoC-class game MUST be losable or it is hollow), P3 deterministic, P4 save/load transparent, P5 ADULT-GATE HOLDS THROUGH THE WHOLE LOOP (a minor can never reach an exposed wardrobe state, and an ADULT on the same seed DOES -- the gate is real AND targeted), P6 solvable (the generated plot has a reachable ending). HONEST SCOPE: this is the ENGINE (state machine + stats + transformation + adult-gating + persistence). Narrative PROSE slots into the story-graph nodes as a later LLM-authored rung (nx_story_vm's design). Emits a JSON proof line so agents/workflows can emit-and-prove an M1 game on demand (MCP tool). license_tier: ORIGINAL expect_exit: 0

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_gamesave.nx nx_rpgstats.nx nx_story_vm.nx nx_plotgen.nx nx_wardrobe_state.nx nx_coc_engine.nx

imports: nx_syscalls.nxnx_gamesave.nxnx_rpgstats.nxnx_story_vm.nxnx_plotgen.nxnx_wardrobe_state.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap ce_run sys_mmap ↻ pg_gen sys_mmap ↻ pg_bit pg_rng ws_init sv_is_end ce_hash rs_sadd rs_level_for_xp rs_xp_for_level rs_smul rs_sadd ↻ rs_clamp ws_morph ws_set ws_is_gated_zone rs_clamp ↻ sv_choose ws_exposure gs_save sys_mmap ↻ put64 gsc_put64 gs_cksum gsc_fold_bytes joinsuf slen sys_mmap ↻ sys_openat_wr sys_write sys_fsync sys_close sys_unlinkat gs_exists sys_openat_rd sys_close ↻

structs

none

consts

27const CE_MAGIC_20260724: i64 = 20260724
28const CE_MAGIC_424242: i64 = 424242
29const CE_MAGIC_4096: i64 = 4096
31const CE_NODES: i64 = 12
32const CE_LEN: i64 = 16 // save vector: [0]node [1]flags [2]hp [3]xp [4]level [5]cycle [6..15]wardrobe(10)
33const CE_MAXHP: i64 = 100
34const CE_TARGET: i64 = 3 // win requires level >= this
35const CE_HAZ_PCT: i64 = 45 // chance a node is a hazard
36const CE_HEAL: i64 = 8 // cautious recovers between nodes
37const CE_TOLL: i64 = 22 // reckless pays a detour toll in HP
38const CE_XPBASE: i64 = 100
39const CE_XPQUAD: i64 = 20
40const CE_M63: i64 = 0x7FFFFFFFFFFFFFFF
41const CE_FNV: i64 = 1099511628211
42const CE_MIXA: i64 = 2654435761
43const CE_MIXB: i64 = 1274126177

functions

45func ce_hash(node: i64, seed: i64) -> i64
called by 1: ce_run
54func ce_run(V: *i64, res: *i64, seed: i64, policy: i64, age: i64) -> i64
126func jc(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a }
called by 1: main
127func jn(o: *u8, at: i64, v: i64) -> i64
called by 1: main calls 1: sys_mmap
138func main() -> i64