code wiki / _hdl_build / nx_wire_nethack_gate.nx

nx_wire_nethack_gate.nx

buildroot/runtime/_hdl_build/nx_wire_nethack_gate.nx

37130 B917 linesdepth 5pulls 11 transitivereach 0 importersview sourcekind gate/prooftopic wire
docsdependenciesstructsconstsfunctions

about

nx_wire_nethack_gate.nx -- TITLE WIRING #1: NetHack (roguelike), the first nx_gamebench title wired through the certified parts. Until now every gamebench readiness number was SELF-GRADED (titles_wired=0): the parts exist, but nothing proved they COMPOSE into this title's genre loop. This gate is that proof -- an actual playable roguelike loop (procgen dungeon -> descend -> fight -> loot rations -> level up -> save/resume) built ONLY from certified parts, with every exercised capability measured by a tooth. CAPS EXERCISED (bit = nx_gamebench capability index, set ONLY if its tooth passes; the mask is written into the wiring artifact payload[0] so the board's declared mask can be cross-checked by nx_gamebench_gate): bit 3 procgen-world (deterministic carved dungeon, seed-diverse, stairs reachable) bit 7 pathfinding-ai (nx_pathfind pf_astar drives the player every move turn) bit 6 entity-component-sim (nx_entity_store holds monsters; stale handle of a killed monster refused) bit 9 rpg-stats-progression(nx_rpgstats XP curve/level inverse/derived HP drive combat + level-ups) bit 11 inventory-crafting (rations picked up, 2 rations CRAFT a feast, ledger conserves exactly) bit 15 save-load-persistence(nx_gamesave mid-run save -> load into ZEROED state -> resume TRANSPARENT) bit 18 ui-menus-hud (nx_gamehud: the eat decision goes THROUGH a modal menu -- open/wrap/select CAUSES the eat, it is not painted after the fact; HUD slots bind live hp/lvl/depth/kills/food per turn, render-chain deterministic across runs) NOT exercised (title requires, this loop does not prove -> the board must down-score them for NetHack): bit 14 text-render-typography (the HUD blits glyphs, but typography = layout/wrap/paragraphs; honest no-claim). FLAGSHIP PROPERTY (mutation target): save/load TRANSPARENCY -- play N..M continuously vs play N, save, load into a zeroed world, resume to M: EVERY per-turn checksum identical (the GX-9 test most engines cannot run; it catches the whole "the save forgot a field" class). Non-vacuity guard: the resumed world must be non-trivial (live monsters, xp earned, items picked) or the equality proves nothing. license_tier: ORIGINAL expect_exit: 0

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_gamesave.nx nx_rpgstats.nx nx_entity_store.nx nx_pathfind.nx nx_gamehud.nx nx_wire_harness.nx nx_wire_nethack_gate.nx

imports: nx_syscalls.nxnx_gamesave.nxnx_rpgstats.nxnx_entity_store.nxnx_pathfind.nxnx_gamehud.nxnx_wire_harness.nx

imported by: nobody (leaf or entry point)

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

main ww sys_write sys_mmap nh_new rs_level_for_xp rs_xp_for_level rs_smul rs_sadd rs_clamp rs_derived_hp rs_sadd ↻ rs_smul ↻ rs_clamp ↻ nh_genstruct nrng nh_populate en_init en_o_gen en_o_alive en_cap en_o_dense en_cap ↻ en_o_pos en_cap ↻ en_o_free en_cap ↻ nrng ↻ en_count en_nth en_o_dense ↻ en_make_handle en_o_gen ↻ en_get en_valid en_handle_idx en_cap ↻ en_o_alive ↻ en_o_gen ↻ en_handle_gen

structs

none

consts

35const NH_W: i64 = 24
36const NH_H: i64 = 12
37const NH_DEPTH: i64 = 3
38const NH_NMON: i64 = 6
39const NH_NITEM: i64 = 5
40const NH_CAP: i64 = 16 // entity arena capacity
41const NH_NCOMP: i64 = 4 // components: 0=x 1=y 2=hp 3=xp_reward
42const NH_CARVE: i64 = 140 // carve steps per level
43const NH_AGGRO: i64 = 8 // monster chase radius (manhattan)
44const NH_MAXT: i64 = 600
46const NH_XB: i64 = 20 // xp curve base
47const NH_XQ: i64 = 10 // xp curve quad
48const NH_HPB: i64 = 10
49const NH_HPC: i64 = 2
50const NH_HPL: i64 = 3
51const NH_CON: i64 = 14
52const NH_BITE: i64 = 2
53const NH_MHPB: i64 = 12 // monster base hp (tanky enough that the save point sees a LIVE world)
54const NH_HEAL_R: i64 = 10 // ration heal
55const NH_HEAL_F: i64 = 25 // feast heal (crafted from 2 rations -> crafting is worth it)
57const NH_HDRN: i64 = 26 // game header fields serialized
58const NH_NSV: i64 = 106 // 26 hdr + 1 nmon + 16*4 monsters + 5*3 items
59const NH_SCHEMA: i64 = 7307
60const NH_ART_SCHEMA: i64 = 7317 // the wiring-evidence artifact schema
62const NH_T1W: i64 = 20
63const NH_T2W: i64 = 45
65const NG_O_GRID: i64 = 32
66const NG_O_ITEM: i64 = 320
67const NG_O_ENT: i64 = 336 // en_words(16,4) = 156, padded to 160
68const NG_O_PATH: i64 = 496
69const NG_O_G: i64 = 792
70const NG_O_F: i64 = 1088
71const NG_O_CAME: i64 = 1384
72const NG_O_OPENF: i64 = 1680
73const NG_O_CLOSED: i64 = 1976
74const NG_O_CARVE: i64 = 2272
75const NG_O_HUD: i64 = 2576 // nx_gamehud arena (GH_WORDS=64) APPENDED -- UI state rides the game
79const NG_WORDS: i64 = 2640
80const NH_HUDINK: i64 = 50 // min ink px for a non-vacuous HUD frame (T10 guard)
82const F_WS: i64 = 0
83const F_DEPTH: i64 = 1
84const F_TURN: i64 = 2
85const F_PX: i64 = 3
86const F_PY: i64 = 4
87const F_XP: i64 = 5
88const F_LVL: i64 = 6
89const F_HP: i64 = 7
90const F_KILLS: i64 = 8
91const F_RATION: i64 = 9
92const F_FEAST: i64 = 10
93const F_PICKED: i64 = 11
94const F_USED: i64 = 12
95const F_WIN: i64 = 13
96const F_COMB: i64 = 14
97const F_EATR: i64 = 15
98const F_EATF: i64 = 16
99const F_PSTEPS: i64 = 17
100const F_ATT: i64 = 18
101const F_BITES: i64 = 19
102const F_SPAWNED: i64 = 20
103const F_SX: i64 = 21
104const F_SY: i64 = 22
105const F_NCARVE: i64 = 23
106const F_GENRNG: i64 = 24
107const F_ABAND: i64 = 25 // monsters left alive on a level when the player descended

functions

109func ww(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
110func wn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
119func nbit(i: i64) -> i64 { var v: i64=1; var k: i64=0; while k<i { v=v*2; k=k+1 } return v }
called by 1: main
120func nrng(g: *i64) -> i64
129func nabs(v: i64) -> i64 { if v<0 { return 0-v } return v }
called by 2: nh_tickmain
132func nh_genstruct(g: *i64) -> i64
called by 3: nh_newnh_restorenh_tick calls 1: nrng
165func nh_populate(g: *i64) -> i64
238func nh_new(g: *i64, ws: i64) -> i64
254func nh_serialize(g: *i64, S: *i64) -> i64
called by 1: main calls 3: en_counten_nthen_get
283func nh_restore(g: *i64, S: *i64) -> i64
314func nh_ckv(ck: i64, v0: i64) -> i64
called by 1: nh_ck
323func nh_ck(g: *i64) -> i64
called by 1: main calls 4: nh_ckven_counten_nthen_get
347func nh_moncell(a: *i64, x: i64, y: i64, skip: i64) -> i64
called by 1: nh_tick calls 3: en_counten_nthen_get
361func nh_tick(g: *i64) -> i64
545func nh_hudchain(seed: i64, turns: i64, out: *i64) -> i64
586func nh_run_full(g: *i64) -> i64
called by 1: main calls 1: nh_tick
601func main() -> i64