Let the water on the road actually run, and gate it
surf_japan.js declared `function water` twice at one scope. Declarations do not shadow by position — the last one hoists and wins — so every call from the road reached the canal's five-argument painter with ed, L and lod missing, `w` came out NaN, `w > 0.20` was false, and the standing water field had been unreachable since the day it was written. The README calls that branch the single most valuable thing the file does. It was worse than dead. The canal painter assigns before it returns, so `mirNow` was set to NaN and the wet-earth branch copied that onto every carriageway cell; raycast.js's `if (m < 0.06) continue` does not reject NaN, so those cells entered the reflect pass and were blanked instead of skipped. The field function is now `puddle` and the two names no longer collide. Turning a dead branch on is not a bug fix on its own — it is a new feature entering the photosensitivity budget, and nothing in there had ever executed, including the `rip` rate whose comment tunes it from 2.4 to 0.6 "because at 2.4 a downpour drove it to 4.5 Hz". That number had been argued and never measured. tools/road-flicker.cjs measures it: canal-flicker's method, walked clear of the channel, scoring only floor cells and running the wet presets, because a dry row would report a confident zero for a feature that was not on screen. It passes at 0.20/s and 0.37% in band against 1.00/s and 2.00%, with reduced motion exactly still, so the reasoning held. The census is the price. Edo moves about a point at every hour, because a wet road is mid-luminance nearly everywhere and that is the muddy band by definition. The README table and the note under it say so. sakura-flicker's verdict line now names which rule a number is under, which its own header already required of whoever quotes it. A big-step rate is not a flash rate: the drift's 1.00/s is about half a hertz of switching on one cell, an object crossing it, where the band this project rules on starts at 3 Hz — and that figure reads 1.21% against a cap of 2.00%. The drift is left alone, because the measurement says the thing it is close to is not the thing that does harm.
This commit is contained in:
parent
20dab1e5dd
commit
f67b268f1d
6 changed files with 168 additions and 10 deletions
30
CONTRACT.md
30
CONTRACT.md
|
|
@ -226,11 +226,37 @@ what each world actually measures at each hour.
|
|||
|
||||
The gates, in the order they are worth running: `node build.js`, `node tools/domshim.cjs`,
|
||||
`node tools/flicker-rate.cjs`, `node tools/lightning-rate.cjs`, `node tools/west-flicker.cjs 4`,
|
||||
`node tools/canal-flicker.cjs`, `node tools/sakura-flicker.cjs 10`,
|
||||
`node tools/sakura-flicker.cjs 10 jp-blossom --cells=4`,
|
||||
`node tools/canal-flicker.cjs`, `node tools/road-flicker.cjs`,
|
||||
`node tools/sakura-flicker.cjs 10`, `node tools/sakura-flicker.cjs 10 jp-blossom --cells=4`,
|
||||
the census, and a determinism check (the same seed, frame, world and hour rendered twice must be
|
||||
byte-identical).
|
||||
|
||||
THE THIRD TIME THIS RULE BIT, AND THE FIRST TIME IT BIT A FEATURE THAT WAS NOT RUNNING AT ALL.
|
||||
`surf_japan.js` declared `function water` twice at one scope. Declarations do not shadow by
|
||||
position — the last one hoists and wins — so every call from the road reached the CANAL's
|
||||
five-argument painter with three arguments missing, `w` came out NaN, and the entire standing
|
||||
water branch was unreachable for its whole life. It was worse than dead: the canal painter
|
||||
assigns `mirNow` before it returns, so NaN was copied onto every carriageway cell, and
|
||||
raycast.js's `if (m < 0.06) continue` does not reject NaN — those cells entered the reflect
|
||||
pass and were blanked rather than skipped.
|
||||
|
||||
WHAT THE GATES SAID WHILE THAT WAS TRUE IS THE POINT. Every probe passed, every census was
|
||||
in budget, and 27 fixtures were byte-identical, because a feature that never executes cannot
|
||||
fail a measurement. A GATE CANNOT SEE A BRANCH THAT DOES NOT RUN, so the branch's own
|
||||
reasoning goes unchecked with it: the `rip` rate in there carries a comment tuning it from
|
||||
2.4 to 0.6 "because at 2.4 a downpour drove it to 4.5 Hz", a number that had been argued
|
||||
and never once measured. Turning the branch on is therefore not a bug fix on its own — it is
|
||||
a new feature entering the photosensitivity budget, and it needs a probe that can see it
|
||||
before it may ship. `tools/road-flicker.cjs` is that probe.
|
||||
|
||||
A PROBE DOES NOT HAVE TO WALK TO BE A GATE, which is the corollary and is worth stating so the
|
||||
pattern is not cargo-culted. The cherry and the canal are somewhere, so their probes walk. The
|
||||
road is underfoot everywhere, so road-flicker pins at the start pose on some seeds and that is
|
||||
not blindness. What makes it a gate the others are not is that it scores ONLY floor cells and
|
||||
runs the WET presets — the cell selection and the conditions, not the pose. It prints a lit
|
||||
count per row for exactly that reason: that is the number saying the road in shot had water on
|
||||
it.
|
||||
|
||||
A GATE THAT CANNOT SEE THE FEATURE IS NOT A GATE, and this is the newest hard-won rule here. Both
|
||||
photosensitivity tools PIN THE CAMERA at the map's start, so anything the walk only reaches later is
|
||||
invisible to them: EDO's canal is on a 160 m pitch, and `west-flicker.cjs` returned PASS having
|
||||
|
|
|
|||
12
README.md
12
README.md
|
|
@ -94,8 +94,15 @@ and it moves the other way. Both, measured at 200x60 on frame 300 at two seeds,
|
|||
| **frontier** seed 7 | 26.5 / 0.24 | 38.7 / 1.03 | 40.9 / 7.16 |
|
||||
| **Moonwalk** seed 42 | 5.5 / 1.64 | 6.6 / 2.27 | 5.0 / 2.85 |
|
||||
| **Moonwalk** seed 7 | 11.8 / 1.27 | 7.2 / 3.88 | 6.2 / 3.60 |
|
||||
| **Edo** seed 42 | 36.3 / 0.70 | 43.8 / 3.08 | 51.6 / 3.23 |
|
||||
| **Edo** seed 7 | 29.5 / 0.03 | 34.9 / 2.23 | 44.7 / 1.17 |
|
||||
| **Edo** seed 42 | 37.1 / 0.70 | 44.8 / 3.06 | 52.5 / 3.23 |
|
||||
| **Edo** seed 7 | 30.1 / 0.03 | 36.0 / 2.11 | 45.6 / 1.17 |
|
||||
|
||||
Edo's row moved about a point at every hour when the standing water on its road started
|
||||
working. The puddle field had been unreachable since it was written — a duplicate function name
|
||||
meant every call from the road landed on the canal painter — so the numbers above it were taken
|
||||
from a world whose largest wet surface was never drawn. A wet road is mid-luminance almost
|
||||
everywhere, which is the muddy band by definition, and that is the honest price of the feature
|
||||
existing.
|
||||
|
||||
Four things in that table are worth saying out loud rather than leaving for someone to notice.
|
||||
|
||||
|
|
@ -539,6 +546,7 @@ Everything here runs without a browser, which is how the thing gets verified at
|
|||
| `tools/lightning-rate.cjs` | the same, for storms |
|
||||
| `tools/west-flicker.cjs` | the same, for every world that is not the city — pinned camera, per cell, against the city as its baseline |
|
||||
| `tools/canal-flicker.cjs` | the same, for Edo's canal — pins the camera **on the water**, which the gate above structurally cannot do |
|
||||
| `tools/road-flicker.cjs` | the same, for the standing water on Edo's road — walks clear of the channel, scores only floor cells, and runs the wet presets, because the puddle field is only there when the world is wet |
|
||||
| `tools/sakura-flicker.cjs` | the same, for the cherry — **walks** until the element's own cells PRINT in the frame, then pins, and scores only those cells. `[seconds] [element] [--cells=n] [--time=]`, and a verdict is only taken at the 10 s reference window. Run it twice: `10` for the crown and `10 jp-blossom --cells=4` for the drift |
|
||||
| `tools/domshim.cjs` | runs the built page against a fake DOM — boot, resize, input, worlds, tab loss |
|
||||
|
||||
|
|
|
|||
|
|
@ -3124,7 +3124,7 @@ var CC = (function () {
|
|||
return ROUT;
|
||||
}
|
||||
|
||||
function water(wx, wz) {
|
||||
function puddle(wx, wz) {
|
||||
var a = vnoise(wx * 0.62, wz * 0.41 + 11.3);
|
||||
var b = vnoise(wx * 1.9 + 5.1, wz * 1.4);
|
||||
var n = a * 0.7 + b * 0.3;
|
||||
|
|
@ -3217,7 +3217,7 @@ var CC = (function () {
|
|||
|
||||
var rut = Math.abs(al - half * 0.52);
|
||||
var inRut = rut < 0.42;
|
||||
var w = water(wx, wz) * (inRut ? 1.35 : 0.82) * clamp(0.4 + 0.8 * wWet, 0, 1.4);
|
||||
var w = puddle(wx, wz) * (inRut ? 1.35 : 0.82) * clamp(0.4 + 0.8 * wWet, 0, 1.4);
|
||||
|
||||
if (w > 0.20) {
|
||||
|
||||
|
|
|
|||
|
|
@ -818,8 +818,18 @@
|
|||
* lattice, thresholded — so a puddle has an EDGE, which is what makes it read as water rather
|
||||
* than as a wet patch — and the threshold moves with how wet the world is, so a road under
|
||||
* `kiri` has a few pools in the ruts and a road under `typhoon` is a sheet. Keyed on world
|
||||
* coordinates alone, so it holds still while the camera walks through it. */
|
||||
function water(wx, wz) {
|
||||
* coordinates alone, so it holds still while the camera walks through it.
|
||||
*
|
||||
* IT IS CALLED `puddle` AND NOT `water` BECAUSE THE CANAL PAINTER BELOW IS ALSO CALLED water,
|
||||
* AND THAT COLLISION MADE THIS WHOLE BRANCH DEAD CODE. Two function declarations at one scope
|
||||
* do not shadow by position — the LAST one hoists and wins — so every call to `water(wx, wz)`
|
||||
* from the road reached the canal's five-argument painter with ed, L and lod undefined. It
|
||||
* returned the ROUT object, `w` came out NaN, `w > 0.20` was false, and the standing water was
|
||||
* never drawn anywhere in the world. Worse than dead: the canal painter assigns before it
|
||||
* returns, so `mirNow` was set to NaN and the wet-earth branch below copied that onto every
|
||||
* carriageway cell, where raycast.js's `if (m < 0.06) continue` does not reject NaN and the
|
||||
* reflect pass blanked the cell instead of skipping it. */
|
||||
function puddle(wx, wz) {
|
||||
var a = vnoise(wx * 0.62, wz * 0.41 + 11.3);
|
||||
var b = vnoise(wx * 1.9 + 5.1, wz * 1.4);
|
||||
var n = a * 0.7 + b * 0.3;
|
||||
|
|
@ -1044,7 +1054,7 @@
|
|||
* standing water reading as random blobs and makes it read as a road that has been used. */
|
||||
var rut = Math.abs(al - half * 0.52);
|
||||
var inRut = rut < 0.42;
|
||||
var w = water(wx, wz) * (inRut ? 1.35 : 0.82) * clamp(0.4 + 0.8 * wWet, 0, 1.4);
|
||||
var w = puddle(wx, wz) * (inRut ? 1.35 : 0.82) * clamp(0.4 + 0.8 * wWet, 0, 1.4);
|
||||
|
||||
if (w > 0.20) {
|
||||
/* WATER. The mirror strength is the payoff of the whole world and it is capped well under 1:
|
||||
|
|
|
|||
103
tools/road-flicker.cjs
Normal file
103
tools/road-flicker.cjs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/* canal-flicker's method, aimed at the STANDING WATER ON THE ROAD.
|
||||
*
|
||||
* WHY THIS FILE EXISTS. The road's puddle field was dead code for its whole life: surf_japan.js
|
||||
* declared `function water` twice at one scope, the canal painter hoisted over the field, and
|
||||
* every call from the road reached it with three arguments missing and got NaN back. Nothing in
|
||||
* the branch had ever run — including its `rip` term, whose rate the comment above it says was
|
||||
* tuned down from 2.4 to 0.6 "because at 2.4 a downpour drove it to 4.5 Hz" and the caster floors
|
||||
* the offset into a whole row. That tuning was done against a branch that could not execute, so
|
||||
* the number was reasoned about and never measured. Turning the branch on without a gate that can
|
||||
* see it would be shipping an unmeasured time-varying reflection into a photosensitivity budget.
|
||||
*
|
||||
* WHY NEITHER SHIPPED PROBE COVERS IT. canal-flicker walks until it is a stated distance FROM THE
|
||||
* CHANNEL, so its floor is mostly canal; west-flicker sees the road but scores the whole frame at
|
||||
* once, in the schedule's own weather, and reports one number per world. This one walks clear of
|
||||
* the channel, scores ONLY the floor cells, and runs the wet presets.
|
||||
*
|
||||
* AND THE WALK IS NOT THE POINT HERE, WHICH IS WORTH SAYING PLAINLY BECAUSE THE SIBLING PROBES ARE
|
||||
* BUILT THE OTHER WAY ROUND. A cherry and a canal are somewhere; the road is underfoot everywhere,
|
||||
* so two of the six rows below pin at frame 0 and that is not the blindness CONTRACT.md warns
|
||||
* about — it is the feature being where the camera already stands. What makes this a gate the
|
||||
* others are not is the CELL SELECTION and the WEATHER, not the pose. The lit count per row is
|
||||
* printed for that reason: it is the number that says the road in shot actually had water on it.
|
||||
*
|
||||
* The rows are run in the wet presets on purpose. `w` scales with wWet and the branch's threshold
|
||||
* moves with it, so a dry row measures a road with no water in it and would report a confident
|
||||
* 0.00 for a feature that was not on screen — the failure CONTRACT.md's newest rule is about. The
|
||||
* reduced-motion row must come back exactly still: `rp` is gated on CC.reducedMotion at source.
|
||||
*
|
||||
* node tools/road-flicker.cjs
|
||||
*/
|
||||
const R=require('path').join(__dirname,'..')+'/',fs=require('fs');
|
||||
global.CC=require(R+'src/core.js');global.window=undefined;
|
||||
['world','proj','daylight','weather_state','city','surfaces','raycast','control'].forEach(m=>require(R+'src/'+m+'.js'));
|
||||
fs.readdirSync(R+'src').sort().forEach(p=>{if(/^surf_.*\.js$/.test(p))require(R+'src/'+p)});
|
||||
fs.readdirSync(R+'src/elements').sort().forEach(p=>require(R+'src/elements/'+p));
|
||||
const COLS=120,ROWS=40,WARM=360,NF=WARM+600,PROBES=[3.5,5,7,9,12,15,19];
|
||||
const BIG=255/3, RATE_CAP=1.00, BAND_CAP=2.00;
|
||||
function goertzel(x,f){const n=x.length,w=2*Math.PI*f/60,c=2*Math.cos(w);let s1=0,s2=0,m=0;
|
||||
for(let i=0;i<n;i++)m+=x[i];m/=n;
|
||||
for(let i=0;i<n;i++){const v=(x[i]-m)*(0.5-0.5*Math.cos(2*Math.PI*i/(n-1)));const s0=v+c*s1-s2;s2=s1;s1=s0;}
|
||||
return 2*Math.sqrt(s1*s1+s2*s2-c*s1*s2)/n;}
|
||||
function run(preset,seed,reduced){
|
||||
CC.World.force('japan'); CC.reducedMotion=!!reduced;
|
||||
const city=CC.City.make(seed); CC.Daylight.init(city); CC.Weather.init(city); CC.Control.reset();
|
||||
const live=CC.ELEMENTS.filter(e=>CC.inWorld(e,'japan')).sort((a,b)=>(a.layer|0)-(b.layer|0));
|
||||
const rng=CC.mulberry(seed^0x9e3779b9);
|
||||
for(const el of live) if(el.init) el.init(city,rng,{cols:COLS,rows:ROWS});
|
||||
const cam={x:city.startX,z:city.startZ,yaw:0,eyeY:1.7,fov:1.25,horizon:ROWS*0.56,cellAspect:0.5625,rows:ROWS,t:0};
|
||||
/* Walk until the channel is well out of range, so the floor in shot is road and not water.
|
||||
The weather is stamped during the walk as well as during the window: the puddle threshold
|
||||
moves with wWet, so a pose found in drizzle is not the pose that has pools in it. */
|
||||
let found=false,pin=0;
|
||||
for(let k=0;k<40000;k++){const t=k/60;
|
||||
if(!CC.Weather.P.forced)CC.Weather.set(preset,t);
|
||||
CC.Daylight.update(1/60,t);CC.Weather.update(1/60,t);CC.Control.update(1/60,t,cam,city);
|
||||
if(city.rivD(cam.x,cam.z)>28){found=true;pin=k;break;}}
|
||||
if(!found) return null;
|
||||
const drawn=live.filter(e=>e.world&&CC.inWorld(e,'japan')&&!CC.inWorld(e,'cyber'));
|
||||
const f=CC.makeFrame(COLS,ROWS),N=COLS*ROWS,keep=NF-WARM,s=new Uint8Array(N*keep);
|
||||
for(let k=0;k<NF;k++){const t=(pin+k)/60;
|
||||
if(!CC.Weather.P.forced)CC.Weather.set(preset,t);
|
||||
CC.Daylight.update(1/60,t);CC.Weather.update(1/60,t);
|
||||
for(const el of live) if(el.update) el.update(1/60,t,cam);
|
||||
cam.t=t;CC.clearFrame(f);CC.Cast.render(f,cam,city);
|
||||
for(const el of drawn) if(el.draw) el.draw(f,cam,t);
|
||||
if(CC.Compose&&CC.Compose.post)CC.Compose.post(f,cam,t);
|
||||
if(k>=WARM){const b=(k-WARM)*N;for(let i=0;i<N;i++)s[b+i]=f.lum[i];}
|
||||
}
|
||||
/* The road is the FLOOR below the horizon, which is what kind 2 means here. */
|
||||
let road=0,lit=0;const isRoad=new Uint8Array(N);
|
||||
for(let i=0;i<N;i++){const rz=(i/COLS)|0; if(f.kind[i]===2&&rz>ROWS*0.56){isRoad[i]=1;road++;}}
|
||||
let big=0,band=0,worst=0;const x=new Float64Array(keep);
|
||||
for(let i=0;i<N;i++){ if(!isRoad[i]) continue;
|
||||
let b=0,mx=0,prev=s[i];x[0]=prev;let anyLit=0;
|
||||
for(let k=1;k<keep;k++){const v=s[k*N+i],d=Math.abs(v-prev);if(d>mx)mx=d;if(d>BIG)b++;prev=v;x[k]=v;}
|
||||
for(let k=0;k<keep;k++) if(s[k*N+i]>=9){anyLit=1;break;}
|
||||
lit+=anyLit;
|
||||
if(mx>worst)worst=mx;
|
||||
const r=b/(keep/60); if(r>big)big=r;
|
||||
for(const pf of PROBES){const a=goertzel(x,pf); if(a>band)band=a;}
|
||||
}
|
||||
return {road,lit,worst:100*worst/255,big,band:100*band/255,pin};
|
||||
}
|
||||
console.log(`road puddle rate gate — ${COLS}x${ROWS}, ${(NF-WARM)/60}s measured, ${WARM} discarded, pinned >28 m from the channel\n`);
|
||||
const rows=[];
|
||||
for(const seed of [42,3,404]) for(const p of ['tsuyu','typhoon']){
|
||||
const r=run(p,seed,false); rows.push(r);
|
||||
console.log(` seed ${String(seed).padStart(4)} ${p.padEnd(8)}` + (!r ? '(never left the channel)' :
|
||||
`roadCells ${String(r.road).padStart(4)}(${String(r.lit).padStart(4)} lit) worstStep ${r.worst.toFixed(1).padStart(5)}% ` +
|
||||
`bigSteps ${r.big.toFixed(2).padStart(5)}/s 3-20Hz ${r.band.toFixed(2).padStart(5)}% pinned f${r.pin}`));
|
||||
}
|
||||
const rm=run('typhoon',42,true);
|
||||
console.log(`\n reduced motion: ` + (!rm ? '(not reached)' :
|
||||
`roadCells ${rm.road} worstStep ${rm.worst.toFixed(1)}% bigSteps ${rm.big.toFixed(2)}/s 3-20Hz ${rm.band.toFixed(2)}%`));
|
||||
const seen=rows.filter(r=>r&&r.lit>0);
|
||||
if(!seen.length){console.log('\nRESULT: NOT_MEASURED — no pose put lit road in frame; this is the probe failing, not a PASS');process.exit(3);}
|
||||
const wBig=Math.max(...seen.map(r=>r.big)),wBand=Math.max(...seen.map(r=>r.band));
|
||||
const rmBad=rm&&(rm.big>0||rm.band>0.5);
|
||||
const bad=(wBig>RATE_CAP?` big steps ${wBig.toFixed(2)}/s over ${RATE_CAP.toFixed(2)}/s`:'')+
|
||||
(wBand>BAND_CAP?` 3-20Hz ${wBand.toFixed(2)}% over ${BAND_CAP.toFixed(2)}%`:'')+
|
||||
(rmBad?' reduced motion is not still':'');
|
||||
console.log(`\nRESULT: ${bad?'FAIL'+bad:'PASS'} (worst big steps ${wBig.toFixed(2)}/s, worst 3-20Hz ${wBand.toFixed(2)}%, ${seen.length}/${rows.length} rows measured)`);
|
||||
process.exit(bad?1:0);
|
||||
|
|
@ -332,8 +332,18 @@ if (thin.length) {
|
|||
const wBig = Math.max(...seen.map(r => r.big)), wBand = Math.max(...seen.map(r => r.band));
|
||||
const rmBad = !rm.notFound && (rm.big > 0 || rm.band > 0.5);
|
||||
const judging = SECONDS === REF_WINDOW;
|
||||
/* A BIG-STEP RATE IS NOT A FLASH RATE, and the RESULT line has to say so or the two get quoted
|
||||
as if they were the same number. `big` counts frame-to-frame jumps over 85/255 on the worst
|
||||
cell, so a rate of r/s is about r/2 on-off events a second: the drift's 1.00/s is roughly half
|
||||
a hertz, an object crossing a cell, and the flash band this project actually rules on starts at
|
||||
3 Hz — which is what the separate 3-20 Hz figure measures. RATE_CAP is this file's house limit
|
||||
at an eighth of west-flicker's 8.0/s backstop, and the header above already says to name which
|
||||
rule a failure is under; until now the verdict line did not. */
|
||||
const impliedHz = wBig / 2;
|
||||
const bad = judging
|
||||
? ((wBig > RATE_CAP ? ` big steps ${wBig.toFixed(2)}/s over ${RATE_CAP.toFixed(2)}/s` : '') +
|
||||
? ((wBig > RATE_CAP ? ` big steps ${wBig.toFixed(2)}/s over this file's house limit of ` +
|
||||
`${RATE_CAP.toFixed(2)}/s (~${impliedHz.toFixed(2)} Hz of switching; the project's own ` +
|
||||
`backstop is 8.0/s and its flash band starts at 3 Hz)` : '') +
|
||||
(wBand > BAND_CAP ? ` 3-20Hz ${wBand.toFixed(2)}% over ${BAND_CAP.toFixed(2)}%` : '') +
|
||||
(rmBad ? ' reduced motion is not still' : ''))
|
||||
: '';
|
||||
|
|
@ -342,6 +352,7 @@ const wLit = Math.min(...seen.map(r => r.lit)); // the thinnest row a verdict
|
|||
console.log(`\nRESULT: ${!judging ? 'NOT_JUDGED' : bad ? 'FAIL' + bad : 'PASS'} ` +
|
||||
`(worst big steps ${wBig.toFixed(2)}/s, worst 3-20Hz ${wBand.toFixed(2)}%` +
|
||||
`${judging ? '' : `; both PRINTED NOT JUDGED — a verdict is only taken at the ${REF_WINDOW}s reference window`}` +
|
||||
`, i.e. ~${impliedHz.toFixed(2)} Hz of switching on the worst cell` +
|
||||
`, over a ${SECONDS}s window; thinnest row ${wLit} lit cells; ${walked}/${seen.length} rows walked off the start pose` +
|
||||
`${rm.notFound ? '; reduced-motion row found nothing — frozen by design, NOT a measured pass' : ''})`);
|
||||
if (!judging) process.exit(3);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue