code wiki / _hdl_build / nx_game_companion_gate.nx

nx_game_companion_gate.nx source

↩ module page · 128 lines · 6103 B

1// nx_game_companion_gate.nx -- certifies the OWNERSHIP core (nx_game_companion): the measurable 2// prerequisites of the endowment effect (beat-Veloren target, gamebench round 14). Each tooth is a 3// structural FACT, not a taste judgment, and the flagship is RED-TEAMED: a soulless generic-loot roster 4// (every companion identical) MUST fail the uniqueness property, proving the gate measures real ownership 5// substrate and can't be passed by mass-produced sameness. 6// T1 UNIQUE · T2 RED-TEAM (soulless generic fails) · T3 PERSISTENT (gamesave bit-exact) · 7// T4 INVESTMENT-DIVERGES (IKEA effect) · T5 DETERMINISM · T6 ANTI-VACUITY. 8// (Name is game-domain to avoid the pre-existing permaculture nx_companion_gate.) license_tier: ORIGINAL expect_exit: 0 9import "nx_syscalls.nx" 10import "nx_game_companion.nx" 11 12const CAP: i64 = 64 13const N: i64 = 50 14 15func ww(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 16func wn(v: i64) -> i64 { 17 if v==0 { sys_write(1,"0" as *u8,1); return 0 } 18 var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } 19 let t: *u8=sys_mmap(32); var k: i64=0 20 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } 21 let o: *u8=sys_mmap(32); var q: i64=k-1; var i: i64=0 22 while q>=0 { o[i]=t[q]; i=i+1; q=q-1 } 23 sys_write(1,o,i); return 0 24} 25 26func main() -> i64 { 27 var pass: i64=0 28 let SEED: i64 = 20260721 29 let ros: *i64 = sys_mmap(en_words(CAP, COMP_NC)*8) as *i64 30 comp_new_roster(ros, CAP, N, SEED, 1) 31 ww("=== nx_game_companion_gate (measurable OWNERSHIP -- the endowment substrate) ===\n") 32 33 // T1 UNIQUE 34 let dups: i64 = comp_dup_count(ros) 35 var t1: i64=0 36 if dups==0 { t1=1 } 37 if t1==1 { ww("T1 GREEN unique: "); wn(N); ww(" companions, 0 duplicate identity vectors (every one a distinct creature)\n"); pass=pass+1 } 38 if t1==0 { ww("T1 RED "); wn(dups); ww(" duplicate companions\n") } 39 40 // T2 RED-TEAM: soulless generic roster must FAIL uniqueness 41 let gen: *i64 = sys_mmap(en_words(CAP, COMP_NC)*8) as *i64 42 comp_new_roster(gen, CAP, N, SEED, 0) 43 let gdups: i64 = comp_dup_count(gen) 44 var t2: i64=0 45 if gdups >= N-1 { t2=1 } 46 if t2==1 { ww("T2 GREEN red-team: the SOULLESS generic roster has "); wn(gdups); ww(" duplicates -> ownership substrate ABSENT, as it must be (mass-produced sameness is rejected)\n"); pass=pass+1 } 47 if t2==0 { ww("T2 RED generic roster only "); wn(gdups); ww(" dups -- uniqueness tooth too weak\n") } 48 49 // T3 PERSISTENT via nx_gamesave 50 let S: *i64 = sys_mmap((1+N*COMP_NC)*8) as *i64 51 let ns: i64 = comp_serialize(ros, S) 52 sys_unlinkat("knowledge/nx_game_companion_roster.sav" as *u8) 53 let sv: i64 = gs_save("knowledge/nx_game_companion_roster.sav" as *u8, 7501, S, ns, SEED) 54 let S2: *i64 = sys_mmap((1+N*COMP_NC)*8+64) as *i64 55 let meta: *i64 = sys_mmap(8*8) as *i64 56 let lr: i64 = gs_load("knowledge/nx_game_companion_roster.sav" as *u8, S2, 1+N*COMP_NC+8, meta) 57 let ros2: *i64 = sys_mmap(en_words(CAP, COMP_NC)*8) as *i64 58 comp_restore(ros2, CAP, S2) 59 var diff: i64=0 60 var i: i64=0 61 while i<N { 62 let h1: i64 = en_nth(ros, i) 63 let h2: i64 = en_nth(ros2, i) 64 if comp_vec(ros, h1) != comp_vec(ros2, h2) { diff=diff+1 } 65 i=i+1 66 } 67 var t3: i64=0 68 if sv>0 { if lr==ns { if diff==0 { t3=1 } } } 69 if t3==1 { ww("T3 GREEN persistent: roster round-tripped gamesave bit-exact ("); wn(N); ww(" companions, 0 changed) -- what you own persists\n"); pass=pass+1 } 70 if t3==0 { ww("T3 RED persist sv="); wn(sv); ww(" lr="); wn(lr); ww(" ns="); wn(ns); ww(" diff="); wn(diff); ww("\n") } 71 72 // T4 INVESTMENT-DIVERGES 73 let ha: i64 = en_nth(ros, 0) 74 let hb: i64 = en_nth(ros, 1) 75 en_set(ros, hb, C_SPEC, en_get(ros, ha, C_SPEC)) 76 en_set(ros, hb, C_IV0, en_get(ros, ha, C_IV0)) 77 en_set(ros, hb, C_IV1, en_get(ros, ha, C_IV1)) 78 en_set(ros, hb, C_IV2, en_get(ros, ha, C_IV2)) 79 en_set(ros, hb, C_IV3, en_get(ros, ha, C_IV3)) 80 let pba: i64 = comp_power(ros, ha) 81 let pbb: i64 = comp_power(ros, hb) 82 comp_invest(ros, ha, 500) 83 let paa: i64 = comp_power(ros, ha) 84 let pab: i64 = comp_power(ros, hb) 85 var t4: i64=0 86 if pba==pbb { if paa > pab { if paa > pba { t4=1 } } } 87 if t4==1 { ww("T4 GREEN investment diverges: two identical creatures, XP into ONE -> power "); wn(paa); ww(" vs "); wn(pab); ww(" (it became distinctly yours -- IKEA effect)\n"); pass=pass+1 } 88 if t4==0 { ww("T4 RED invest before "); wn(pba); ww("/"); wn(pbb); ww(" after "); wn(paa); ww("/"); wn(pab); ww("\n") } 89 90 // T5 DETERMINISM 91 let ros3: *i64 = sys_mmap(en_words(CAP, COMP_NC)*8) as *i64 92 comp_new_roster(ros3, CAP, N, SEED, 1) 93 var same: i64=1 94 i=0 95 while i<N { if comp_vec(ros3, en_nth(ros3,i)) != comp_vec(ros2, en_nth(ros2,i)) { same=0 } i=i+1 } 96 var t5: i64=0 97 if same==1 { t5=1 } 98 if t5==1 { ww("T5 GREEN deterministic roster from a seed\n"); pass=pass+1 } 99 if t5==0 { ww("T5 RED nondeterministic\n") } 100 101 // T6 ANTI-VACUITY 102 let ros4: *i64 = sys_mmap(en_words(CAP, COMP_NC)*8) as *i64 103 comp_new_roster(ros4, CAP, N, SEED, 1) 104 var minsp: i64=999 105 var maxsp: i64=0 106 var miniv: i64=999 107 var maxiv: i64=0 108 i=0 109 while i<N { 110 let h: i64 = en_nth(ros4, i) 111 let sp: i64 = en_get(ros4, h, C_SPEC) 112 let iv: i64 = en_get(ros4, h, C_IV0) 113 if sp<minsp { minsp=sp } 114 if sp>maxsp { maxsp=sp } 115 if iv<miniv { miniv=iv } 116 if iv>maxiv { maxiv=iv } 117 i=i+1 118 } 119 var t6: i64=0 120 if maxsp>minsp { if maxiv-miniv >= 16 { t6=1 } } 121 if t6==1 { ww("T6 GREEN anti-vacuity: species span "); wn(minsp); ww(".."); wn(maxsp); ww(", IV span "); wn(miniv); ww(".."); wn(maxiv); ww(" (genuine variety)\n"); pass=pass+1 } 122 if t6==0 { ww("T6 RED trivial roster\n") } 123 124 ww("nx_game_companion_gate: "); wn(pass); ww("/6\n") 125 ww("SCOPE: proves the measurable PREREQUISITES of ownership (unique+persistent+investment-divergent), NOT the felt bond. Necessary, not sufficient.\n") 126 if pass==6 { return 0 } 127 return 1 128}