code wiki / _hdl_build / nx_anatomy_critic_gate.nx

nx_anatomy_critic_gate.nx source

↩ module page · 236 lines · 11479 B

1// nx_anatomy_critic_gate.nx -- proves the anatomy critic is a REAL instrument by making it FAIL things 2// that should fail, including OUR OWN current figure. A critic you have not seen reject your own work is 3// not evidence -- that is the banked law this whole gate exists to honour. 4// MUTATION TARGET (documented): remove the connectivity hard-cap in ac2_quality => T1 RED (a detached 5// head scores as a sound body). 6// license_tier: ORIGINAL 7import "nx_syscalls.nx" 8import "nx_anatomy_critic.nx" 9import "nx_game_raster.nx" 10import "nx_game_critic.nx" 11 12func 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 pn(v: i64) -> i64 { 14 let t: *u8 = sys_mmap(32) as *u8 15 var m: i64 = v 16 var w: i64 = 0 17 if m < 0 { t[w] = 45 as u8; w = w + 1; m = 0 - m } 18 if m == 0 { t[w] = 48 as u8; sys_write(1, t, w + 1); return 0 } 19 let d: *u8 = sys_mmap(32) as *u8 20 var k: i64 = 0 21 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 22 var j: i64 = 0 23 while j < k { t[w] = d[k - 1 - j]; w = w + 1; j = j + 1 } 24 sys_write(1, t, w) 25 return 0 26} 27func nl() -> i64 { p("\n" as *u8); return 0 } 28 29const FW: i64 = 160 30const FH: i64 = 220 31const BG: i64 = 0 // black background 32 33func newfb() -> *i64 { 34 let fb: *i64 = sys_mmap(FW*FH*8) as *i64 35 gr_clear(fb, FW, FH, BG) 36 return fb 37} 38func ell(fb: *i64, cx: i64, cy: i64, rx: i64, ry: i64, c: i64) -> i64 { 39 if rx <= 0 { return 0 } 40 if ry <= 0 { return 0 } 41 var y: i64 = 0 - ry 42 while y <= ry { 43 var x: i64 = 0 - rx 44 while x <= rx { 45 if x*x*10000/(rx*rx) + y*y*10000/(ry*ry) <= 10000 { gr_px(fb, FW, FH, cx+x, cy+y, c) } 46 x = x + 1 47 } 48 y = y + 1 49 } 50 return 0 51} 52// a SOUND figure: head on a neck, tapered torso, legs to the floor. Deliberately plain. 53func draw_sound(fb: *i64) -> i64 { 54 let skin: i64 = gr_pack(228, 176, 152) 55 ell(fb, 80, 30, 15, 18, skin) // head 56 ell(fb, 80, 48, 6, 8, skin) // NECK -- what makes it one body 57 ell(fb, 80, 70, 26, 20, skin) // shoulders/chest 58 ell(fb, 80, 92, 18, 16, skin) // waist (narrower = taper) 59 ell(fb, 80, 114, 27, 18, skin) // hips (wider again) 60 ell(fb, 52, 82, 6, 26, skin) // arms 61 ell(fb, 108, 82, 6, 26, skin) 62 ell(fb, 68, 165, 11, 50, skin) // legs to the floor 63 ell(fb, 92, 165, 11, 50, skin) 64 return 0 65} 66// the SAME figure with the head DETACHED -- the exact defect our identity sheet shipped 67func draw_detached(fb: *i64) -> i64 { 68 let skin: i64 = gr_pack(228, 176, 152) 69 ell(fb, 80, 22, 15, 18, skin) // head, floating high, NO neck 70 ell(fb, 80, 70, 26, 20, skin) 71 ell(fb, 80, 92, 18, 16, skin) 72 ell(fb, 80, 114, 27, 18, skin) 73 ell(fb, 52, 82, 6, 26, skin) 74 ell(fb, 108, 82, 6, 26, skin) 75 ell(fb, 68, 165, 11, 50, skin) 76 ell(fb, 92, 165, 11, 50, skin) 77 return 0 78} 79// a SHADED ellipse -- the exact draw style the identity sheet used to score 876=SOTA on richness 80func ell_shaded(fb: *i64, cx: i64, cy: i64, rx: i64, ry: i64, r: i64, g: i64, b: i64) -> i64 { 81 if rx <= 0 { return 0 } 82 if ry <= 0 { return 0 } 83 var y: i64 = 0 - ry 84 while y <= ry { 85 var x: i64 = 0 - rx 86 while x <= rx { 87 if x*x*10000/(rx*rx) + y*y*10000/(ry*ry) <= 10000 { 88 var lit: i64 = 100 + (0 - x) * 40 / rx + (0 - y) * 40 / ry 89 if lit < 55 { lit = 55 } 90 if lit > 165 { lit = 165 } 91 var rr: i64 = r * lit / 100 92 if rr > 255 { rr = 255 } 93 var gg: i64 = g * lit / 100 94 if gg > 255 { gg = 255 } 95 var bb: i64 = b * lit / 100 96 if bb > 255 { bb = 255 } 97 gr_px(fb, FW, FH, cx+x, cy+y, gr_pack(rr, gg, bb)) 98 } 99 x = x + 1 100 } 101 y = y + 1 102 } 103 return 0 104} 105// the sheet's failure mode, faithfully: SHADED lobes with the head floating free 106func draw_shaded_detached(fb: *i64) -> i64 { 107 ell_shaded(fb, 80, 22, 15, 18, 228, 176, 152) 108 ell_shaded(fb, 80, 70, 26, 20, 228, 176, 152) 109 ell_shaded(fb, 80, 92, 18, 16, 228, 176, 152) 110 ell_shaded(fb, 80, 114, 27, 18, 228, 176, 152) 111 ell_shaded(fb, 52, 82, 6, 26, 228, 176, 152) 112 ell_shaded(fb, 108, 82, 6, 26, 228, 176, 152) 113 ell_shaded(fb, 68, 165, 11, 50, 228, 176, 152) 114 ell_shaded(fb, 92, 165, 11, 50, 228, 176, 152) 115 return 0 116} 117// a LOLLIPOP: giant head, spindly everything, no taper -- reads as not-a-body 118func draw_lollipop(fb: *i64) -> i64 { 119 let skin: i64 = gr_pack(228, 176, 152) 120 ell(fb, 80, 55, 45, 50, skin) // enormous head 121 ell(fb, 80, 108, 4, 8, skin) 122 ell(fb, 80, 150, 5, 40, skin) // stick body, no taper 123 return 0 124} 125// a CYLINDER: connected, correct head, but zero taper -- should read CRUDE, not CLEAN 126func draw_cylinder(fb: *i64) -> i64 { 127 let skin: i64 = gr_pack(228, 176, 152) 128 ell(fb, 80, 30, 15, 18, skin) 129 ell(fb, 80, 48, 6, 8, skin) 130 gr_rect(fb, FW, FH, 60, 56, 100, 214, skin) // straight tube, no waist 131 return 0 132} 133 134func main() -> i64 { 135 p("=== nx_anatomy_critic_gate (does this shape read as a BODY?) ===\n" as *u8) 136 var pass: i64 = 0 137 let checks: i64 = 6 138 let o: *i64 = sys_mmap(AC2_N * 8) as *i64 139 140 // ---------- T1 ★THE DETACHED HEAD IS REJECTED (the defect that scored SOTA 876 elsewhere) ---------- 141 let fbS: *i64 = newfb() 142 draw_sound(fbS) 143 ac2_score(fbS, FW, FH, 20, 5, 140, 218, BG, 0, o) 144 let qS: i64 = ac2_quality(o) 145 let connS: i64 = o[AC2_M_CONN] 146 let fbD: *i64 = newfb() 147 draw_detached(fbD) 148 ac2_score(fbD, FW, FH, 20, 5, 140, 218, BG, 0, o) 149 let qD: i64 = ac2_quality(o) 150 let connD: i64 = o[AC2_M_CONN] 151 var t1: i64 = 0 152 if qD < AC2_BROKEN { if qS >= AC2_CRUDE { if connD < connS { t1 = 1 } } } 153 if t1 == 1 { pass = pass + 1; p("T1 GREEN detached head REJECTED: connected body " as *u8); pn(qS); p("=" as *u8); p(ac2_verdict(qS)); p(" (conn " as *u8); pn(connS); p(") vs floating head " as *u8); pn(qD); p("=" as *u8); p(ac2_verdict(qD)); p(" (conn " as *u8); pn(connD); p(")\n" as *u8) } 154 if t1 == 0 { p("T1 RED sound=" as *u8); pn(qS); p(" detached=" as *u8); pn(qD); p(" connS=" as *u8); pn(connS); p(" connD=" as *u8); pn(connD); nl() } 155 156 // ---------- T2 LOLLIPOP REJECTED ---------- 157 let fbL: *i64 = newfb() 158 draw_lollipop(fbL) 159 ac2_score(fbL, FW, FH, 20, 5, 140, 218, BG, 0, o) 160 let qL: i64 = ac2_quality(o) 161 var t2: i64 = 0 162 if qL < AC2_CRUDE { if qL < qS { t2 = 1 } } 163 if t2 == 1 { pass = pass + 1; p("T2 GREEN lollipop REJECTED: " as *u8); pn(qL); p(" = " as *u8); p(ac2_verdict(qL)); p(" (head " as *u8); pn(o[AC2_M_HEAD]); p(", vbal " as *u8); pn(o[AC2_M_VBAL]); p(") vs a real body at " as *u8); pn(qS); nl() } 164 if t2 == 0 { p("T2 RED lollipop=" as *u8); pn(qL); nl() } 165 166 // ---------- T3 TAPER discriminates a body from a tube ---------- 167 let fbC: *i64 = newfb() 168 draw_cylinder(fbC) 169 ac2_score(fbC, FW, FH, 20, 5, 140, 218, BG, 0, o) 170 let taperC: i64 = o[AC2_M_TAPER] 171 let qC: i64 = ac2_quality(o) 172 ac2_score(fbS, FW, FH, 20, 5, 140, 218, BG, 0, o) 173 let taperS: i64 = o[AC2_M_TAPER] 174 var t3: i64 = 0 175 if taperS > taperC { if taperC < 100 { if qC < qS { t3 = 1 } } } 176 if t3 == 1 { pass = pass + 1; p("T3 GREEN taper is real: body taper " as *u8); pn(taperS); p(" vs tube " as *u8); pn(taperC); p(" (tube scores " as *u8); pn(qC); p("=" as *u8); p(ac2_verdict(qC)); p(", below the body's " as *u8); pn(qS); p(")\n" as *u8) } 177 if t3 == 0 { p("T3 RED taperS=" as *u8); pn(taperS); p(" taperC=" as *u8); pn(taperC); nl() } 178 179 // ---------- T4 STYLE widens the head band but never removes it ---------- 180 // an anime-proportioned figure (bigger head) must PASS as anime and be penalised as realistic 181 let fbA: *i64 = newfb() 182 let skin: i64 = gr_pack(228, 176, 152) 183 ell(fbA, 80, 40, 26, 30, skin) // big anime head 184 ell(fbA, 80, 68, 7, 8, skin) // neck 185 ell(fbA, 80, 92, 22, 18, skin) 186 ell(fbA, 80, 112, 15, 14, skin) 187 ell(fbA, 80, 132, 23, 16, skin) 188 ell(fbA, 68, 178, 10, 40, skin) 189 ell(fbA, 92, 178, 10, 40, skin) 190 ac2_score(fbA, FW, FH, 20, 5, 140, 218, BG, 1, o) 191 let headA_anime: i64 = o[AC2_M_HEAD] 192 let qA_anime: i64 = ac2_quality(o) 193 ac2_score(fbA, FW, FH, 20, 5, 140, 218, BG, 0, o) 194 let headA_real: i64 = o[AC2_M_HEAD] 195 var t4: i64 = 0 196 if headA_anime > headA_real { if qA_anime >= AC2_CRUDE { t4 = 1 } } 197 if t4 == 1 { pass = pass + 1; p("T4 GREEN style-aware: the same anime figure scores head " as *u8); pn(headA_anime); p(" judged as ANIME vs " as *u8); pn(headA_real); p(" judged as REALISTIC -- the band moves, it never disappears\n" as *u8) } 198 if t4 == 0 { p("T4 RED anime=" as *u8); pn(headA_anime); p(" real=" as *u8); pn(headA_real); p(" q=" as *u8); pn(qA_anime); nl() } 199 200 // ---------- T5 ★★THE INSTRUMENT CATCHES WHAT nx_game_critic MISSED ---------- 201 // Reproduce the ACTUAL failure: the identity sheet scored 876=SOTA on richness with detached heads, 202 // because its figures were SHADED (gradient+coherence+palette all maxed). A flat test figure does not 203 // reproduce it -- richness correctly calls flat ellipses TOY. So shade this one the same way the sheet 204 // did, which is what makes richness happy while the body is still in pieces. 205 let fbDS: *i64 = newfb() 206 draw_shaded_detached(fbDS) 207 let gout: *i64 = sys_mmap(GC_N * 8) as *i64 208 gc_score(fbDS, FW, FH, gout) 209 let rich_detached: i64 = gc_quality(gout) 210 ac2_score(fbDS, FW, FH, 20, 5, 140, 218, BG, 0, o) 211 let anat_detached: i64 = ac2_quality(o) 212 var t5: i64 = 0 213 if anat_detached < AC2_BROKEN { if rich_detached > anat_detached { t5 = 1 } } 214 if t5 == 1 { pass = pass + 1; p("T5 GREEN the blind spot is REAL and now covered: the same broken figure scores richness " as *u8); pn(rich_detached); p(" (" as *u8); p(gc_verdict(rich_detached)); p(") but anatomy " as *u8); pn(anat_detached); p(" (" as *u8); p(ac2_verdict(anat_detached)); p(") -- richness cannot see a detached head\n" as *u8) } 215 if t5 == 0 { p("T5 RED rich=" as *u8); pn(rich_detached); p(" anat=" as *u8); pn(anat_detached); nl() } 216 217 // ---------- T6 ANTI-VACUITY: the critic is not simply rejecting everything ---------- 218 // A sound body must clear CRUDE, all five dimensions must be live on it, and an EMPTY frame must be 0. 219 ac2_score(fbS, FW, FH, 20, 5, 140, 218, BG, 0, o) 220 var live: i64 = 0 221 var d: i64 = 0 222 while d < AC2_N { if o[d] > 0 { live = live + 1 } d = d + 1 } 223 let fbE: *i64 = newfb() 224 let oe: *i64 = sys_mmap(AC2_N * 8) as *i64 225 ac2_score(fbE, FW, FH, 20, 5, 140, 218, BG, 0, oe) 226 let qE: i64 = ac2_quality(oe) 227 var t6: i64 = 0 228 if qS >= AC2_CRUDE { if live == AC2_N { if qE == 0 { t6 = 1 } } } 229 if t6 == 1 { pass = pass + 1; p("T6 GREEN anti-vacuity: a sound body scores " as *u8); pn(qS); p(" = " as *u8); p(ac2_verdict(qS)); p(" with all " as *u8); pn(live); p(" dimensions live, and an EMPTY frame scores 0 (it is not rejecting everything)\n" as *u8) } 230 if t6 == 0 { p("T6 RED qS=" as *u8); pn(qS); p(" live=" as *u8); pn(live); p(" empty=" as *u8); pn(qE); nl() } 231 232 p("nx_anatomy_critic_gate: " as *u8); pn(pass); p("/" as *u8); pn(checks); nl() 233 if pass == checks { p("VERDICT GREEN\n" as *u8); return 0 } 234 p("VERDICT RED\n" as *u8) 235 return 1 236}