code wiki / _hdl_build / nx_game_gen2.nx

nx_game_gen2.nx

buildroot/runtime/_hdl_build/nx_game_gen2.nx

13323 B297 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic game
docsdependenciesstructsconstsfunctions

about

nx_game_gen2.nx -- the POLYMORPHIC game-system generator (X-GAME-GEN-001: "generate-a-game: game systems as emitter SHAPES -> GAME SPEC -> Builder emits the game"). Generalizes nx_game_gen (which hard-codes the dungenc table, dungeon-only) to ALL SIX proven game-system FSM types by SOURCING each type's transition table from its build_<type>.spec -- the same DATA the hand-authored _pe_<type> FSM (shape 18 STATE_MACHINE) was gated on. So the emitted game's FSM is, by construction, the PROVEN one (DRY: the table is never duplicated here). CLI: nx_game_gen2 <name> <THEME> <type> [difficulty] type = dungenc | twrwave | abround | stealth | datesim | fightfsm writes knowledge/specs/<name>.spec (name/title/economy + fsm+rows from build_<type>.spec) SELF-GATE (run with no args, the way nx_sov_build_run invokes it): generate all 6 types to scratch, re-parse each emitted game-spec, assert its FSM == the source build_<type>.spec FSM, assert the 6 tables are DISTINCT (polymorphic, not all-dungenc), and assert an UNKNOWN type is REFUSED. GAMEGEN2-GATE verdict=GREEN iff all sourced-ok + distinct>=2 + neg refused. HONEST SCOPE: the economy shell (walls/foes/hp, difficulty-scaled -- the deterministic tier table) is the dungeon default; the FSM (the game SYSTEM) is the polymorphic shape. Per-type economy templates are a refinement. Sovereign syscalls only. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_game_gen2.nx

imports: nx_syscalls.nxnx_itoa_lib.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 gg_build_fsm sys_mmap ↻ gg_cat gg_read sys_openat_rd sys_read sys_close gg_extract_fsm sys_mmap ↻ gg_line_ints gg_w sys_write sys_exit gg_cat ↻ sys_openat_wr gg_emit_spec gg_w ↻ gg_c sys_mmap ↻ sys_write ↻ gg_kv gg_w ↻ gg_c ↻ gg_wn nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap gg_wn ↻ gg_tier gg_streq sys_close ↻ gg_c ↻ gg_read ↻ gg_extract_fsm ↻ gg_fsm_eq gg_fsm_sig

structs

none

consts

21const K_MAGIC_65536: i64 = 65536
22const K_MAGIC_2048: i64 = 2048

functions

24func gg_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
25func gg_c(fd: i64, c: i64) -> i64 { let b: *u8 = sys_mmap(8); b[0] = c as u8; sys_write(fd, b, 1); return 0 }
30func gg_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
31func gg_streq(a: *u8, b: *u8) -> i64
called by 1: gg_tier
37func gg_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 2: gg_build_fsmmain
39func gg_read(path: *u8, buf: *u8, cap: i64) -> i64
50func gg_line_ints(buf: *u8, ls: i64, le: i64, tmp: *i64) -> i64
called by 1: gg_extract_fsm
78func gg_extract_fsm(buf: *u8, n: i64, key: i64, out: *i64) -> i64
128func gg_build_fsm(typ: *u8, out: *i64) -> i64
139func gg_tier(d: *u8) -> i64
called by 1: main calls 1: gg_streq
147func gg_kv(fd: i64, key: *u8, v: i64) -> i64 { gg_w(fd, key); gg_c(fd, 32); gg_wn(fd, v); gg_c(fd, 10); return 0 }
called by 1: gg_emit_spec calls 3: gg_wgg_cgg_wn
150func gg_emit_spec(fd: i64, name: *u8, theme: *u8, typ: *u8, tier: i64, ftab: *i64) -> i64
called by 1: main calls 4: gg_wgg_cgg_kvgg_wn
185func gg_fsm_eq(a: *i64, b: *i64) -> i64
called by 1: main
194func gg_fsm_sig(a: *i64) -> i64
called by 1: main
202func gg_gate_report(fd: i64, navail: i64, sourced: i64, distinct: i64, neg: i64, ok: i64) -> i64
called by 1: main calls 2: gg_wgg_wn
211func main(argc: i64, argv: *i64) -> i64