code wiki / _hdl_build / nx_game_gen2.nx
nx_game_gen2.nx
buildroot/runtime/_hdl_build/nx_game_gen2.nx
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
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
structs
| none |
consts
| 21 | const K_MAGIC_65536: i64 = 65536 |
| 22 | const K_MAGIC_2048: i64 = 2048 |
functions
| 24 | func 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 } |
| 25 | func 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 } |
| 30 | func gg_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 31 | func gg_streq(a: *u8, b: *u8) -> i64 called by 1: gg_tier |
| 37 | func 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 } |
| 39 | func gg_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 50 | func gg_line_ints(buf: *u8, ls: i64, le: i64, tmp: *i64) -> i64 called by 1: gg_extract_fsm |
| 78 | func gg_extract_fsm(buf: *u8, n: i64, key: i64, out: *i64) -> i64 |
| 128 | func gg_build_fsm(typ: *u8, out: *i64) -> i64 |
| 139 | func gg_tier(d: *u8) -> i64 |
| 147 | func 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 } |
| 150 | func gg_emit_spec(fd: i64, name: *u8, theme: *u8, typ: *u8, tier: i64, ftab: *i64) -> i64 |
| 185 | func gg_fsm_eq(a: *i64, b: *i64) -> i64 called by 1: main |
| 194 | func gg_fsm_sig(a: *i64) -> i64 called by 1: main |
| 202 | func gg_gate_report(fd: i64, navail: i64, sourced: i64, distinct: i64, neg: i64, ok: i64) -> i64 |
| 211 | func main(argc: i64, argv: *i64) -> i64 |