code wiki / _hdl_build / nx_game_taming_gate.nx

nx_game_taming_gate.nx source

↩ module page · 271 lines · 13864 B

1// nx_game_taming_gate.nx -- proves the five taming paths are five REAL skills, not five buttons. 2// The design claim under test: every path can succeed AND fail, the fast paths COST loyalty, and trust 3// genuinely governs obedience. A taming system where every path always works is a menu, not a game. 4// MUTATION TARGET (documented): make tm_obeys ignore trust (constant chance) => T5 RED (a forced captive 5// obeys as reliably as a bonded one) while every other tooth stays GREEN. 6// license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_game_taming.nx" 9 10func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11func pn(v: i64) -> i64 { 12 let t: *u8 = sys_mmap(32) as *u8 13 var m: i64 = v 14 var w: i64 = 0 15 if m < 0 { t[w] = 45 as u8; w = w + 1; m = 0 - m } 16 if m == 0 { t[w] = 48 as u8; sys_write(1, t, w + 1); return 0 } 17 let d: *u8 = sys_mmap(32) as *u8 18 var k: i64 = 0 19 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 20 var j: i64 = 0 21 while j < k { t[w] = d[k - 1 - j]; w = w + 1; j = j + 1 } 22 sys_write(1, t, w) 23 return 0 24} 25func nl() -> i64 { p("\n" as *u8); return 0 } 26 27func mkw(ros: *i64, sp: i64, geno: i64, will: i64, disp: i64) -> i64 { 28 let h: i64 = en_spawn(ros) 29 en_set(ros, h, C_SPEC, sp) 30 en_set(ros, h, C_IV0, 16); en_set(ros, h, C_IV1, 16) 31 en_set(ros, h, C_IV2, 16); en_set(ros, h, C_IV3, 16) 32 en_set(ros, h, C_XP, 0); en_set(ros, h, C_LVL, 5) 33 en_set(ros, h, C_NICK, en_count(ros) - 1) 34 en_set(ros, h, C_GENO, geno); en_set(ros, h, C_SEXG, 0) 35 en_set(ros, h, C_POLY, 85); en_set(ros, h, C_EPI, 0) 36 en_set(ros, h, C_TRUST, 0); en_set(ros, h, C_WILL, will); en_set(ros, h, C_DISP, disp) 37 return h 38} 39 40func main() -> i64 { 41 p("=== nx_game_taming_gate (five paths, five real skills) ===\n" as *u8) 42 var pass: i64 = 0 43 let checks: i64 = 7 44 let tbl: *i64 = sys_mmap(64 * 8) as *i64 45 tm_arch_default(tbl) 46 let at: *i64 = sys_mmap(32 * 8) as *i64 47 tm_act_default(at) 48 let s: *i64 = sys_mmap(16) as *i64 49 s[0] = 27072026 50 51 // ---------- T1 ITEM: odds track HP the way the real catch curve does, and it CAN fail ---------- 52 let ros1: *i64 = sys_mmap(en_bytes(64, COMP_NC)) as *i64 53 en_init(ros1, 64, COMP_NC) 54 let w1: i64 = mkw(ros1, 0, 0, 500, 300) 55 let c1: *i64 = sys_mmap(24 * 8) as *i64 56 cb_set(c1, 2, 5, 100, 20, 20, 20, "Wild" as *u8) 57 c1[3] = 100 // full HP 58 let odds_full: i64 = tm_item_odds_permil(ros1, w1, tbl, c1, 1) 59 c1[3] = 12 // weakened 60 let odds_weak: i64 = tm_item_odds_permil(ros1, w1, tbl, c1, 1) 61 var caught: i64 = 0 62 var failed: i64 = 0 63 var tries: i64 = 0 64 while tries < 400 { 65 let r1: *i64 = sys_mmap(en_bytes(8, COMP_NC)) as *i64 66 en_init(r1, 8, COMP_NC) 67 let ww: i64 = mkw(r1, 0, 0, 500, 300) 68 let cc: *i64 = sys_mmap(24 * 8) as *i64 69 cb_set(cc, 2, 5, 100, 20, 20, 20, "Wild" as *u8) 70 cc[3] = 12 71 let rc: i64 = tm_item_try(r1, ww, tbl, cc, 1, s) 72 if rc == TM_OK { caught = caught + 1 } 73 if rc == TM_RESIST { failed = failed + 1 } 74 tries = tries + 1 75 } 76 var t1: i64 = 0 77 if odds_weak > odds_full { if caught > 0 { if failed > 0 { if odds_full > 0 { t1 = 1 } } } } 78 if t1 == 1 { pass = pass + 1; p("T1 GREEN item capture is a real curve: odds " as *u8); pn(odds_full); p(" permil at full HP -> " as *u8); pn(odds_weak); p(" weakened; over 400 throws " as *u8); pn(caught); p(" caught / " as *u8); pn(failed); p(" broke free (it can fail)\n" as *u8) } 79 if t1 == 0 { p("T1 RED item full=" as *u8); pn(odds_full); p(" weak=" as *u8); pn(odds_weak); p(" caught=" as *u8); pn(caught); p(" failed=" as *u8); pn(failed); nl() } 80 81 // ---------- T2 ITEM failure HARDENS her: a missed charm makes the next one worse ---------- 82 let ros2: *i64 = sys_mmap(en_bytes(16, COMP_NC)) as *i64 83 en_init(ros2, 16, COMP_NC) 84 let w2: i64 = mkw(ros2, 0, 0, 400, 500) 85 let will_before: i64 = en_get(ros2, w2, C_WILL) 86 let disp_before: i64 = en_get(ros2, w2, C_DISP) 87 let c2: *i64 = sys_mmap(24 * 8) as *i64 88 cb_set(c2, 2, 5, 100, 20, 20, 20, "Wild" as *u8) 89 c2[3] = 99 // nearly full: throws will mostly fail 90 var hardened: i64 = 0 91 var k2: i64 = 0 92 while k2 < 5 { if tm_item_try(ros2, w2, tbl, c2, 1, s) == TM_RESIST { hardened = hardened + 1 } k2 = k2 + 1 } 93 var t2: i64 = 0 94 if hardened > 0 { 95 if en_get(ros2, w2, C_WILL) > will_before { if en_get(ros2, w2, C_DISP) < disp_before { t2 = 1 } } 96 } 97 if t2 == 1 { pass = pass + 1; p("T2 GREEN a failed charm costs you: will " as *u8); pn(will_before); p("->" as *u8); pn(en_get(ros2, w2, C_WILL)); p(", disposition " as *u8); pn(disp_before); p("->" as *u8); pn(en_get(ros2, w2, C_DISP)); p(" (she learned the trap)\n" as *u8) } 98 if t2 == 0 { p("T2 RED hardened=" as *u8); pn(hardened); nl() } 99 100 // ---------- T3 SEDUCTION is a READ, not a grind: right approach wins, wrong approach LOSES ---------- 101 // Same woman, same seed budget: play her archetype correctly vs incorrectly. 102 var won_right: i64 = 0 103 var won_wrong: i64 = 0 104 var a3: i64 = 0 105 while a3 < TM_NARCH { 106 // build a wild whose derived archetype is a3 by searching genomes (archetype is DERIVED, not set) 107 var g3: i64 = 0 108 var found: i64 = 0 109 var gi: i64 = 0 110 while gi < 64 { 111 if found == 0 { 112 let rp: *i64 = sys_mmap(en_bytes(8, COMP_NC)) as *i64 113 en_init(rp, 8, COMP_NC) 114 let hp3: i64 = mkw(rp, gi % 6, gi, 300, 400) 115 if tm_archetype(rp, hp3) == a3 { g3 = gi; found = 1 } 116 } 117 gi = gi + 1 118 } 119 if found == 1 { 120 // RIGHT read: always her best approach 121 let rr: *i64 = sys_mmap(en_bytes(8, COMP_NC)) as *i64 122 en_init(rr, 8, COMP_NC) 123 let hr: i64 = mkw(rr, g3 % 6, g3, 300, 400) 124 let ar: i64 = tm_archetype(rr, hr) 125 var okr: i64 = 0 126 var tr: i64 = 0 127 while tr < 12 { 128 if okr == 0 { if tm_seduce_step(rr, hr, tbl, tm_best(tbl, ar), 200, s) == TM_OK { okr = 1 } } 129 tr = tr + 1 130 } 131 if okr == 1 { won_right = won_right + 1 } 132 // WRONG read: always her worst approach 133 let rw: *i64 = sys_mmap(en_bytes(8, COMP_NC)) as *i64 134 en_init(rw, 8, COMP_NC) 135 let hw: i64 = mkw(rw, g3 % 6, g3, 300, 400) 136 let aw: i64 = tm_archetype(rw, hw) 137 var okw: i64 = 0 138 var tw: i64 = 0 139 while tw < 12 { 140 if okw == 0 { if tm_seduce_step(rw, hw, tbl, tm_worst(tbl, aw), 200, s) == TM_OK { okw = 1 } } 141 tw = tw + 1 142 } 143 if okw == 1 { won_wrong = won_wrong + 1 } 144 } 145 a3 = a3 + 1 146 } 147 var t3: i64 = 0 148 if won_right == TM_NARCH { if won_wrong == 0 { t3 = 1 } } 149 if t3 == 1 { pass = pass + 1; p("T3 GREEN seduction is a READ: playing the right approach won " as *u8); pn(won_right); p("/4 archetypes, the wrong approach won " as *u8); pn(won_wrong); p("/4 (reading her is the skill)\n" as *u8) } 150 if t3 == 0 { p("T3 RED seduce right=" as *u8); pn(won_right); p(" wrong=" as *u8); pn(won_wrong); nl() } 151 152 // ---------- T4 THE FAST PATH COSTS LOYALTY (the design's whole point) ---------- 153 let dst4: *i64 = sys_mmap(en_bytes(64, COMP_NC)) as *i64 154 en_init(dst4, 64, COMP_NC) 155 let src4: *i64 = sys_mmap(en_bytes(64, COMP_NC)) as *i64 156 en_init(src4, 64, COMP_NC) 157 let hd: i64 = mkw(src4, 1, 5, 500, 400) 158 let hs: i64 = mkw(src4, 1, 5, 500, 400) 159 let gd: i64 = tm_acquire(dst4, src4, hd, TM_DOMINANCE) 160 let gs2: i64 = tm_acquire(dst4, src4, hs, TM_SEDUCE) 161 var t4: i64 = 0 162 if gd > 0 { if gs2 > 0 { 163 let td: i64 = en_get(dst4, gd, C_TRUST) 164 let ts: i64 = en_get(dst4, gs2, C_TRUST) 165 if ts > td { if tm_willing(dst4, gd) == 0 { if td > 0 { t4 = 1 } } } 166 } } 167 if t4 == 1 { pass = pass + 1; p("T4 GREEN the fast path costs loyalty: dominated companion trust " as *u8); pn(en_get(dst4, gd, C_TRUST)); p(" (NOT willing) vs seduced " as *u8); pn(en_get(dst4, gs2, C_TRUST)); p(" -- force gets you a body, not a partner\n" as *u8) } 168 if t4 == 0 { p("T4 RED acquire-bond gd=" as *u8); pn(gd); p(" gs=" as *u8); pn(gs2); nl() } 169 170 // ---------- T5 TRUST GOVERNS OBEDIENCE (the mutation target) + training actually closes the gap ---- 171 let ros5: *i64 = sys_mmap(en_bytes(16, COMP_NC)) as *i64 172 en_init(ros5, 16, COMP_NC) 173 let forced: i64 = mkw(ros5, 1, 5, 700, 300) 174 en_set(ros5, forced, C_TRUST, 100) 175 var obey_forced: i64 = 0 176 var o5: i64 = 0 177 while o5 < 1000 { obey_forced = obey_forced + tm_obeys(ros5, forced, s); o5 = o5 + 1 } 178 // now TRAIN her for 60 sessions of praise+rest and re-measure 179 var tr5: i64 = 0 180 while tr5 < 60 { 181 tm_train(ros5, forced, tbl, at, TM_ACT_PRAISE, s) 182 tm_train(ros5, forced, tbl, at, TM_ACT_REST, s) 183 tr5 = tr5 + 1 184 } 185 let trust_after: i64 = en_get(ros5, forced, C_TRUST) 186 var obey_trained: i64 = 0 187 var o5b: i64 = 0 188 while o5b < 1000 { obey_trained = obey_trained + tm_obeys(ros5, forced, s); o5b = o5b + 1 } 189 var t5: i64 = 0 190 if obey_trained > obey_forced + 150 { if trust_after > 500 { if obey_forced < 600 { t5 = 1 } } } 191 if t5 == 1 { pass = pass + 1; p("T5 GREEN trust governs obedience: a forced captive obeyed " as *u8); pn(obey_forced); p("/1000; after 60 training sessions trust rose to " as *u8); pn(trust_after); p(" and obedience to " as *u8); pn(obey_trained); p("/1000 -- the slow path is what makes her yours\n" as *u8) } 192 if t5 == 0 { p("T5 RED obey_forced=" as *u8); pn(obey_forced); p(" trust_after=" as *u8); pn(trust_after); p(" obey_trained=" as *u8); pn(obey_trained); nl() } 193 194 // ---------- T6 RELEASE has consequences + she can RETURN remembering how it went ---------- 195 let ros6: *i64 = sys_mmap(en_bytes(16, COMP_NC)) as *i64 196 en_init(ros6, 16, COMP_NC) 197 let reg: *i64 = sys_mmap((1 + 32*TM_REL_STRIDE) * 8) as *i64 198 reg[0] = 0 199 let repbox: *i64 = sys_mmap(16) as *i64 200 repbox[0] = 0 201 let loved: i64 = mkw(ros6, 2, 9, 200, 800) 202 en_set(ros6, loved, C_TRUST, 800) 203 let vec_before: i64 = comp_vec(ros6, loved) 204 tm_release(ros6, loved, reg, 32, repbox) 205 let rep_after_loved: i64 = repbox[0] 206 let stranger: i64 = mkw(ros6, 3, 3, 600, 200) 207 en_set(ros6, stranger, C_TRUST, 50) 208 tm_release(ros6, stranger, reg, 32, repbox) 209 let rep_after_both: i64 = repbox[0] 210 var idx6: i64 = 0-1 211 var r6: i64 = 0 212 while r6 < 40 { if idx6 < 0 { idx6 = tm_maybe_return(reg, s) } r6 = r6 + 1 } 213 var returned_vec: i64 = 0-1 214 var back: i64 = 0-1 215 if idx6 >= 0 { back = tm_readmit(ros6, reg, idx6); if back > 0 { returned_vec = comp_vec(ros6, back) } } 216 var t6: i64 = 0 217 if rep_after_loved < 0 { if rep_after_both > rep_after_loved { if tm_rel_count(reg) == 2 { 218 if idx6 >= 0 { if returned_vec == reg[1 + idx6*TM_REL_STRIDE + 0] { t6 = 1 } } 219 } } } 220 if t6 == 1 { pass = pass + 1; p("T6 GREEN release has weight: freeing a companion who trusted you cost reputation " as *u8); pn(rep_after_loved); p(", freeing a stranger recovered to " as *u8); pn(rep_after_both); p("; one returned later with her identity intact (vec " as *u8); pn(returned_vec); p(")\n" as *u8) } 221 if t6 == 0 { p("T6 RED rep1=" as *u8); pn(rep_after_loved); p(" rep2=" as *u8); pn(rep_after_both); p(" n=" as *u8); pn(tm_rel_count(reg)); p(" idx=" as *u8); pn(idx6); nl() } 222 223 // ---------- T7 determinism + anti-vacuity: no path is a guaranteed win, all archetypes reachable ---- 224 var det: i64 = 0 225 var rep: i64 = 0 226 var ck1: i64 = 0 227 var ck2: i64 = 0 228 while rep < 2 { 229 let sd: *i64 = sys_mmap(16) as *i64 230 sd[0] = 999331 231 let rr7: *i64 = sys_mmap(en_bytes(16, COMP_NC)) as *i64 232 en_init(rr7, 16, COMP_NC) 233 let h7: i64 = mkw(rr7, 1, 7, 500, 400) 234 var ck: i64 = 1469598103 235 var i7: i64 = 0 236 while i7 < 50 { 237 tm_train(rr7, h7, tbl, at, i7 % TM_NACT, sd) 238 tm_seduce_step(rr7, h7, tbl, i7 % TM_NAP, 150, sd) 239 ck = ((ck ^ (en_get(rr7, h7, C_TRUST)*7 + en_get(rr7, h7, C_WILL)*13 + en_get(rr7, h7, C_DISP)*17 + tm_obeys(rr7, h7, sd))) * 1099511) & 4611686018427387903 240 i7 = i7 + 1 241 } 242 if rep == 0 { ck1 = ck } 243 if rep == 1 { ck2 = ck } 244 rep = rep + 1 245 } 246 if ck1 == ck2 { if ck1 != 0 { det = 1 } } 247 // anti-vacuity: every archetype is actually reachable from real genomes (a dead archetype = dead content) 248 let seenA: *i64 = sys_mmap(8 * 8) as *i64 249 var z: i64 = 0 250 while z < TM_NARCH { seenA[z] = 0; z = z + 1 } 251 var gi7: i64 = 0 252 while gi7 < 200 { 253 let rp7: *i64 = sys_mmap(en_bytes(8, COMP_NC)) as *i64 254 en_init(rp7, 8, COMP_NC) 255 let hh7: i64 = mkw(rp7, gi7 % 6, gx_founder(gi7 * 7 + 3), 300, 400) 256 seenA[tm_archetype(rp7, hh7)] = 1 257 gi7 = gi7 + 1 258 } 259 var narch: i64 = 0 260 var z2: i64 = 0 261 while z2 < TM_NARCH { narch = narch + seenA[z2]; z2 = z2 + 1 } 262 var t7: i64 = 0 263 if det == 1 { if narch == TM_NARCH { t7 = 1 } } 264 if t7 == 1 { pass = pass + 1; p("T7 GREEN deterministic (ck " as *u8); pn(ck1); p(" bit-equal across replays) and all " as *u8); pn(narch); p("/4 archetypes reachable from real genomes\n" as *u8) } 265 if t7 == 0 { p("T7 RED det=" as *u8); pn(det); p(" archetypes=" as *u8); pn(narch); nl() } 266 267 p("nx_game_taming_gate: " as *u8); pn(pass); p("/" as *u8); pn(checks); nl() 268 if pass == checks { p("VERDICT GREEN\n" as *u8); return 0 } 269 p("VERDICT RED\n" as *u8) 270 return 1 271}