code wiki / _hdl_build / nx_creature_world_gate.nx

nx_creature_world_gate.nx source

↩ module page · 89 lines · 6295 B

1// nx_creature_world_gate.nx -- RUNS the integrated creature-collector loop and asserts each piece is REAL, then 2// prints the actual run transcript. Proves: the catch formula is HP-DEPENDENT (weakened catches >> full-HP 3// catches -- weakening matters, not auto-success); the overworld loop RUNS (encounters happen on grass); 4// capture INTEGRATES (a caught wild enters the party); a NEG-CONTROL (a grass-less route -> 0 encounters, no 5// fabricated catches); SAVE/LOAD round-trips the party (real persistence); DETERMINISTIC + sovereign. 6// HONEST: headless logic spine -- no visuals/UI/real-time/netcode. license_tier: ORIGINAL expect_exit: 0 7import "nx_creature_world.nx" 8import "nx_creature_battle.nx" 9import "nx_ad_serve.nx" 10import "nx_syscalls.nx" 11import "nx_gate_verdict.nx" 12 13func g_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 14func g_i(v: i64) -> i64 { let t: *u8 = sys_mmap(24); var m: i64 = v; var k: i64 = 0; if m == 0 { t[0]=48 as u8; k=1 } while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let o: *u8=sys_mmap(24); var w: i64=0; var q: i64=k-1; while q>=0 { o[w]=t[q]; w=w+1; q=q-1 } sys_write(1,o,w); return 0 } 15func eqb(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } 16func mk_ember(c: *i64) -> i64 { cb_set(c, 1, 25, 90, 65, 50, 70, "Embercat" as *u8); cb_addmove(c, 1, 40, 100); cb_addmove(c, 0, 60, 100); return 0 } 17 18func main(argc: i64, argv: *i64) -> i64 { 19 g_p("=== nx_creature_world_gate (REAL integrated loop: overworld->encounter->weaken->CAPTURE->party->save) ===\n" as *u8) 20 let lead: *i64 = sys_mmap(8*24) as *i64; mk_ember(lead) 21 var pass: i64 = 0; var tot: i64 = 0 22 23 // T1 catch formula is HP-DEPENDENT (real): full HP vs 10% HP over 256 throws each 24 let wild: *i64 = sys_mmap(8*24) as *i64; cw_spawn(wild, 0) 25 let s: *i64 = sys_mmap(16) as *i64; s[0] = 1234 26 var fullC: i64 = 0; var i: i64 = 0 27 wild[3] = wild[2] 28 while i < 256 { if cw_try_catch(wild, 1, s) == 1 { fullC = fullC + 1 } i = i + 1 } 29 var lowC: i64 = 0; i = 0 30 wild[3] = wild[2] / 10 31 while i < 256 { if cw_try_catch(wild, 1, s) == 1 { lowC = lowC + 1 } i = i + 1 } 32 tot = tot + 1 33 if lowC > fullC { pass = pass + 1; g_p("PASS T1 catch is HP-dependent: weakened catches=" as *u8); g_i(lowC); g_p("/256 >> full-HP catches=" as *u8); g_i(fullC); g_p("/256 (weakening matters -- real)\n" as *u8) } else { g_p("FAIL T1 low=" as *u8); g_i(lowC); g_p(" full=" as *u8); g_i(fullC); g_p("\n" as *u8) } 34 35 // build a route with grass tiles 36 let route: *u8 = sys_mmap(12); i = 0; while i < 12 { route[i] = 0 as u8; i = i + 1 } 37 route[2] = 1 as u8; route[4] = 1 as u8; route[5] = 1 as u8; route[8] = 1 as u8; route[10] = 1 as u8 38 39 // T2 + T3: the loop RUNS and capture integrates into the party 40 let party: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64 41 let pcb: *i64 = sys_mmap(16) as *i64; pcb[0] = 0 42 let buf: *u8 = sys_mmap(8192) 43 let enc: i64 = cw_explore(route, 12, lead, party, pcb, 77, buf) 44 g_p(buf) 45 tot = tot + 1 46 if enc >= 1 { pass = pass + 1; g_p("PASS T2 overworld loop RAN: " as *u8); g_i(enc); g_p(" wild encounter(s) on grass tiles\n" as *u8) } else { g_p("FAIL T2 enc=0\n" as *u8) } 47 tot = tot + 1 48 if pcb[0] >= 1 { pass = pass + 1; g_p("PASS T3 capture integrates: party grew to " as *u8); g_i(pcb[0]); g_p(" (a caught wild entered the party)\n" as *u8) } else { g_p("FAIL T3 party=" as *u8); g_i(pcb[0]); g_p("\n" as *u8) } 49 50 // T4 NEG-CONTROL: a route with NO grass -> 0 encounters, no fabricated catches 51 let route2: *u8 = sys_mmap(12); i = 0; while i < 12 { route2[i] = 0 as u8; i = i + 1 } 52 let party2: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64 53 let pcb2: *i64 = sys_mmap(16) as *i64; pcb2[0] = 0 54 let buf2: *u8 = sys_mmap(8192) 55 let enc2: i64 = cw_explore(route2, 12, lead, party2, pcb2, 77, buf2) 56 tot = tot + 1 57 if enc2 == 0 { if pcb2[0] == 0 { pass = pass + 1; g_p("PASS T4 neg-control: grass-less route -> 0 encounters, 0 catches (not fabricated)\n" as *u8) } else { g_p("FAIL T4 party grew with no grass\n" as *u8) } } else { g_p("FAIL T4 enc2=" as *u8); g_i(enc2); g_p("\n" as *u8) } 58 59 // T5 SAVE/LOAD round-trip the party (real persistence) 60 sys_mkdir("knowledge/staging/game" as *u8, 0x1ed) 61 cw_save("knowledge/staging/game/party.sav" as *u8, party, pcb[0]) 62 let lparty: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64 63 let lcb: *i64 = sys_mmap(16) as *i64; lcb[0] = 0 64 cw_load("knowledge/staging/game/party.sav" as *u8, lparty, lcb) 65 tot = tot + 1; var ok5: i64 = 1 66 if lcb[0] != pcb[0] { ok5 = 0 } 67 if lcb[0] >= 1 { if lparty[0] != party[0] { ok5 = 0 } if lparty[1] != party[1] { ok5 = 0 } if lparty[2] != party[2] { ok5 = 0 } } else { ok5 = 0 } 68 if ok5 == 1 { pass = pass + 1; g_p("PASS T5 save/load: party persisted + restored (" as *u8); g_i(lcb[0]); g_p(" member(s), type/level/hp match)\n" as *u8) } else { g_p("FAIL T5\n" as *u8) } 69 70 // T6 determinism + sovereignty 71 let pcb3: *i64 = sys_mmap(16) as *i64; pcb3[0] = 0; let party3: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64; let buf3: *u8 = sys_mmap(8192) 72 cw_explore(route, 12, lead, party3, pcb3, 77, buf3) 73 tot = tot + 1; var ok6: i64 = 1 74 if eqb(buf, buf3) != 1 { ok6 = 0 } 75 var bl: i64 = 0; while buf[bl] != (0 as u8) { bl = bl + 1 } 76 if as_has_thirdparty_js(buf, bl) != 0 { ok6 = 0 } 77 if ok6 == 1 { pass = pass + 1; g_p("PASS T6 deterministic (same seed -> identical run) + sovereign (0 third-party)\n" as *u8) } else { g_p("FAIL T6\n" as *u8) } 78 79 g_p("nx_creature_world_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot) 80 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 81 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 82 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 83 let ctr__dry: *i64 = gv_ctr() 84 ctr__dry[0] = pass 85 ctr__dry[1] = tot 86 let rc__dry: i64 = gv_verdict("CREATURE-WORLD-GATE" as *u8, ctr__dry, "a REAL creature-collector loop RUNS end-to-end; honest headless slice, no visuals/UI/MP)" as *u8) 87 sys_exit(rc__dry) 88 return rc__dry 89}