code wiki / _hdl_build / nx_creature_world_gate.nx
nx_creature_world_gate.nx source
↩ module page · 81 lines · 5915 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"
11
12func 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 }
13func 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 }
14func 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 }
15func 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 }
16
17func main(argc: i64, argv: *i64) -> i64 {
18 g_p("=== nx_creature_world_gate (REAL integrated loop: overworld->encounter->weaken->CAPTURE->party->save) ===\n" as *u8)
19 let lead: *i64 = sys_mmap(8*24) as *i64; mk_ember(lead)
20 var pass: i64 = 0; var tot: i64 = 0
21
22 // T1 catch formula is HP-DEPENDENT (real): full HP vs 10% HP over 256 throws each
23 let wild: *i64 = sys_mmap(8*24) as *i64; cw_spawn(wild, 0)
24 let s: *i64 = sys_mmap(16) as *i64; s[0] = 1234
25 var fullC: i64 = 0; var i: i64 = 0
26 wild[3] = wild[2]
27 while i < 256 { if cw_try_catch(wild, 1, s) == 1 { fullC = fullC + 1 } i = i + 1 }
28 var lowC: i64 = 0; i = 0
29 wild[3] = wild[2] / 10
30 while i < 256 { if cw_try_catch(wild, 1, s) == 1 { lowC = lowC + 1 } i = i + 1 }
31 tot = tot + 1
32 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) }
33
34 // build a route with grass tiles
35 let route: *u8 = sys_mmap(12); i = 0; while i < 12 { route[i] = 0 as u8; i = i + 1 }
36 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
37
38 // T2 + T3: the loop RUNS and capture integrates into the party
39 let party: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64
40 let pcb: *i64 = sys_mmap(16) as *i64; pcb[0] = 0
41 let buf: *u8 = sys_mmap(8192)
42 let enc: i64 = cw_explore(route, 12, lead, party, pcb, 77, buf)
43 g_p(buf)
44 tot = tot + 1
45 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) }
46 tot = tot + 1
47 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) }
48
49 // T4 NEG-CONTROL: a route with NO grass -> 0 encounters, no fabricated catches
50 let route2: *u8 = sys_mmap(12); i = 0; while i < 12 { route2[i] = 0 as u8; i = i + 1 }
51 let party2: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64
52 let pcb2: *i64 = sys_mmap(16) as *i64; pcb2[0] = 0
53 let buf2: *u8 = sys_mmap(8192)
54 let enc2: i64 = cw_explore(route2, 12, lead, party2, pcb2, 77, buf2)
55 tot = tot + 1
56 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) }
57
58 // T5 SAVE/LOAD round-trip the party (real persistence)
59 sys_mkdir("knowledge/staging/game" as *u8, 0x1ed)
60 cw_save("knowledge/staging/game/party.sav" as *u8, party, pcb[0])
61 let lparty: *i64 = sys_mmap(8*24*PARTY_MAX) as *i64
62 let lcb: *i64 = sys_mmap(16) as *i64; lcb[0] = 0
63 cw_load("knowledge/staging/game/party.sav" as *u8, lparty, lcb)
64 tot = tot + 1; var ok5: i64 = 1
65 if lcb[0] != pcb[0] { ok5 = 0 }
66 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 }
67 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) }
68
69 // T6 determinism + sovereignty
70 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)
71 cw_explore(route, 12, lead, party3, pcb3, 77, buf3)
72 tot = tot + 1; var ok6: i64 = 1
73 if eqb(buf, buf3) != 1 { ok6 = 0 }
74 var bl: i64 = 0; while buf[bl] != (0 as u8) { bl = bl + 1 }
75 if as_has_thirdparty_js(buf, bl) != 0 { ok6 = 0 }
76 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) }
77
78 g_p("nx_creature_world_gate pass=" as *u8); g_i(pass); g_p("/" as *u8); g_i(tot)
79 if pass == tot { g_p(" verdict=GREEN (a REAL creature-collector loop RUNS end-to-end; honest headless slice, no visuals/UI/MP)\n" as *u8); sys_exit(0); return 0 }
80 g_p(" verdict=RED\n" as *u8); sys_exit(1); return 1
81}