code wiki / _hdl_build / nx_wire_nethack_gate.nx
nx_wire_nethack_gate.nx
buildroot/runtime/_hdl_build/nx_wire_nethack_gate.nx
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
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
structs
| none |
consts
| 35 | const NH_W: i64 = 24 |
| 36 | const NH_H: i64 = 12 |
| 37 | const NH_DEPTH: i64 = 3 |
| 38 | const NH_NMON: i64 = 6 |
| 39 | const NH_NITEM: i64 = 5 |
| 40 | const NH_CAP: i64 = 16 // entity arena capacity |
| 41 | const NH_NCOMP: i64 = 4 // components: 0=x 1=y 2=hp 3=xp_reward |
| 42 | const NH_CARVE: i64 = 140 // carve steps per level |
| 43 | const NH_AGGRO: i64 = 8 // monster chase radius (manhattan) |
| 44 | const NH_MAXT: i64 = 600 |
| 46 | const NH_XB: i64 = 20 // xp curve base |
| 47 | const NH_XQ: i64 = 10 // xp curve quad |
| 48 | const NH_HPB: i64 = 10 |
| 49 | const NH_HPC: i64 = 2 |
| 50 | const NH_HPL: i64 = 3 |
| 51 | const NH_CON: i64 = 14 |
| 52 | const NH_BITE: i64 = 2 |
| 53 | const NH_MHPB: i64 = 12 // monster base hp (tanky enough that the save point sees a LIVE world) |
| 54 | const NH_HEAL_R: i64 = 10 // ration heal |
| 55 | const NH_HEAL_F: i64 = 25 // feast heal (crafted from 2 rations -> crafting is worth it) |
| 57 | const NH_HDRN: i64 = 26 // game header fields serialized |
| 58 | const NH_NSV: i64 = 106 // 26 hdr + 1 nmon + 16*4 monsters + 5*3 items |
| 59 | const NH_SCHEMA: i64 = 7307 |
| 60 | const NH_ART_SCHEMA: i64 = 7317 // the wiring-evidence artifact schema |
| 62 | const NH_T1W: i64 = 20 |
| 63 | const NH_T2W: i64 = 45 |
| 65 | const NG_O_GRID: i64 = 32 |
| 66 | const NG_O_ITEM: i64 = 320 |
| 67 | const NG_O_ENT: i64 = 336 // en_words(16,4) = 156, padded to 160 |
| 68 | const NG_O_PATH: i64 = 496 |
| 69 | const NG_O_G: i64 = 792 |
| 70 | const NG_O_F: i64 = 1088 |
| 71 | const NG_O_CAME: i64 = 1384 |
| 72 | const NG_O_OPENF: i64 = 1680 |
| 73 | const NG_O_CLOSED: i64 = 1976 |
| 74 | const NG_O_CARVE: i64 = 2272 |
| 75 | const NG_O_HUD: i64 = 2576 // nx_gamehud arena (GH_WORDS=64) APPENDED -- UI state rides the game |
| 79 | const NG_WORDS: i64 = 2640 |
| 80 | const NH_HUDINK: i64 = 50 // min ink px for a non-vacuous HUD frame (T10 guard) |
| 82 | const F_WS: i64 = 0 |
| 83 | const F_DEPTH: i64 = 1 |
| 84 | const F_TURN: i64 = 2 |
| 85 | const F_PX: i64 = 3 |
| 86 | const F_PY: i64 = 4 |
| 87 | const F_XP: i64 = 5 |
| 88 | const F_LVL: i64 = 6 |
| 89 | const F_HP: i64 = 7 |
| 90 | const F_KILLS: i64 = 8 |
| 91 | const F_RATION: i64 = 9 |
| 92 | const F_FEAST: i64 = 10 |
| 93 | const F_PICKED: i64 = 11 |
| 94 | const F_USED: i64 = 12 |
| 95 | const F_WIN: i64 = 13 |
| 96 | const F_COMB: i64 = 14 |
| 97 | const F_EATR: i64 = 15 |
| 98 | const F_EATF: i64 = 16 |
| 99 | const F_PSTEPS: i64 = 17 |
| 100 | const F_ATT: i64 = 18 |
| 101 | const F_BITES: i64 = 19 |
| 102 | const F_SPAWNED: i64 = 20 |
| 103 | const F_SX: i64 = 21 |
| 104 | const F_SY: i64 = 22 |
| 105 | const F_NCARVE: i64 = 23 |
| 106 | const F_GENRNG: i64 = 24 |
| 107 | const F_ABAND: i64 = 25 // monsters left alive on a level when the player descended |
functions
| 109 | func ww(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 110 | func wn(v: i64) -> i64 |
| 119 | func 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 |
| 120 | func nrng(g: *i64) -> i64 |
| 129 | func nabs(v: i64) -> i64 { if v<0 { return 0-v } return v } |
| 132 | func nh_genstruct(g: *i64) -> i64 |
| 165 | func nh_populate(g: *i64) -> i64 |
| 238 | func nh_new(g: *i64, ws: i64) -> i64 |
| 254 | func nh_serialize(g: *i64, S: *i64) -> i64 |
| 283 | func nh_restore(g: *i64, S: *i64) -> i64 |
| 314 | func nh_ckv(ck: i64, v0: i64) -> i64 called by 1: nh_ck |
| 323 | func nh_ck(g: *i64) -> i64 |
| 347 | func nh_moncell(a: *i64, x: i64, y: i64, skip: i64) -> i64 |
| 361 | func nh_tick(g: *i64) -> i64 called by 3: nh_hudchainnh_run_fullmain calls 15: en_counten_nthen_getnabsen_destroyrs_level_for_xp+9 |
| 545 | func nh_hudchain(seed: i64, turns: i64, out: *i64) -> i64 |
| 586 | func nh_run_full(g: *i64) -> i64 |
| 601 | func main() -> i64 |