code wiki / _hdl_build / nx_worldpipe_gate.nx

nx_worldpipe_gate.nx source

↩ module page · 527 lines · 22578 B

1// nx_worldpipe_gate.nx -- ★R5 STAGED PROCGEN GATE: prove the pipeline is REAL, stage by stage, causally. 2// T1 the six parameter fields exist and are DECORRELATED (independent knobs, not one noise renamed). 3// T2 biome comes from the parameter VECTOR, not height: find same-height points with different biomes. 4// T3 the spline is monotone (continents rise from the sea) and EROSION FLATTENS (measured on the relief formula). 5// T4 the carver is CAUSAL: rivers exist with the stage on, vanish with it off (geometry, not paint). 6// T5 features RESPECT biome (cacti in desert, spruce in snow, trees in forest/plains) with real counts. 7// T6 determinism + seed variety (same seed = identical biome map; different seed = materially different). 8// T7 spawn stage: valid gentle land, deterministic. 9// T8 evidence: biome/continent map + 3D hero of the staged world -> knowledge/nx_worldpipe.png 10// license_tier: ORIGINAL expect_exit: 0 11import "nx_syscalls.nx" 12import "nx_png.nx" 13import "nx_trimesh.nx" 14import "nx_worldpipe.nx" 15const WG_MAGIC_1657: i64 = 1657 16const WG_MAGIC_2000: i64 = 2000 17const WG_MAGIC_1327: i64 = 1327 18const WG_MAGIC_16000: i64 = 16000 19const WG_MAGIC_8000: i64 = 8000 20const WG_MAGIC_2801: i64 = 2801 21const WG_MAGIC_3271: i64 = 3271 22const WG_MAGIC_7777: i64 = 7777 23const WG_MAGIC_3333: i64 = 3333 24const WG_MAGIC_4000: i64 = 4000 25const WG_MAGIC_1889: i64 = 1889 26const WG_MAGIC_1637: i64 = 1637 27const WG_MAGIC_19000: i64 = 19000 28const WG_MAGIC_9500: i64 = 9500 29const WG_MAGIC_2411: i64 = 2411 30const WG_MAGIC_1024: i64 = 1024 31const WG_MAGIC_65536: i64 = 65536 32const WG_MAGIC_5900: i64 = 5900 33const WG_T9_PAL: i64 = 4096 34const WG_T9_OFF: i64 = 2800 35const WG_T9_SOFF: i64 = 3100 36const WG_T9_SPAN: i64 = 9000 37const WG_T9_HALF: i64 = 4500 38const WG_T9_PA: i64 = 1637 39const WG_T9_PB: i64 = 2411 40 41func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 42func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 } 43func clearfb(fb: *i64, n: i64, c: i64) -> i64 { var i: i64=0; while i<n { fb[i]=c; i=i+1 } return 0 } 44 45const MAPW: i64 = 360 46const HERW: i64 = 560 47const GH: i64 = 360 48 49func main() -> i64 { 50 hw("=== nx_worldpipe_gate -- the STAGED six-parameter procgen pipeline, stage-causal ===\n" as *u8) 51 var fails: i64 = 0 52 wp_init(1) 53 let nspr: i64 = wp_hydro_bake() 54 hw(" hydrology: springs traced="); pn(nspr); hw("\n" as *u8) 55 56 // ---- T1 six fields, decorrelated ---- 57 var pair: i64 = 0 58 var t1: i64 = 1 59 while pair < 5 { 60 var agree: i64 = 0 61 var s: i64 = 0 62 while s < 60 { 63 let x: i64 = (s*991) % WG_T9_SPAN - WG_T9_HALF 64 let z: i64 = (s*WG_MAGIC_1657) % WG_T9_SPAN - WG_T9_HALF 65 let a: i64 = wp_param(x, z, pair) 66 let b: i64 = wp_param(x, z, pair+1) 67 var sa: i64 = 0 68 if a > 0 { sa = 1 } 69 var sb: i64 = 0 70 if b > 0 { sb = 1 } 71 if sa == sb { agree = agree + 1 } 72 s = s + 1 73 } 74 hw(" fields "); pn(pair); hw("~"); pn(pair+1); hw(": sign-agree "); pn(agree); hw("/60\n" as *u8) 75 if agree < 15 { t1 = 0 } 76 if agree > 45 { t1 = 0 } 77 pair = pair + 1 78 } 79 if t1 == 1 { hw("T1 PASS six independent parameter fields (adjacent pairs decorrelated)\n" as *u8) } 80 else { fails=fails+1; hw("T1 FAIL\n" as *u8) } 81 82 // ---- T2 biome from the VECTOR, not height: same-height pair with different biomes ---- 83 var found: i64 = 0 84 var fh: i64 = 0 85 var fb1: i64 = 0 86 var fb2: i64 = 0 87 var i: i64 = 0 88 while i < WG_MAGIC_2000 { 89 if found == 0 { 90 let x1: i64 = (i*WG_MAGIC_1327) % WG_MAGIC_16000 - WG_MAGIC_8000 91 let z1: i64 = (i*WG_MAGIC_2801) % WG_MAGIC_16000 - WG_MAGIC_8000 92 let x2: i64 = (i*WG_MAGIC_3271 + WG_MAGIC_7777) % WG_MAGIC_16000 - WG_MAGIC_8000 93 let z2: i64 = (i*911 + WG_MAGIC_3333) % WG_MAGIC_16000 - WG_MAGIC_8000 94 let h1: i64 = wp_height(x1, z1) 95 let h2: i64 = wp_height(x2, z2) 96 if h1 > 10 { if h2 > 10 { 97 var dh: i64 = h1 - h2 98 if dh < 0 { dh = 0-dh } 99 if dh < 12 { 100 let b1: i64 = wp_biome(x1, z1) 101 let b2: i64 = wp_biome(x2, z2) 102 if b1 >= 3 { if b2 >= 3 { if b1 != b2 { 103 found = 1 104 fh = h1 105 fb1 = b1 106 fb2 = b2 107 } } } 108 } 109 } } 110 } 111 i = i + 1 112 } 113 hw(" same-height different-biome: found="); pn(found); hw(" (h~"); pn(fh); hw(" biomes "); pn(fb1); hw(" vs "); pn(fb2); hw(")\n" as *u8) 114 if found == 1 { hw("T2 PASS biome is a function of the parameter VECTOR, not of height (the anti-height-only proof)\n" as *u8) } 115 else { fails=fails+1; hw("T2 FAIL\n" as *u8) } 116 117 // ---- T3 spline monotone + erosion flattens ---- 118 var mono: i64 = 1 119 var c: i64 = 0-512 120 var prev: i64 = wp_spline(0-512) 121 while c <= 512 { 122 let v: i64 = wp_spline(c) 123 if v < prev { mono = 0 } 124 prev = v 125 c = c + 16 126 } 127 var flatter: i64 = 0 128 var samp: i64 = 0 129 while samp < 40 { 130 let x: i64 = (samp*733) % WG_MAGIC_8000 - WG_MAGIC_4000 131 let z: i64 = (samp*WG_MAGIC_1889) % WG_MAGIC_8000 - WG_MAGIC_4000 132 let base: i64 = wp_spline(200) 133 var mLow: i64 = wp_height_params(200, 0-400, 300, x, z) - base 134 if mLow < 0 { mLow = 0-mLow } 135 var mHigh: i64 = wp_height_params(200, 400, 300, x, z) - base 136 if mHigh < 0 { mHigh = 0-mHigh } 137 if mLow >= mHigh { flatter = flatter + 1 } 138 samp = samp + 1 139 } 140 hw(" spline monotone="); pn(mono); hw(" erosion-flattens "); pn(flatter); hw("/40\n" as *u8) 141 var t3: i64 = 0 142 if mono == 1 { if flatter >= 36 { t3 = 1 } } 143 if t3 == 1 { hw("T3 PASS heights flow through the SPLINE (monotone continents) and EROSION flattens the relief\n" as *u8) } 144 else { fails=fails+1; hw("T3 FAIL\n" as *u8) } 145 146 // ---- T4 the carver is causal geometry: SAME cells, stage on vs off ---- 147 var carved: i64 = 0 148 var antiCarve: i64 = 0 149 var gz: i64 = 0 150 while gz < 64 { 151 var gx: i64 = 0 152 while gx < 64 { 153 let x: i64 = (gx-32)*280 154 let z: i64 = (gz-32)*280 155 wp_set_carve(1) 156 let hOn: i64 = wp_height(x, z) 157 wp_set_carve(0) 158 let hOff: i64 = wp_height(x, z) 159 if hOn < hOff - 8 { carved = carved + 1 } 160 if hOn > hOff + 8 { antiCarve = antiCarve + 1 } 161 gx = gx + 1 162 } 163 gz = gz + 1 164 } 165 wp_set_carve(1) 166 hw(" carver: cells CUT by the river stage="); pn(carved); hw(" (illegal raises="); pn(antiCarve); hw(")\n" as *u8) 167 var t4: i64 = 0 168 if carved > 8 { if antiCarve == 0 { t4 = 1 } } 169 if t4 == 1 { hw("T4 PASS the CARVER stage cuts real rivers (geometry present with the stage on, gone with it off)\n" as *u8) } 170 else { fails=fails+1; hw("T4 FAIL\n" as *u8) } 171 172 // ---- T4b HYDROLOGY: every river flows DOWNHILL and terminates at the sea or a lake ---- 173 var mono: i64 = 1 174 var seaN: i64 = 0 175 var si: i64 = 0 176 while si < wp_hyd_n() { 177 if wp_hyd_stat(si, 1) > wp_hyd_stat(si, 0) { mono = 0 } 178 seaN = seaN + wp_hyd_stat(si, 3) 179 hw(" spring "); pn(si); hw(": bed "); pn(wp_hyd_stat(si,0)); hw("->"); pn(wp_hyd_stat(si,1)); hw(" steps="); pn(wp_hyd_stat(si,2)); hw(" sea="); pn(wp_hyd_stat(si,3)); hw("\n" as *u8) 180 si = si + 1 181 } 182 var t4b: i64 = 0 183 if wp_hyd_n() >= 2 { if mono == 1 { if seaN >= 1 { t4b = 1 } } } 184 if t4b == 1 { hw("T4b PASS rivers are HYDROLOGICAL: monotone downhill beds (water never flows uphill), at least one reaches the SEA\n" as *u8) } 185 else { fails=fails+1; hw("T4b FAIL\n" as *u8) } 186 187 // ---- T4c ALTITUDE LAPSE: snow concentrates on high ground (temperature falls with height) ---- 188 var snowHi: i64 = 0 189 var hiN: i64 = 0 190 var snowLo: i64 = 0 191 var loN: i64 = 0 192 var li: i64 = 0 193 while li < WG_MAGIC_4000 { 194 let x: i64 = (li*WG_MAGIC_1637) % WG_MAGIC_19000 - WG_MAGIC_9500 195 let z: i64 = (li*WG_MAGIC_2411) % WG_MAGIC_19000 - WG_MAGIC_9500 196 let hh: i64 = wp_height_raw(x, z) 197 if hh > 320 { 198 hiN = hiN + 1 199 if wp_biome(x, z) == 4 { snowHi = snowHi + 1 } 200 } 201 if hh > 40 { if hh < 150 { 202 loN = loN + 1 203 if wp_biome(x, z) == 4 { snowLo = snowLo + 1 } 204 } } 205 li = li + 1 206 } 207 hw(" lapse: snow "); pn(snowHi); hw("/"); pn(hiN); hw(" on peaks vs "); pn(snowLo); hw("/"); pn(loN); hw(" in lowland\n" as *u8) 208 var t4c: i64 = 0 209 if hiN > 25 { if snowHi*5 >= hiN*2 { if snowHi*loN > snowLo*hiN*2 { t4c = 1 } } } 210 if t4c == 1 { hw("T4c PASS ALTITUDE LAPSE: snow tops the mountains BECAUSE they are high (not a random patch)\n" as *u8) } 211 else { fails=fails+1; hw("T4c FAIL\n" as *u8) } 212 213 // ---- T5 features respect biome ---- 214 var nTree: i64 = 0 215 var nCact: i64 = 0 216 var nSpru: i64 = 0 217 var nBold: i64 = 0 218 var wrong: i64 = 0 219 gz = 0 220 while gz < 80 { 221 var gx: i64 = 0 222 while gx < 80 { 223 let x: i64 = (gx-40)*180 224 let z: i64 = (gz-40)*180 225 let f: i64 = wp_feature(x, z) 226 if f > 0 { 227 let b: i64 = wp_biome(x, z) 228 if f == 1 { nTree = nTree + 1; if b != 6 { if b != 7 { wrong = wrong + 1 } } } 229 if f == 2 { nCact = nCact + 1; if b != 3 { wrong = wrong + 1 } } 230 if f == 3 { nSpru = nSpru + 1; if b != 4 { wrong = wrong + 1 } } 231 if f == 4 { nBold = nBold + 1; if b != 5 { wrong = wrong + 1 } } 232 } 233 gx = gx + 1 234 } 235 gz = gz + 1 236 } 237 hw(" features: trees="); pn(nTree); hw(" cacti="); pn(nCact); hw(" spruce="); pn(nSpru); hw(" boulders="); pn(nBold); hw(" biome-violations="); pn(wrong); hw("\n" as *u8) 238 var t5: i64 = 0 239 if nTree > 30 { if nCact + nSpru + nBold > 6 { if wrong == 0 { t5 = 1 } } } 240 if t5 == 1 { hw("T5 PASS the FEATURE stage is biome-aware (every placement matches its biome rule; 3+ kinds present)\n" as *u8) } 241 else { fails=fails+1; hw("T5 FAIL\n" as *u8) } 242 243 // ---- T6 determinism + seed variety ---- 244 let bm1: *i64 = sys_mmap(32*32*8) as *i64 245 let bm2: *i64 = sys_mmap(32*32*8) as *i64 246 let bm3: *i64 = sys_mmap(32*32*8) as *i64 247 i = 0 248 while i < WG_MAGIC_1024 { 249 let x: i64 = (i%32 - 16)*260 250 let z: i64 = (i/32 - 16)*260 251 bm1[i] = wp_biome(x, z) 252 i = i + 1 253 } 254 wp_init(1) 255 wp_hydro_bake() 256 i = 0 257 while i < WG_MAGIC_1024 { 258 let x: i64 = (i%32 - 16)*260 259 let z: i64 = (i/32 - 16)*260 260 bm2[i] = wp_biome(x, z) 261 i = i + 1 262 } 263 wp_init(7) 264 wp_hydro_bake() 265 i = 0 266 while i < WG_MAGIC_1024 { 267 let x: i64 = (i%32 - 16)*260 268 let z: i64 = (i/32 - 16)*260 269 bm3[i] = wp_biome(x, z) 270 i = i + 1 271 } 272 wp_init(1) 273 wp_hydro_bake() 274 var same12: i64 = 0 275 var diff13: i64 = 0 276 i = 0 277 while i < WG_MAGIC_1024 { 278 if bm1[i] == bm2[i] { same12 = same12 + 1 } 279 if bm1[i] != bm3[i] { diff13 = diff13 + 1 } 280 i = i + 1 281 } 282 hw(" seed1==seed1: "); pn(same12); hw("/1024 seed1!=seed7: "); pn(diff13); hw("/1024\n" as *u8) 283 var t6: i64 = 0 284 if same12 == WG_MAGIC_1024 { if diff13 > 150 { t6 = 1 } } 285 if t6 == 1 { hw("T6 PASS deterministic per seed + real seed variety\n" as *u8) } 286 else { fails=fails+1; hw("T6 FAIL\n" as *u8) } 287 288 // ---- T7 spawn ---- 289 let sp: *i64 = sys_mmap(24) as *i64 290 let ok1: i64 = wp_spawn(sp) 291 let sx: i64 = sp[0] 292 let sz: i64 = sp[1] 293 let sh: i64 = sp[2] 294 let ok2: i64 = wp_spawn(sp) 295 hw(" spawn: ok="); pn(ok1); hw(" at ("); pn(sx); hw(","); pn(sz); hw(") h="); pn(sh); hw("\n" as *u8) 296 var t7: i64 = 0 297 if ok1 == 1 { if ok2 == 1 { if sp[0] == sx { if sh > 10 { t7 = 1 } } } } 298 if t7 == 1 { hw("T7 PASS SPAWN stage: valid gentle land, deterministic\n" as *u8) } 299 else { fails=fails+1; hw("T7 FAIL\n" as *u8) } 300 301 // ---- T9 LIGHTING stage (F1158) is CAUSAL and does what the palette measurements demanded ---- 302 // off == wp_surface bit-exact; on: sun-facing slopes measurably brighter than opposite AND the 303 // distinct-colour count over a fixed region RISES (the exact number the frame ruler said was 304 // the gap). Same stage-causal pattern as the carver (T4) and features (T5). 305 wp_set_light(0) 306 var same9: i64 = 1 307 var q9: i64 = 0 308 while q9 < 60 { 309 let x9: i64 = (q9 % 8) * 700 - WG_T9_OFF 310 let z9: i64 = (q9 / 8) * 700 - WG_T9_OFF 311 let h9: i64 = wp_height(x9, z9) 312 if wp_shade(x9, z9, h9, 0) != wp_surface(x9, z9, h9, 0) { same9 = 0 } 313 q9 = q9 + 1 314 } 315 wp_set_light(1) 316 // distinct-colour census over a fixed 48x48 sample, lit vs unlit (colour from GEOMETRY, not noise) 317 let pal9: *i64 = sys_mmap(WG_T9_PAL*8) as *i64 318 var lit_n: i64 = 0 319 var unlit_n: i64 = 0 320 var pass9: i64 = 0 321 while pass9 < 2 { 322 if pass9 == 0 { wp_set_light(0) } 323 if pass9 == 1 { wp_set_light(1) } 324 var seen9: i64 = 0 325 var yy9: i64 = 0 326 while yy9 < 48 { 327 var xx9: i64 = 0 328 while xx9 < 48 { 329 let wx9: i64 = xx9*130 - WG_T9_SOFF 330 let wz9: i64 = yy9*130 - WG_T9_SOFF 331 let hh9: i64 = wp_height(wx9, wz9) 332 var sl9: i64 = wp_height(wx9+40, wz9) - hh9 333 if sl9 < 0 { sl9 = 0-sl9 } 334 let c9: i64 = wp_shade(wx9, wz9, hh9, sl9) 335 var k9: i64 = 0 336 var found9: i64 = 0 337 while k9 < seen9 { if pal9[k9] == c9 { found9 = 1; k9 = seen9 } if found9 == 0 { k9 = k9 + 1 } } 338 if found9 == 0 { if seen9 < WG_T9_PAL { pal9[seen9] = c9; seen9 = seen9 + 1 } } 339 xx9 = xx9 + 1 340 } 341 yy9 = yy9 + 1 342 } 343 if pass9 == 0 { unlit_n = seen9 } 344 if pass9 == 1 { lit_n = seen9 } 345 pass9 = pass9 + 1 346 } 347 wp_set_light(1) 348 // sun physics, tested by the stage's OWN gradient: sample d exactly as wp_shade computes it 349 // (height NW-of-here minus here). d>0 must BRIGHTEN vs unlit, d<0 must DARKEN -- both directions 350 // required, so a shader that just brightens everything cannot pass. (First tooth draft demanded 351 // dnw>30 over a 90-unit step and found ZERO pairs -- this terrain's local relief is gentler than 352 // the tooth assumed; the gate's own RED corrected the premise, not the stage.) 353 var bright_ok: i64 = 0 354 var bright_n: i64 = 0 355 var dark_ok: i64 = 0 356 var dark_n: i64 = 0 357 q9 = 0 358 while q9 < 600 { 359 let bx9: i64 = (q9 * WG_T9_PA) % WG_T9_SPAN - WG_T9_HALF 360 let bz9: i64 = (q9 * WG_T9_PB) % WG_T9_SPAN - WG_T9_HALF 361 let hh: i64 = wp_height(bx9, bz9) 362 let d9: i64 = wp_height(bx9-90, bz9-90) - hh 363 if d9 > 8 { if d9 < 91 { bright_n = bright_n + 1 } } 364 if d9 < 0-8 { if d9 > 0-91 { dark_n = dark_n + 1 } } 365 if d9 > 8 { if d9 < 91 { 366 let lit: i64 = wp_shade(bx9, bz9, hh, 0) 367 wp_set_light(0) 368 let unl: i64 = wp_shade(bx9, bz9, hh, 0) 369 wp_set_light(1) 370 let lb: i64 = (lit % 256) + (lit/256) % 256 + (lit/WG_MAGIC_65536) % 256 371 let ub: i64 = (unl % 256) + (unl/256) % 256 + (unl/WG_MAGIC_65536) % 256 372 if lb > ub { bright_ok = bright_ok + 1 } 373 } } 374 if d9 < 0-8 { if d9 > 0-91 { 375 let lit2: i64 = wp_shade(bx9, bz9, hh, 0) 376 wp_set_light(0) 377 let unl2: i64 = wp_shade(bx9, bz9, hh, 0) 378 wp_set_light(1) 379 let lb2: i64 = (lit2 % 256) + (lit2/256) % 256 + (lit2/WG_MAGIC_65536) % 256 380 let ub2: i64 = (unl2 % 256) + (unl2/256) % 256 + (unl2/WG_MAGIC_65536) % 256 381 if lb2 < ub2 { dark_ok = dark_ok + 1 } 382 } } 383 q9 = q9 + 1 384 } 385 var t9: i64 = 0 386 if same9 == 1 { if lit_n * 2 >= unlit_n * 3 { 387 if bright_n > 10 { if dark_n > 10 { 388 if bright_ok * 10 >= bright_n * 7 { if dark_ok * 10 >= dark_n * 7 { t9 = 1 } } } } } } 389 hw(" light: unlit-colours="); pn(unlit_n); hw(" lit-colours="); pn(lit_n) 390 hw(" sunward-brighter "); pn(bright_ok); hw("/"); pn(bright_n) 391 hw(" shadeward-darker "); pn(dark_ok); hw("/"); pn(dark_n); hw("\n" as *u8) 392 if t9 == 1 { hw("T9 PASS LIGHTING stage: causal toggle, colour count rises >=1.5x from GEOMETRY, sun-facing brightens AND shade-facing darkens\n" as *u8) } 393 else { fails=fails+1; hw("T9 FAIL lighting stage\n" as *u8) } 394 395 // ---- T8 evidence: biome map (left) + 3D staged world (right) ---- 396 let GW: i64 = MAPW + HERW 397 let gal: *i64 = sys_mmap(GW*GH*8) as *i64 398 clearfb(gal, GW*GH, 20 + 24*256 + 38*WG_MAGIC_65536) 399 // biome map: world span +-9900 400 var py: i64 = 0 401 while py < MAPW { 402 var px: i64 = 0 403 while px < MAPW { 404 let x: i64 = (px - 180)*55 405 let z: i64 = (py - 180)*55 406 let b: i64 = wp_biome(x, z) 407 var col: i64 = 96 + 150*256 + 60*WG_MAGIC_65536 408 if b == 0 { col = 24 + 70*256 + 165*WG_MAGIC_65536 } 409 if b == 1 { col = 216 + 196*256 + 140*WG_MAGIC_65536 } 410 if b == 2 { col = 52 + 118*256 + 196*WG_MAGIC_65536 } 411 if b == 3 { col = 228 + 200*256 + 120*WG_MAGIC_65536 } 412 if b == 4 { col = 232 + 236*256 + 244*WG_MAGIC_65536 } 413 if b == 5 { col = 130 + 124*256 + 120*WG_MAGIC_65536 } 414 if b == 6 { col = 52 + 110*256 + 44*WG_MAGIC_65536 } 415 gal[py*GW + px] = col 416 px = px + 1 417 } 418 py = py + 1 419 } 420 // spawn marker: white cross 421 let mx: i64 = sx/55 + 180 422 let mz: i64 = sz/55 + 180 423 var d: i64 = 0-4 424 while d <= 4 { 425 if mx+d >= 0 { if mx+d < MAPW { gal[mz*GW + mx+d] = 255 + 255*256 + 255*WG_MAGIC_65536 } } 426 if mz+d >= 0 { if mz+d < MAPW { gal[(mz+d)*GW + mx] = 255 + 255*256 + 255*WG_MAGIC_65536 } } 427 d = d + 1 428 } 429 // 3D hero: terrain 96x96 spacing 110 + biome features 430 tm_reset() 431 tm_set_spec(0) 432 tm_set_tex(0) 433 tm_set_image(0 as *u8, 0, 0) 434 let TN: i64 = 97 435 let SP: i64 = 110 436 let terrFrom: i64 = tm_nv() 437 gz = 0 438 while gz < TN { 439 var gx: i64 = 0 440 while gx < TN { 441 let wx: i64 = (gx - 48)*SP 442 let wz: i64 = (gz - 48)*SP 443 var h: i64 = wp_height(wx, wz) 444 let slope: i64 = wp_iabs(wp_height(wx+SP, wz) - h) + wp_iabs(wp_height(wx, wz+SP) - h) 445 let col: i64 = wp_shade(wx, wz, h, slope) // T8 evidence renders the LIT world (F1158) 446 if h < 0-14 { h = 0-14 } // water reads as a shallow blue floor 447 let vi: i64 = tm_vert(wx, h, wz) 448 tm_vcol(vi, col) 449 gx = gx + 1 450 } 451 gz = gz + 1 452 } 453 gz = 0 454 while gz < TN-1 { 455 var qx: i64 = 0 456 while qx < TN-1 { 457 let v0: i64 = terrFrom + gz*TN + qx 458 tm_quad(v0, v0+1, v0+TN+1, v0+TN, 0) 459 qx = qx + 1 460 } 461 gz = gz + 1 462 } 463 // features over the same span (cell step 220) 464 var fz: i64 = 0 465 while fz < 48 { 466 var fx: i64 = 0 467 while fx < 48 { 468 let wx: i64 = (fx - 24)*220 469 let wz: i64 = (fz - 24)*220 470 let f: i64 = wp_feature(wx, wz) 471 if f > 0 { 472 let h: i64 = wp_height(wx, wz) 473 let ffrom: i64 = tm_nv() 474 if f == 1 { 475 tm_cube(wx, h+60, wz, 26, 96+72*256+46*WG_MAGIC_65536) 476 tm_pyramid(wx, h+210, wz, 130, 42+96*256+40*WG_MAGIC_65536) 477 var pi: i64 = ffrom 478 while pi < ffrom+8 { tm_vcol(pi, 96+72*256+46*WG_MAGIC_65536); pi = pi + 1 } 479 while pi < tm_nv() { tm_vcol(pi, 42+96*256+40*WG_MAGIC_65536); pi = pi + 1 } 480 } 481 if f == 2 { 482 tm_cube(wx, h+95, wz, 34, 60+150*256+70*WG_MAGIC_65536) 483 var pi: i64 = ffrom 484 while pi < tm_nv() { tm_vcol(pi, 60+150*256+70*WG_MAGIC_65536); pi = pi + 1 } 485 } 486 if f == 3 { 487 tm_cube(wx, h+50, wz, 20, 88+66*256+44*WG_MAGIC_65536) 488 tm_pyramid(wx, h+230, wz, 150, 210+220*256+230*WG_MAGIC_65536) 489 var pi: i64 = ffrom 490 while pi < ffrom+8 { tm_vcol(pi, 88+66*256+44*WG_MAGIC_65536); pi = pi + 1 } 491 while pi < tm_nv() { tm_vcol(pi, 210+220*256+230*WG_MAGIC_65536); pi = pi + 1 } 492 } 493 if f == 4 { 494 tm_cube(wx, h+42, wz, 44, 128+122*256+116*WG_MAGIC_65536) 495 var pi: i64 = ffrom 496 while pi < tm_nv() { tm_vcol(pi, 128+122*256+116*WG_MAGIC_65536); pi = pi + 1 } 497 } 498 } 499 fx = fx + 1 500 } 501 fz = fz + 1 502 } 503 tm_compute_normals() 504 tm_place(0, tm_nv(), 0, 0-480, 0, 1000) 505 tm_set_sun(340, 780, 0-300) 506 tm_shadow_bake() 507 tm_set_tex(64) 508 tm_set_shadow(1) 509 hw(" hero: verts="); pn(tm_nv()); hw(" tris="); pn(tm_nt()); hw(" ovf="); pn(tm_ovf()); hw("\n" as *u8) 510 let npx: i64 = HERW*GH 511 let hero: *i64 = sys_mmap(npx*8) as *i64 512 clearfb(hero, npx, 30 + 40*256 + 58*WG_MAGIC_65536) 513 trimesh_render_aa(hero, HERW, GH, 620, 0-280, WG_MAGIC_5900, 560, 2) 514 py = 0 515 while py < GH { 516 var px: i64 = 0 517 while px < HERW { gal[py*GW + MAPW + px] = hero[py*HERW + px]; px = px + 1 } 518 py = py + 1 519 } 520 write_png(gal, GW, GH, "knowledge/nx_worldpipe.png" as *u8) 521 hw("T8 evidence -> knowledge/nx_worldpipe.png (biome/continent map + staged 3D world)\n" as *u8) 522 523 if fails == 0 { hw("WORLDPIPE-GATE verdict=GREEN -- R5: the STAGED six-parameter pipeline is real (params -> spline -> relief/erosion -> carver -> vector-biomes -> surface -> biome-features -> spawn), each stage causally proven. Residual vs the banked curriculum: structures stage, 3D density/overhangs (depth param). Lighting stage LANDED 2026-07-26 (T9).\n" as *u8); sys_exit(0); return 0 } 524 hw("WORLDPIPE-GATE RED fails="); pn(fails); hw("\n" as *u8) 525 sys_exit(1) 526 return 1 527}