CyberCity/tools/peds.cjs
MiguelCarino 63fe882f3f Aerial traffic, police, ads, street market
Four new elements: skylanes (flying cars in lanes over the street
grid, three altitudes), police (patrol cars, a parked one with the bar
running, officers, checkpoints), ads (billboards at storey scale, not
shopfront scale - signage.js already owns that), market (stall rows,
kiosks, vending banks). Ground floor units now roll a store type so a
laundry doesn't look like a bar, and the crowd got visors, scarves,
cloaks and a few more archetypes. 38 -> 42 elements.

Wider pavement while I was in there. 1.4m -> 2.15m, moved to CC.PAVE
because three files had it written out separately and street.js was
laying people out against a kerb that wasn't where raycast drew it.
Cars were taking their lane offset from the building line too, so at
2.15 they'd have driven down the pavement.

flicker-rate.cjs was only testing neon/shopSpill/signals/holo. That
list was written when signage was the only thing that blinked, so
everything added since has been invisible to it and every PASS I've
been quoting was about the wrong elements. Added the new ones and it
failed immediately:

  - police kept moving under reducedMotion. Not the strobe, that was
    fine - a parked car spawn timer counting down with the camera
    frozen, so a whole car switched on at t=4.00 in a still frame.
    Fixing that showed officers were spawning 30-42m out and needing
    to walk into the 26m draw gate, which they can't do at k=0, so
    the element was 8 cells of lightbar and no people.
  - skylanes never stopped either. Positions are a pure function of t
    (which is what makes it scrub-safe), so reducedMotion never got a
    say. Needed a substituted clock, not a flag.
  - ads stepped 96.5% of full scale in one cell on a content cut.

mist now reports NOT_APPLICABLE instead of PASS. That's right -
skylanes switches itself off in fog so there's nothing to measure
there, and the tool won't score an empty set as a pass. Documented it
at the NAMES line so nobody "fixes" it later.

Print budget: muddy 31.6 -> 28.0 (under the <30 target for the first
time), hot 4.83 -> 4.20. Most of that came from finding three
branches in surfaces.js painting 7.3% of every frame below the
visibility floor - the frame was paying for them and rendering black,
and they were masking the light shafts on top of it. Spent some of the
headroom lifting the spandrel and dead-glass tiers into visibility,
which is the trade those comments had been asking for since the
exposure refit.

Size budget 300k -> 420k. The comment there said cut content instead
of moving the line, which was the right rule when it was written and
is the wrong one for a commit whose entire purpose is more content.
Left the old paragraph in place above the override rather than quietly
rewording it. 365k raw, 100k gzipped.

Not fixed: azure is 1.7 points down, just past the +/-1.5 I'd set for
a pillar. Per-frame hot still swings 0.9-13.7% across seeds, which is
old (10.8% before this) but slightly worse now. blank is up to 47.5%
though about 7 points of that is the invisible paint going away.

tools/peds.cjs is new - runs the crowd against an empty frame with no
city, because a costume whose spans collapse draws nothing, costs no
cells and throws no error. Can't see that in a full frame.

Still never opened in an actual browser.
2026-08-16 20:25:15 -06:00

74 lines
3.5 KiB
JavaScript

/* THE CROWD, WITH NO CITY BEHIND IT. Usage:
node tools/peds.cjs [cols] [rows] [seconds] > peds.txt # then tools/topng.py
The pedestrians are the one element that cannot be checked in a rendered frame. A figure is a
black cut-out with a lit edge, most of the crowd is six to twenty rows tall, and the frame it
lives in is a dark street with several thousand other lit cells in it — so "does the new costume
read" is a question a whole-frame dump physically cannot answer. Worse, a costume that draws
NOTHING (an accessory that reaches outside its archetype's `ext`, a span whose v1 lands above
its v0) costs no cells and throws no error. It just quietly stops being in the picture, which is
exactly the failure this file exists to make visible.
So: run the SHIPPED element — its own init/update/draw, no drawing re-implemented here — against
an empty frame with no city, no road and no signage, for as many seconds as asked, and dump what
it drew. corridor() falls back to the harness canyon when there is no city, which is why this
needs nothing but core.js and street.js.
What to look for, in the order these things break:
- every figure has a lit top edge. A silhouette with no rim is invisible on a real street
- the crowd is not all one height, one width or one gait
- hems, brims, packs and bags are reaching PAST the shoulder line and catching the rim
- arms swing: the outline is asymmetric and changes between frames
- nothing is a featureless black slab (that is a costume whose spans have collapsed) */
const fs = require('fs'), path = require('path');
const root = path.join(__dirname, '..');
global.CC = require(path.join(root, 'src/core.js'));
global.window = undefined;
for (const rel of ['src/weather_state.js', 'src/city.js', 'src/surfaces.js', 'src/raycast.js'])
if (fs.existsSync(path.join(root, rel))) require(path.join(root, rel));
require(path.join(root, 'src/elements/street.js'));
const CC = global.CC;
const argv = process.argv.slice(2);
const COLS = parseInt(argv[0] || '260', 10);
const ROWS = parseInt(argv[1] || '60', 10);
const SECS = parseFloat(argv[2] || '12');
const ped = CC.ELEMENTS.filter(e => e.name === 'pedestrians')[0];
if (!ped) { console.error('no pedestrians element'); process.exit(2); }
/* The camera walks +z down the middle of the harness canyon at the same 1.6 m/s the autopilot
uses, so the crowd is met head-on and at a spread of distances rather than posed. */
function cam(t) {
return { x: 0.5, y: 1.7, z: t * 1.6, yaw: 0, fov: 1.25,
horizon: ROWS * 0.56, horizonBase: ROWS * 0.56, rows: ROWS, t: t };
}
const f = CC.makeFrame(COLS, ROWS);
ped.init(null, CC.mulberry(7), { cols: COLS, rows: ROWS });
const N = Math.round(SECS * 60);
for (let k = 0; k <= N; k++) ped.update(1 / 60, k / 60, cam(k / 60));
CC.clearFrame(f);
ped.draw(f, cam(N / 60), N / 60);
CC.Compose.post(f);
let lit = 0;
for (let i = 0; i < f.n; i++) if (f.ch[i] && f.lum[i]) lit++;
const out = ['CCFRAME 2', COLS + ' ' + ROWS,
'PALETTE ' + CC.PALETTE.map(c => c.join(',')).join(' '),
'GLYPHS ' + JSON.stringify(CC.GLYPHS.join(''))];
for (let y = 0; y < ROWS; y++) {
const row = [];
for (let x = 0; x < COLS; x++) {
const i = y * COLS + x;
row.push(f.ch[i] + ',' + f.col[i] + ',' + f.lum[i] + ',' + (f.kind ? f.kind[i] : 3));
}
out.push(row.join(' '));
}
process.stdout.write(out.join('\n') + '\n');
console.error('crowd ' + COLS + 'x' + ROWS + ' at t=' + (N / 60).toFixed(1) + 's ' +
lit + ' lit cells');