code wiki / (root) / nx_part_solver_gate.nx

nx_part_solver_gate.nx source

↩ module page · 362 lines · 20388 B

1// nx_part_solver_gate.nx -- GATE for the constraint part-placement solver (the Infinigen-Indoors transfer, 2// operator 2026-08-12). Teeth the steer named: a BILATERAL-SYMMETRY tooth the typed tables cannot pass by 3// luck (exact mirror equality), and a deliberately-INCONSISTENT set that must be refused loudly, never 4// fabricated. Plus determinism, per-kind satisfaction, an untouched-parts trivial control, and the 5// APPLICATION tooth: a human face part-set assembled by constraints alone, rendered as an artifact. 6// license_tier: ORIGINAL expect_exit: 0 7import "nx_syscalls.nx" 8import "nx_part_solver_lib.nx" 9import "nx_trimesh.nx" 10import "nx_png.nx" 11import "nx_gate_verdict.nx" 12 13func gp_wfile(path: *u8, s: *u8) -> i64 { 14 let fd: i64 = sys_openat_wr(path, 0x1a4) 15 if fd < 0 { return 0 } 16 sys_write(fd, s, ps_slen(s)) 17 sys_close(fd) 18 return 1 19} 20func gp_load(path: *u8) -> i64 { 21 let lp: *i64 = sys_mmap(16) as *i64 22 let b: *u8 = sys_read_file(path, lp) 23 if (b as i64) == 0 { return 0 - 1 } 24 return ps_load(b, lp[0]) 25} 26 27func main() -> i64 { 28 let ctr: *i64 = gv_ctr() 29 gv_head("nx_part_solver_gate -- declarative constraints assemble parts (Infinigen-Indoors transfer, rung 1)" as *u8) 30 31 // face fixture: initial placements are DELIBERATE GARBAGE -- only the constraints carry the anatomy 32 let pf: *u8 = "/tmp/psg_face.conf" as *u8 33 gp_wfile(pf, "# face parts: anatomy by constraints, not typed coordinates\npart head 0 0 0 120\npart eyeL 5 7 9 12\npart eyeR 999 999 999 12\npart nose -50 33 210 10\npart mouth 77 -8 -300 14\nattach nose head 0 -70 0\nattach mouth head 0 -72 -45\nmirror eyeL eyeR\nstation eyeL 30 44\nstation eyeR 30 44\ninside eyeL head 80\ninside eyeR head 80\nclear eyeL eyeR 50\n" as *u8) 34 let rc1: i64 = gp_load(pf) 35 var solved: i64 = 0 36 if rc1 == 0 { solved = ps_solve() } 37 ps_dump() 38 gv_check("T1 face constraint set parses and SOLVES" as *u8, solved == 1, ctr) 39 40 let ih: i64 = ps_find("head" as *u8) 41 let il: i64 = ps_find("eyeL" as *u8) 42 let ir: i64 = ps_find("eyeR" as *u8) 43 let in2: i64 = ps_find("nose" as *u8) 44 let im: i64 = ps_find("mouth" as *u8) 45 var t2: i64 = 0 46 if in2 >= 0 { if im >= 0 { 47 if ps_x(in2) == 0 { if ps_y(in2) == 0-70 { if ps_z(in2) == 0 { 48 if ps_x(im) == 0 { if ps_y(im) == 0-72 { if ps_z(im) == 0-45 { t2 = 1 } } } } } } 49 } } 50 gv_check("T2 attach is EXACT: nose=(0,-70,0) mouth=(0,-72,-45)" as *u8, t2, ctr) 51 52 var t3: i64 = 0 53 if il >= 0 { if ir >= 0 { 54 if ps_x(il) == 0 - ps_x(ir) { if ps_y(il) == ps_y(ir) { if ps_z(il) == ps_z(ir) { t3 = 1 } } } 55 } } 56 gv_check("T3 BILATERAL SYMMETRY exact: eyeL = mirror(eyeR) about x=0" as *u8, t3, ctr) 57 58 let dx: i64 = ps_x(il) - ps_x(ir) 59 let dy: i64 = ps_y(il) - ps_y(ir) 60 let dz: i64 = ps_z(il) - ps_z(ir) 61 let d2e: i64 = dx*dx + dy*dy + dz*dz 62 gv_check("T4 clear holds: eyes >= 48 apart" as *u8, d2e >= 48*48, ctr) 63 64 let hx: i64 = ps_x(il) - ps_x(ih) 65 let hy: i64 = ps_y(il) - ps_y(ih) 66 let hz: i64 = ps_z(il) - ps_z(ih) 67 gv_check("T5 inside holds: eyeL within 82 of head centre" as *u8, hx*hx + hy*hy + hz*hz <= 82*82, ctr) 68 gv_check("T6 station holds: eyeL z in [28,46]" as *u8, (ps_z(il) >= 28)*(ps_z(il) <= 46) == 1, ctr) 69 70 // T7 determinism: reload + resolve reproduces every coordinate exactly 71 let sx: *i64 = sys_mmap(64*8) as *i64 72 var i: i64 = 0 73 while i < ps_np() { sx[i*3] = ps_x(i); sx[i*3+1] = ps_y(i); sx[i*3+2] = ps_z(i); i = i + 1 } 74 let n1: i64 = ps_np() 75 gp_load(pf) 76 ps_solve() 77 var t7: i64 = 1 78 if ps_np() != n1 { t7 = 0 } 79 i = 0 80 while i < n1 { if ps_x(i) != sx[i*3] { t7 = 0 } if ps_y(i) != sx[i*3+1] { t7 = 0 } if ps_z(i) != sx[i*3+2] { t7 = 0 } i = i + 1 } 81 gv_check("T7 deterministic: reload+resolve is coordinate-identical" as *u8, t7, ctr) 82 83 // T8 NEG-CONTROL: attach forces coincidence while clear demands 400 -- must be INCONSISTENT, never SOLVED 84 let pn: *u8 = "/tmp/psg_bad.conf" as *u8 85 gp_wfile(pn, "part a 0 0 0 5\npart b 10 0 0 5\nattach a b 0 0 0\nclear a b 400\n" as *u8) 86 var t8: i64 = 0 87 if gp_load(pn) == 0 { if ps_solve() == 0 { if ps_worst() >= 0 { t8 = 1 } } } 88 gv_puts(" neg-control worst=" as *u8); gv_puts(ps_kindname(ps_ckind(ps_worst()))); gv_puts(" violation=" as *u8); gv_num(ps_worstv()); gv_puts("\n" as *u8) 89 gv_check("T8 neg-control-inconsistent: unsatisfiable set reports INCONSISTENT with the worst NAMED" as *u8, t8, ctr) 90 91 // T9 trivial control: no constraints -> solved, and placements UNTOUCHED (the solver moves nothing it was not asked to) 92 let pt: *u8 = "/tmp/psg_triv.conf" as *u8 93 gp_wfile(pt, "part a 11 22 33 5\npart b -4 -5 -6 5\n" as *u8) 94 var t9: i64 = 0 95 if gp_load(pt) == 0 { if ps_solve() == 1 { 96 if ps_x(0) == 11 { if ps_y(0) == 22 { if ps_z(0) == 33 { if ps_x(1) == 0-4 { t9 = 1 } } } } 97 } } 98 gv_check("T9 trivial control: constraint-free parts stay EXACTLY where declared" as *u8, t9, ctr) 99 100 // T10 application artifact: re-solve the face and render the assembly (cubes at solved positions) 101 gp_load(pf) 102 ps_solve() 103 tm_reset() 104 var pi: i64 = 0 105 while pi < ps_np() { 106 var half: i64 = ps_r(pi)*4 107 if pi == ps_find("head" as *u8) { half = ps_r(pi)/2 } 108 var col: i64 = 214 + 170*256 + 150*65536 109 if pi == ps_find("eyeL" as *u8) { col = 80 + 160*256 + 230*65536 } 110 if pi == ps_find("eyeR" as *u8) { col = 80 + 160*256 + 230*65536 } 111 if pi == ps_find("nose" as *u8) { col = 230 + 170*256 + 120*65536 } 112 if pi == ps_find("mouth" as *u8) { col = 200 + 90*256 + 110*65536 } 113 tm_cube(ps_x(pi)*4, ps_z(pi)*4, ps_y(pi)*4, half, col) 114 pi = pi + 1 115 } 116 tm_compute_normals() 117 let npx: i64 = 360*360 118 let fb: *i64 = sys_mmap(npx*8) as *i64 119 let zb: *i64 = sys_mmap(npx*8) as *i64 120 var ci2: i64 = 0 121 while ci2 < npx { fb[ci2] = 24 + 26*256 + 34*65536; ci2 = ci2 + 1 } 122 trimesh_zclear(zb, npx) 123 trimesh_render(fb, zb, 360, 360, 300, 0-200, 2600, 520, 0) 124 var filled: i64 = 0 125 ci2 = 0 126 while ci2 < npx { if fb[ci2] != 24 + 26*256 + 34*65536 { filled = filled + 1 } ci2 = ci2 + 1 } 127 write_png(fb, 360, 360, "knowledge/nx_part_solver_face.png" as *u8) 128 gv_puts(" artifact knowledge/nx_part_solver_face.png filled=" as *u8); gv_num(filled); gv_puts("\n" as *u8) 129 gv_check("T10 the solved assembly renders (constraint-placed face parts, artifact emitted)" as *u8, filled > 500, ctr) 130 131 // ===== ★BEAUTY AS PROPORTIONS (operator 2026-08-12): canonical ranges as constraint DATA ===== 132 // φ-band ratio (mouth width : interpupillary = 618:1000 within 80 permil) + IPD band + symmetry. 133 // The NUMBERS are placeholder canon rows pending private reference calibration -- they are DATA, 134 // recalibrating beauty edits the conf, never this code. 135 let pb2: *u8 = "/tmp/psg_beauty.conf" as *u8 136 gp_wfile(pb2, "part head 0 0 0 120\npart eyeL 5 7 9 12\npart eyeR 999 999 999 12\npart noseTip 50 -60 20 10\npart mouthL -300 4 -9 6\npart mouthR 77 -8 -3 6\nattach noseTip head 0 -74 0\nmirror eyeL eyeR\nmirror mouthL mouthR\nstation eyeL 28 44\nstation eyeR 28 44\nstation mouthL -52 -38\nstation mouthR -52 -38\ninside eyeL head 80\ninside eyeR head 80\ninside mouthL head 90\ninside mouthR head 90\nband eyeL eyeR 92 116\nratio mouthL mouthR eyeL eyeR 618 1000 80\n" as *u8) 137 var t11: i64 = 0 138 var ipd: i64 = 0 139 var mw: i64 = 0 140 if gp_load(pb2) == 0 { if ps_solve() == 1 { 141 let el: i64 = ps_find("eyeL" as *u8) 142 let er: i64 = ps_find("eyeR" as *u8) 143 let ml: i64 = ps_find("mouthL" as *u8) 144 let mr: i64 = ps_find("mouthR" as *u8) 145 let ex: i64 = ps_x(el) - ps_x(er) 146 let ey: i64 = ps_y(el) - ps_y(er) 147 let ez: i64 = ps_z(el) - ps_z(er) 148 let mx: i64 = ps_x(ml) - ps_x(mr) 149 let my: i64 = ps_y(ml) - ps_y(mr) 150 let mz: i64 = ps_z(ml) - ps_z(mr) 151 ipd = ps_isqrt(ex*ex + ey*ey + ez*ez) 152 mw = ps_isqrt(mx*mx + my*my + mz*mz) 153 if ipd >= 90 { if ipd <= 118 { 154 let rp: i64 = mw*1000/ipd 155 if rp >= 530 { if rp <= 706 { t11 = 1 } } 156 } } 157 } } 158 gv_puts(" beauty: IPD=" as *u8); gv_num(ipd) 159 gv_puts(" mouthW=" as *u8); gv_num(mw) 160 if ipd > 0 { gv_puts(" ratio_permil=" as *u8); gv_num(mw*1000/ipd) } 161 gv_puts("\n" as *u8) 162 gv_check("T11 beauty canon SOLVES: IPD in band, mouth:IPD in the phi band (proportions from DATA)" as *u8, t11, ctr) 163 // impossible beauty: mouth band 300-400 vs phi ratio of a 92-116 IPD -- must refuse, never fabricate 164 let pb3: *u8 = "/tmp/psg_ugly.conf" as *u8 165 gp_wfile(pb3, "part eyeL 0 0 0 12\npart eyeR 100 0 0 12\npart mouthL 0 -40 0 6\npart mouthR 60 -40 0 6\nmirror eyeL eyeR\nmirror mouthL mouthR\nband eyeL eyeR 92 116\nband mouthL mouthR 300 400\nratio mouthL mouthR eyeL eyeR 618 1000 40\n" as *u8) 166 var t12: i64 = 0 167 if gp_load(pb3) == 0 { if ps_solve() == 0 { if ps_worst() >= 0 { t12 = 1 } } } 168 gv_puts(" ugly-control worst=" as *u8); gv_puts(ps_kindname(ps_ckind(ps_worst()))); gv_puts(" violation=" as *u8); gv_num(ps_worstv()); gv_puts("\n" as *u8) 169 gv_check("T12 neg-control-impossible-beauty: conflicting band+ratio refused with the worst NAMED" as *u8, t12, ctr) 170 // determinism of the beauty solve 171 let bx: *i64 = sys_mmap(64*8) as *i64 172 gp_load(pb2) 173 ps_solve() 174 var bi: i64 = 0 175 while bi < ps_np() { bx[bi*3] = ps_x(bi); bx[bi*3+1] = ps_y(bi); bx[bi*3+2] = ps_z(bi); bi = bi + 1 } 176 gp_load(pb2) 177 ps_solve() 178 var t13: i64 = 1 179 bi = 0 180 while bi < ps_np() { if ps_x(bi) != bx[bi*3] { t13 = 0 } if ps_y(bi) != bx[bi*3+1] { t13 = 0 } if ps_z(bi) != bx[bi*3+2] { t13 = 0 } bi = bi + 1 } 181 gv_check("T13 beauty solve deterministic: identical coordinates on re-solve" as *u8, t13, ctr) 182 183 // ===== ★RUNG 2 (2026-08-14): EXTENT + ORIENTATION + ENVELOPE AS FIRST-CLASS PARTS ===== 184 // The rung /world/procgen named from two directions ("orientation + extent -- parts are points today" 185 // and W4 R1 "city block = same engine at next scale"). T17 is the anti-vacuity tooth: the trivial wrong 186 // implementation -- one that STORES a facing but never lets it reach the geometry -- cannot pass it. 187 188 // T14 KAT: a pre-rung-2 file is untouched by the new code path (a point, facing +x, by default). 189 let qk: *u8 = "/tmp/psg_kat.conf" as *u8 190 gp_wfile(qk, "part a 11 22 33 5\npart b -4 -5 -6 5\nclear a b 40\n" as *u8) 191 var t14: i64 = 0 192 if gp_load(qk) == 0 { if ps_solve() == 1 { 193 if ps_ex(0) == 0 { if ps_ey(0) == 0 { if ps_ez(0) == 0 { if ps_fx(0) == 1 { if ps_fy(0) == 0 { t14 = 1 } } } } } 194 } } 195 gv_check("T14 KAT: a pre-rung-2 part stays a POINT facing +x -- legacy constraint files solve unchanged" as *u8, t14, ctr) 196 197 // T15 envelope: a box declared at garbage is slid WHOLLY inside its shell; containment asserted by 198 // arithmetic on every axis, never by trusting the verdict. 199 let qe: *u8 = "/tmp/psg_env.conf" as *u8 200 gp_wfile(qe, "part shell 0 0 0 0\nextent shell 1000 600 200\npart crate 999999 -888888 77777 0\nextent crate 150 90 40\nenvelope crate shell\n" as *u8) 201 var t15: i64 = 0 202 var qcx: i64 = 0 203 var qcy: i64 = 0 204 if gp_load(qe) == 0 { if ps_solve() == 1 { 205 let qs: i64 = ps_find("shell" as *u8) 206 let qc: i64 = ps_find("crate" as *u8) 207 qcx = ps_x(qc) 208 qcy = ps_y(qc) 209 var qax: i64 = 0 210 if ps_abs(ps_x(qc) - ps_x(qs)) + ps_exx(qc) <= ps_exx(qs) { qax = qax + 1 } 211 if ps_abs(ps_y(qc) - ps_y(qs)) + ps_eyy(qc) <= ps_eyy(qs) { qax = qax + 1 } 212 if ps_abs(ps_z(qc) - ps_z(qs)) + ps_ez(qc) <= ps_ez(qs) { qax = qax + 1 } 213 if qax == 3 { t15 = 1 } 214 } } 215 gv_puts(" envelope: crate slid to " as *u8); gv_num(qcx); gv_puts("," as *u8); gv_num(qcy); gv_puts("\n" as *u8) 216 gv_check("T15 envelope: a box from garbage lands WHOLLY inside its shell on all three axes" as *u8, t15, ctr) 217 218 // T16 noclip: boxes planted on top of each other separate, and the MEASURED lane is printed. 219 let qn: *u8 = "/tmp/psg_noclip.conf" as *u8 220 gp_wfile(qn, "part p 0 0 0 0\nextent p 100 60 0\npart q 5 3 0 0\nextent q 100 60 0\nnoclip p q 40\n" as *u8) 221 var t16: i64 = 0 222 var qgap: i64 = 0 223 if gp_load(qn) == 0 { if ps_solve() == 1 { 224 let qp: i64 = ps_find("p" as *u8) 225 let qq: i64 = ps_find("q" as *u8) 226 let qsx: i64 = ps_abs(ps_x(qp) - ps_x(qq)) - (ps_exx(qp) + ps_exx(qq)) 227 let qsy: i64 = ps_abs(ps_y(qp) - ps_y(qq)) - (ps_eyy(qp) + ps_eyy(qq)) 228 qgap = qsx 229 if qsy > qsx { qgap = qsy } 230 if qgap >= 40 { t16 = 1 } 231 } } 232 gv_puts(" noclip: measured lane=" as *u8); gv_num(qgap); gv_puts(" declared=40\n" as *u8) 233 gv_check("T16 noclip: intersecting footprints separate to at least the DECLARED gap" as *u8, t16, ctr) 234 235 // T17 ★ANTI-VACUITY: two files identical in every byte except ONE facing row. If facing were stored 236 // and never consumed, both solves would agree and this tooth would fail. It is the only tooth here 237 // that can distinguish a load-bearing orientation from a decorative one. 238 let qo1: *u8 = "/tmp/psg_ori1.conf" as *u8 239 let qo2: *u8 = "/tmp/psg_ori2.conf" as *u8 240 gp_wfile(qo1, "part w 0 0 0 0\nextent w 300 100 0\npart v 0 0 0 0\nextent v 300 100 0\nnoclip w v 0\n" as *u8) 241 gp_wfile(qo2, "part w 0 0 0 0\nextent w 300 100 0\nfacing w 0 1\npart v 0 0 0 0\nextent v 300 100 0\nnoclip w v 0\n" as *u8) 242 var qd1: i64 = 0 243 var qd2: i64 = 0 244 var qfoot: i64 = 0 245 if gp_load(qo1) == 0 { ps_solve(); qd1 = ps_abs(ps_x(0) - ps_x(1)) + ps_abs(ps_y(0) - ps_y(1)) } 246 if gp_load(qo2) == 0 { ps_solve(); qd2 = ps_abs(ps_x(0) - ps_x(1)) + ps_abs(ps_y(0) - ps_y(1)); qfoot = ps_exx(0) } 247 gv_puts(" orientation: unturned sep=" as *u8); gv_num(qd1) 248 gv_puts(" turned sep=" as *u8); gv_num(qd2) 249 gv_puts(" turned footprint_x=" as *u8); gv_num(qfoot); gv_puts(" (declared ex=300, ey=100)\n" as *u8) 250 var t17: i64 = 0 251 if qd1 != qd2 { if qfoot == 100 { t17 = 1 } } 252 gv_check("T17 anti-vacuity: ONE facing row swaps the footprint and CHANGES the solved layout" as *u8, t17, ctr) 253 254 // T18 face: a deliberately wrong facing is turned to address its datum, exactly. 255 let qfp: *u8 = "/tmp/psg_facerow.conf" as *u8 256 gp_wfile(qfp, "part chair 0 0 0 0\nextent chair 40 30 0\nfacing chair -1 0\npart table 0 900 0 0\nface chair table\n" as *u8) 257 var t18: i64 = 0 258 var qfxv: i64 = 0 259 var qfyv: i64 = 0 260 if gp_load(qfp) == 0 { if ps_solve() == 1 { 261 qfxv = ps_fx(0) 262 qfyv = ps_fy(0) 263 if qfxv == 0 { if qfyv == 1 { t18 = 1 } } 264 } } 265 gv_puts(" face: chair turned to (" as *u8); gv_num(qfxv); gv_puts("," as *u8); gv_num(qfyv); gv_puts(") toward a table at +y\n" as *u8) 266 gv_check("T18 face: a wrongly-oriented part is turned to address its datum, violation 0" as *u8, t18, ctr) 267 268 // T19 neg-control: a crate BIGGER than its shell cannot be contained. A fabricated fit here would be 269 // invisible in every downstream render, so it must be refused with envelope NAMED. 270 let qbad: *u8 = "/tmp/psg_envbad.conf" as *u8 271 gp_wfile(qbad, "part shell 0 0 0 0\nextent shell 100 100 10\npart crate 0 0 0 0\nextent crate 400 400 10\nenvelope crate shell\n" as *u8) 272 var t19: i64 = 0 273 if gp_load(qbad) == 0 { if ps_solve() == 0 { if ps_ckind(ps_worst()) == PS_K_ENVELOPE { t19 = 1 } } } 274 gv_puts(" neg-control-envelope worst=" as *u8); gv_puts(ps_kindname(ps_ckind(ps_worst()))); gv_puts(" violation=" as *u8); gv_num(ps_worstv()); gv_puts("\n" as *u8) 275 gv_check("T19 neg-control-oversize-envelope: a box too big for its shell is REFUSED, envelope NAMED" as *u8, t19, ctr) 276 277 // T20 neg-control: attach pins two footprints together while noclip demands a lane. 278 let qbad2: *u8 = "/tmp/psg_noclipbad.conf" as *u8 279 gp_wfile(qbad2, "part g 0 0 0 0\nextent g 50 50 0\npart h 0 0 0 0\nextent h 50 50 0\nattach g h 0 0 0\nnoclip g h 30\n" as *u8) 280 var t20: i64 = 0 281 if gp_load(qbad2) == 0 { if ps_solve() == 0 { if ps_worst() >= 0 { t20 = 1 } } } 282 gv_puts(" neg-control-pinned worst=" as *u8); gv_puts(ps_kindname(ps_ckind(ps_worst()))); gv_puts(" violation=" as *u8); gv_num(ps_worstv()); gv_puts("\n" as *u8) 283 gv_check("T20 neg-control-pinned-noclip: coincident-by-attach boxes cannot clear a lane -- refused loudly" as *u8, t20, ctr) 284 285 // T21 ★APPLICATION, W4 R1: the SAME engine that assembles a face SITES A CITY BLOCK from one data file. 286 var t21: i64 = 0 287 var qin: i64 = 0 288 var qover: i64 = 0 289 var qfaced: i64 = 0 290 var qaway: i64 = 0 291 var qsolved: i64 = 0 292 if gp_load("knowledge/w4_cityblock.conf" as *u8) == 0 { 293 qsolved = ps_solve() 294 ps_dump() 295 let qblk: i64 = ps_find("block" as *u8) 296 let qstr: i64 = ps_find("street" as *u8) 297 var qa: i64 = 0 298 while qa < ps_np() { 299 var qbuild: i64 = 0 300 if qa != qblk { if ps_ex(qa) > 0 { qbuild = 1 } } 301 if qbuild == 1 { 302 var qok: i64 = 0 303 if ps_abs(ps_x(qa) - ps_x(qblk)) + ps_exx(qa) <= ps_exx(qblk) { qok = qok + 1 } 304 if ps_abs(ps_y(qa) - ps_y(qblk)) + ps_eyy(qa) <= ps_eyy(qblk) { qok = qok + 1 } 305 if qok == 2 { qin = qin + 1 } 306 // ADDRESSES THE STREET = the facing points into the half-space that holds the street 307 // datum. NOT "everyone points south": a corner building legitimately fronts along the 308 // block when the datum is a POINT. This is a semantic property, not a restatement of the 309 // cardinal snap -- and the yard, which carries NO face row, is the control that must FAIL 310 // it (qaway), so the tooth cannot be passed by a solver that orients everything. 311 let qtx: i64 = ps_x(qstr) - ps_x(qa) 312 let qty: i64 = ps_y(qstr) - ps_y(qa) 313 if ps_fx(qa)*qtx + ps_fy(qa)*qty > 0 { qfaced = qfaced + 1 } else { qaway = qaway + 1 } 314 var qb2: i64 = qa + 1 315 while qb2 < ps_np() { 316 var qpair: i64 = 0 317 if qb2 != qblk { if ps_ex(qb2) > 0 { qpair = 1 } } 318 if qpair == 1 { 319 let qpx: i64 = (ps_exx(qa) + ps_exx(qb2)) - ps_abs(ps_x(qa) - ps_x(qb2)) 320 let qpy: i64 = (ps_eyy(qa) + ps_eyy(qb2)) - ps_abs(ps_y(qa) - ps_y(qb2)) 321 var qhit: i64 = 0 322 if qpx > 0 { if qpy > 0 { qhit = 1 } } 323 qover = qover + qhit 324 } 325 qb2 = qb2 + 1 326 } 327 } 328 qa = qa + 1 329 } 330 } 331 gv_puts(" cityblock: solved=" as *u8); gv_num(qsolved) 332 gv_puts(" inside_block=" as *u8); gv_num(qin) 333 gv_puts(" footprint_overlaps=" as *u8); gv_num(qover) 334 gv_puts(" addressing_street=" as *u8); gv_num(qfaced) 335 gv_puts(" not_addressing(control)=" as *u8); gv_num(qaway) 336 gv_puts(" residual=" as *u8); gv_num(ps_resid()); gv_puts("\n" as *u8) 337 if qsolved == 1 { if qin == 5 { if qover == 0 { if qfaced == 4 { if qaway == 1 { t21 = 1 } } } } } 338 gv_check("T21 W4 R1 city block: 5 sited inside, 0 overlaps, 4 addressing the street, 1 unfaced control NOT addressing it" as *u8, t21, ctr) 339 340 // T22 determinism at city scale -- placements AND orientations. 341 let qsn: *i64 = sys_mmap(128*8) as *i64 342 gp_load("knowledge/w4_cityblock.conf" as *u8) 343 ps_solve() 344 var qi: i64 = 0 345 while qi < ps_np() { qsn[qi*3] = ps_x(qi); qsn[qi*3+1] = ps_y(qi); qsn[qi*3+2] = ps_fx(qi)*10 + ps_fy(qi); qi = qi + 1 } 346 let qn2: i64 = ps_np() 347 gp_load("knowledge/w4_cityblock.conf" as *u8) 348 ps_solve() 349 var t22: i64 = 1 350 qi = 0 351 while qi < qn2 { 352 if ps_x(qi) != qsn[qi*3] { t22 = 0 } 353 if ps_y(qi) != qsn[qi*3+1] { t22 = 0 } 354 if ps_fx(qi)*10 + ps_fy(qi) != qsn[qi*3+2] { t22 = 0 } 355 qi = qi + 1 356 } 357 gv_check("T22 city solve deterministic: identical placements AND identical orientations on re-solve" as *u8, t22, ctr) 358 359 let rc: i64 = gv_verdict("PART-SOLVER-GATE" as *u8, ctr, "anatomy assembled by declarative constraints; beauty is proportion DATA; extent+orientation+envelope carry the same engine to city scale; inconsistency refused loudly" as *u8) 360 sys_exit(rc) 361 return rc 362}