Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea/people: passers-by on a city's sidewalks, places found by grid, queues on the world's line facing the door (CH52)
shinyobjectz4b707f246fc9
diff --git a/docs/character.feature b/docs/character.featureindex 710425e0..08e53f51 100644--- a/docs/character.feature+++ b/docs/character.feature@@ -1015,7 +1015,14 @@ Feature: The character SDK as one system: SOMA bodies, Kimodo motion, generated# their trips with no skinning), far (census(): how many are at each kind of place, or moving by each mode,# in each hour). A person changes level with a tenth of hysteresis so the edge does not flicker. The ranges# are the project's (THE GAMBIT's world/budgets.ts: near 150 m, middle 1500 m).+ # A street carries more than its residents: passersBy() puts walkers on a city's sidewalks by each line's+ # length, how busy it is at its busiest hour (THE GAMBIT: 0.3 a metre on a tram street at 5 pm, 0.08 on a side+ # street) and the hour's share; each a person by the street's mix at their own pace, keeping right, computed+ # for any minute alone. Places are found by a grid (a slice of Berlin has 16,000 shops); a queue stands on the+ # world's queue line when it gives one, everyone facing the door; a block with nowhere to happen (no post, no+ # workplace) is not lived that day.Then a city of thousands is placed at any minute, and only those near the camera are characters+ And a main street at its busiest holds about the people its tile's budget allows, on its sidewalksScenario: CH53. How a person meets an event# react(): a shock underfoot (a mine's blast felt through the ground), a gun's report, a shout. Feltdiff --git a/sdk/character/src/people.ts b/sdk/character/src/people.tsindex 47d62400..514b69d9 100644--- a/sdk/character/src/people.ts+++ b/sdk/character/src/people.ts@@ -13,3 +13,5 @@ export { rng, hash, type Rng } from "./people/rng";export { makePerson, gaitOf, leaned, TRAITS, type Folk, type Names } from "./people/persona";export { dayOf, whereAt, walkSpeed, straight, SPEED, WALK_UNDER, type DayInput } from "./people/day";export { populate, cityDay, snapshot, census, levelAt, react, type CityInput, type Mix, type Day, type Event } from "./people/city";+export { Grid, gridOf } from "./people/near";+export { passersBy, busyAt, STREET_HOURS, type Walk, type Passer, type FlowInput } from "./people/flow";diff --git a/sdk/character/src/people/city.ts b/sdk/character/src/people/city.tsindex 6cd27160..afc09917 100644--- a/sdk/character/src/people/city.ts+++ b/sdk/character/src/people/city.ts@@ -3,6 +3,7 @@// no skinning, and beyond that only counts (how many are at each kind of place in each hour). A person moves between// levels by id, keeping their day.import { dayOf, whereAt, type DayInput } from "./day";+import { gridOf } from "./near";import { makePerson, type Folk } from "./persona";import { hash, rng } from "./rng";import type { Activity, Level, Person, Place, Role, Router, Traits, V3 } from "./types";@@ -34,6 +35,7 @@ export function populate(c: CityInput): Person[] {for (const h of homes) for (let k = 0; k < (h.holds ?? 3); k++) slots.push(h);for (let i = slots.length - 1; i > 0; i--) { const j = r.int(0, i); [slots[i], slots[j]] = [slots[j], slots[i]]; }const used = new Map<string, number>();+ const kinds = kindsOf(c.places);const out: Person[] = [];let n = 0;for (const [rid, count] of counts) {@@ -43,8 +45,8 @@ export function populate(c: CityInput): Person[] {const home = slots[n % slots.length];let work: Place | undefined;if (role.work) {- const cand = c.places.filter((p) => p.kind === role.work!.at && (used.get(p.id) ?? 0) < (p.holds ?? Infinity)- && Math.hypot(p.at[0] - home.at[0], p.at[2] - home.at[2]) <= (role.work!.within ?? Infinity));+ const all = kinds.get(role.work.at) ?? [], within = role.work.within;+ const cand = (within === undefined ? all : gridOf(all).within(home.at, within)).filter((p) => (used.get(p.id) ?? 0) < (p.holds ?? Infinity));work = cand.length ? cand[r.int(0, cand.length - 1)] : undefined;if (work) used.set(work.id, (used.get(work.id) ?? 0) + 1);}@@ -69,10 +71,16 @@ export interface Day {places: Map<string, Place>;}+/** Places by kind, in the order given. */+function kindsOf(places: Place[]): Map<string, Place[]> {+ const m = new Map<string, Place[]>();+ for (const p of places) { const l = m.get(p.kind); if (l) l.push(p); else m.set(p.kind, [p]); }+ return m;+}+/** Every person's day for a date. */export function cityDay(people: Person[], roles: Role[], places: Place[], date: DayInput["date"], router?: Router, cold?: number): Day {- const pm = new Map(places.map((p) => [p.id, p])), byKind = new Map<string, Place[]>();- for (const p of places) byKind.set(p.kind, [...(byKind.get(p.kind) ?? []), p]);+ const pm = new Map(places.map((p) => [p.id, p])), byKind = kindsOf(places);const rm = new Map(roles.map((x) => [x.id, x]));const days = new Map<string, Activity[]>();for (const person of people) days.set(person.id, dayOf({ person, role: rm.get(person.role)!, date, places: pm, byKind, router, cold }));@@ -95,11 +103,16 @@ export function snapshot(d: Day, m: number, camera: V3, range: { near: number; mconst placed = new Map<number, { at: V3; facing: number }>();for (const [id, line] of lines) {const pl = d.places.get(id)!, f = pl.facing ?? 0;- // the front runs across the facing; the queue runs along it from the door, a step out from the wall- const out: V3 = [Math.sin(f), 0, Math.cos(f)], along: V3 = [Math.cos(f), 0, -Math.sin(f)];+ // the world's queue line when it gives one; else the front runs across the facing and the queue runs along it from+ // the door, a step out from the wall+ const out: V3 = [Math.sin(f), 0, Math.cos(f)];+ const start: V3 = pl.line?.at ?? [pl.at[0] + out[0] * QUEUE_OUT, pl.at[1], pl.at[2] + out[2] * QUEUE_OUT];+ const along: V3 = pl.line?.along ?? [Math.cos(f), 0, -Math.sin(f)];+ // each faces the one ahead, toward the door: back along the line+ const facing = Math.atan2(-along[0], -along[2]);line.sort((a, b) => a.since - b.since || a.i - b.i).forEach((q, k) => {- const s = (k + 1) * QUEUE_GAP;- placed.set(q.i, { at: [pl.at[0] + out[0] * QUEUE_OUT + along[0] * s, pl.at[1], pl.at[2] + out[2] * QUEUE_OUT + along[2] * s], facing: f + Math.PI / 2 });+ const s = (k + (pl.line ? 0 : 1)) * QUEUE_GAP;+ placed.set(q.i, { at: [start[0] + along[0] * s, start[1], start[2] + along[2] * s], facing });});}return rows.map(({ p, w }, i) => {diff --git a/sdk/character/src/people/day.ts b/sdk/character/src/people/day.tsindex 354c2505..27b36fa8 100644--- a/sdk/character/src/people/day.ts+++ b/sdk/character/src/people/day.ts@@ -1,6 +1,7 @@// A person's day: the role's blocks that apply on that date, at real places, at times moved by how punctual the person// is, with the trips between them (a mode drawn by the person's own leanings and the distance), and habits slotted in// where they fit. The same person and date give the same day.+import { gridOf } from "./near";import { leaned } from "./persona";import { rng } from "./rng";import type { Activity, Block, Habit, Minute, Mode, Person, Place, Role, Router, V3 } from "./types";@@ -43,8 +44,8 @@ function placeFor(at: string, p: Person, inp: DayInput, near: Place, r: ReturnTyconst all = inp.byKind.get(at);if (!all || all.length === 0) return undefined;// the nearest few, one of them (people do not all use the one nearest shop)- const ranked = [...all].sort((a, b) => Math.hypot(a.at[0] - near.at[0], a.at[2] - near.at[2]) - Math.hypot(b.at[0] - near.at[0], b.at[2] - near.at[2]));- return ranked[Math.min(ranked.length - 1, Math.floor(Math.pow(r.next(), 2) * Math.min(4, ranked.length)))];+ const ranked = gridOf(all).nearest(near.at, 4);+ return ranked[Math.min(ranked.length - 1, Math.floor(Math.pow(r.next(), 2) * ranked.length))];}function modeFor(p: Person, metres: number, cold: number, r: ReturnType<typeof rng>): Mode {@@ -79,7 +80,10 @@ export function dayOf(inp: DayInput): Activity[] {let from = b.from + Math.round(r.normal(0, (b.jitter ?? 10) * keep));const end = b.to ?? from + (b.minutes ?? 60);for (let s = 0; s < stops; s++) {- const at = placeFor(b.at, p, inp, here, r) ?? here;+ // a block with nowhere to happen (no workplace was found for the person, no place of its kind in the city) is+ // not lived that day: a sentry with no post stays home rather than standing guard at their own door+ const at = placeFor(b.at, p, inp, here, r);+ if (!at) break;const to = b.round ? Math.min(end, from + b.round.dwell) : end + Math.round(r.normal(0, (b.jitter ?? 10) * keep * 0.5));stays.push({ what: b.what, at, from, to: Math.max(from + 1, to), acts: b.acts, outside: b.outside });here = at;@@ -92,7 +96,8 @@ export function dayOf(inp: DayInput): Activity[] {if (!r.fork(h.id).chance(leaned(h.chance, p.traits, h.leans))) continue;const start = h.from + Math.floor(r.next() * Math.max(1, h.to - h.from - h.minutes));const host = [...stays].reverse().find((s) => s.from <= start) ?? stays[0];- const at = h.at === "here" && host ? host.at : placeFor(h.at, p, inp, host?.at ?? home, r) ?? home;+ const at = h.at === "here" && host ? host.at : placeFor(h.at, p, inp, host?.at ?? home, r);+ if (!at) continue;stays.push({ what: h.act, at, from: start, to: start + h.minutes, outside: h.outside });}stays.sort((a, b) => a.from - b.from);diff --git a/sdk/character/src/people/flow.ts b/sdk/character/src/people/flow.tsnew file mode 100644index 00000000..bbef8c9d--- /dev/null+++ b/sdk/character/src/people/flow.ts@@ -0,0 +1,93 @@+// The people passing through (docs/character.feature CH52): a street carries more than the people who live on it.+// Each sidewalk holds walkers by its length, its busyness at its busiest hour and the hour's share of that; each is a+// person (a role drawn by the mix) walking the line at their own pace one way or the other, keeping to their right.+// Where a walker is at any minute is computed, not stepped, so any frame of a shot can be drawn alone.+import { walkSpeed } from "./day";+import { makePerson, type Folk } from "./persona";+import { hash, rng } from "./rng";+import type { Minute, Person, Place, Role, V3 } from "./types";++/** A sidewalk's centreline and how busy it is: walkers a metre at its busiest hour. */+export interface Walk {+ id: string;+ path: V3[];+ perMetre: number;+ /** its width (metres, 3): walkers keep to their right within it */+ width?: number;+}++/** A city street's walkers by hour, against its busiest (5 pm): the morning and evening rush, the noon errands, the+ * empty night. Index h is h:00; a minute between is read between. */+export const STREET_HOURS = [0.03, 0.02, 0.02, 0.02, 0.04, 0.1, 0.3, 0.6, 0.7, 0.55, 0.6, 0.75, 0.9, 0.85, 0.75, 0.8, 0.9, 1, 0.85, 0.5, 0.3, 0.2, 0.1, 0.05];++export interface Passer {+ id: string;+ walk: string;+ at: V3;+ facing: number;+ person: Person;+}++export interface FlowInput {+ roles: Role[];+ folk: Folk;+ /** the roles' shares among people on the street */+ mix: Record<string, number>;+ seed: number | string;+ /** the hour profile (STREET_HOURS) */+ hours?: number[];+ /** how cold (0 mild to 1 bitter): pace */+ cold?: number;+ /** more or fewer than the walks' own numbers (1): a shot's busier street */+ busy?: number;+ /** only walks with a point within `within` metres of `near` */+ near?: V3;+ within?: number;+}++const people = new Map<string, Person>();++/** The share of the busiest hour at a minute of the day. */+export function busyAt(m: Minute, hours = STREET_HOURS): number {+ const h = (((m / 60) % 24) + 24) % 24, i = Math.floor(h), k = h - i;+ return hours[i] * (1 - k) + hours[(i + 1) % 24] * k;+}++/** Everyone walking the given sidewalks at minute `m` (fractional minutes are seconds): who, where, which way. */+export function passersBy(walks: Walk[], m: Minute, f: FlowInput): Passer[] {+ const busy = busyAt(m, f.hours), out: Passer[] = [];+ const roles = new Map(f.roles.map((r) => [r.id, r]));+ for (const w of walks) {+ if (f.near && f.within !== undefined && !w.path.some((p) => Math.hypot(p[0] - f.near![0], p[2] - f.near![2]) <= f.within!)) continue;+ const seg = w.path.slice(1).map((q, i) => Math.hypot(q[0] - w.path[i][0], q[2] - w.path[i][2]));+ const L = seg.reduce((a, b) => a + b, 0);+ if (L < 2) continue;+ // the line's slots at its busiest; a slot walks when its own draw is under the hour's share, so the walkers+ // thin out and come back as the day goes without anyone jumping+ const slots = Math.round(L * w.perMetre * (f.busy ?? 1));+ for (let k = 0; k < slots; k++) {+ const id = `${w.id}:${k}`, r = rng(`${f.seed}-${id}`);+ if (r.next() >= busy) continue;+ let p = people.get(`${f.seed}-${id}`);+ if (!p) {+ // who they are from a draw of their own, so a walker made earlier walks the same way+ const role = roles.get(rng(`${f.seed}-${id}-who`).weighted(f.mix))!;+ const home: Place = { id: `passing-${w.id}`, kind: "street", at: w.path[0] };+ p = makePerson(id, role, f.folk, home, hash(`${f.seed}-${id}`));+ people.set(`${f.seed}-${id}`, p);+ }+ const dir = r.next() < 0.5 ? 1 : -1, phase = r.next();+ const v = walkSpeed(p, f.cold ?? 0.5) * (0.9 + 0.2 * r.next());+ // along the line, wrapping at its ends (a walker leaves at one end as another comes in at the other)+ let s = (((phase * L + dir * v * m * 60) % L) + L) % L, i = 0;+ while (i < seg.length - 1 && s > seg[i]) s -= seg[i++];+ const A = w.path[i], B = w.path[i + 1], u = seg[i] ? s / seg[i] : 0;+ const tx = (B[0] - A[0]) / (seg[i] || 1), tz = (B[2] - A[2]) / (seg[i] || 1);+ // keep right: off the centreline by a quarter of the width or so, to the walker's right+ const off = dir * (w.width ?? 3) * (0.12 + 0.2 * r.next());+ const at: V3 = [A[0] + (B[0] - A[0]) * u - tz * off, A[1] + (B[1] - A[1]) * u, A[2] + (B[2] - A[2]) * u + tx * off];+ out.push({ id, walk: w.id, at, facing: Math.atan2(dir * tx, dir * tz), person: p });+ }+ }+ return out;+}diff --git a/sdk/character/src/people/near.ts b/sdk/character/src/people/near.tsnew file mode 100644index 00000000..bfa4ebef--- /dev/null+++ b/sdk/character/src/people/near.ts@@ -0,0 +1,55 @@+// Places by where they are: a grid of cells, so the nearest few of a kind, or all within a reach, are found by looking+// at the cells around a point, not at every place in the city (16,000 shops in a slice of Berlin; CH52).+import type { Place, V3 } from "./types";++const dist = (a: V3, b: V3) => Math.hypot(a[0] - b[0], a[2] - b[2]);++export class Grid {+ private cells = new Map<string, Place[]>();+ constructor(readonly places: Place[], readonly cell = 250) {+ for (const p of places) {+ const k = this.key(Math.floor(p.at[0] / cell), Math.floor(p.at[2] / cell));+ const c = this.cells.get(k);+ if (c) c.push(p); else this.cells.set(k, [p]);+ }+ }+ private key(i: number, j: number) { return `${i},${j}`; }+ /** the cells in the square ring `r` cells out from (i, j) */+ private ring(i: number, j: number, r: number, out: Place[]) {+ for (let a = -r; a <= r; a++) for (let b = -r; b <= r; b++) {+ if (Math.max(Math.abs(a), Math.abs(b)) !== r) continue;+ const c = this.cells.get(this.key(i + a, j + b));+ if (c) for (const p of c) out.push(p);+ }+ }+ /** the `k` nearest to `at`, nearest first (fewer when there are fewer) */+ nearest(at: V3, k: number): Place[] {+ if (this.places.length <= k) return [...this.places].sort((a, b) => dist(a.at, at) - dist(b.at, at));+ const i = Math.floor(at[0] / this.cell), j = Math.floor(at[2] / this.cell);+ const seen: Place[] = [];+ // a ring r cells out holds nothing nearer than (r - 1) cells; stop once k are found nearer than that+ for (let r = 0; ; r++) {+ this.ring(i, j, r, seen);+ if (seen.length >= k) {+ seen.sort((a, b) => dist(a.at, at) - dist(b.at, at));+ if (dist(seen[k - 1].at, at) <= r * this.cell) return seen.slice(0, k);+ }+ if (seen.length === this.places.length) return seen.sort((a, b) => dist(a.at, at) - dist(b.at, at)).slice(0, k);+ }+ }+ /** every place within `metres` of `at` */+ within(at: V3, metres: number): Place[] {+ const i = Math.floor(at[0] / this.cell), j = Math.floor(at[2] / this.cell), R = Math.ceil(metres / this.cell);+ const out: Place[] = [];+ for (let r = 0; r <= R; r++) this.ring(i, j, r, out);+ return out.filter((p) => dist(p.at, at) <= metres);+ }+}++const grids = new WeakMap<Place[], Grid>();+/** The grid over a list of places, made once per list. */+export function gridOf(places: Place[]): Grid {+ let g = grids.get(places);+ if (!g) grids.set(places, (g = new Grid(places)));+ return g;+}diff --git a/sdk/character/src/people/types.ts b/sdk/character/src/people/types.tsindex 0c17092d..308da278 100644--- a/sdk/character/src/people/types.ts+++ b/sdk/character/src/people/types.ts@@ -121,6 +121,9 @@ export interface Place {/** being there hides a person (a home, a works, a school): no character is drawn for them unless their block is* `outside`. Unset: a place out of doors (a corner, a post, a courtyard, a square) */inside?: boolean;+ /** where a queue at this door forms, when the world says (a tile's queue line): its first place and the way it runs.+ * Unset: a step out from the door, along the front */+ line?: { at: V3; along: V3 };}/** A face: a hero's own head (made from its pictures) or a crowd head drawn from a face model by these numbers. */diff --git a/sdk/character/test/people.test.ts b/sdk/character/test/people.test.tsindex 0342c9c2..be78c34e 100644--- a/sdk/character/test/people.test.ts+++ b/sdk/character/test/people.test.ts@@ -1,7 +1,7 @@// raea/people (src/people.ts, docs/character.feature CH50-CH53): people drawn from roles, their days, where they are// at a minute, the levels of detail and how they meet an event.import { expect, test } from "bun:test";-import { census, cityDay, dayOf, levelAt, populate, react, snapshot, whereAt, type Folk, type Place, type Role } from "../src/people";+import { census, cityDay, dayOf, Grid, levelAt, passersBy, populate, react, rng, snapshot, whereAt, type Walk, type Folk, type Place, type Role, type V3 } from "../src/people";const folk: Folk = {names: { given: { f: ["Anna", "Martha", "Frieda"], m: ["Karl", "Otto", "Paul"] }, family: ["Schulz", "Müller", "Krüger"] },@@ -163,4 +163,76 @@ test("people inside are counted, not drawn; a queue stands in a line along the fconst at = q.filter((x) => x.activity.kind === "stay" && x.activity.at === door).map((x) => x.at[0]).sort((a, b) => a - b);for (let k = 1; k < at.length; k++) expect(at[k] - at[k - 1]).toBeCloseTo(0.65, 5);}+ // each faces the door: from the bakery's door (facing 0, so the front runs along x) back along the line+ for (const x of q) {+ const door = inside.find((p) => x.activity.kind === "stay" && p.id === x.activity.at)!;+ const toDoor = Math.atan2(door.at[0] - x.at[0], door.at[2] + 1.1 - x.at[2]);+ expect(Math.abs(Math.atan2(Math.sin(x.facing - toDoor), Math.cos(x.facing - toDoor)))).toBeLessThan(0.01);+ }+ // a world's queue line is followed: its first place, then 0.65 m apart along it+ const lined = inside.map((p) => (p.kind === "bakery" ? { ...p, line: { at: [p.at[0], 0, p.at[2] + 2] as V3, along: [0, 0, 1] as V3 } } : p));+ const dl = cityDay(ps, queueRoles, lined, { key: "1917-12-03", weekday: 1 });+ const ql = snapshot(dl, 7 * 60 + 15, [0, 0, 0], { near: 150, middle: 1500 }).filter((x) => x.doing === "queue for bread");+ for (const door of lined.filter((p) => p.line)) {+ const zs = ql.filter((x) => x.activity.kind === "stay" && x.activity.at === door.id).map((x) => x.at[2] - door.at[2]).sort((a, b) => a - b);+ zs.forEach((z, k) => expect(z).toBeCloseTo(2 + 0.65 * k, 5));+ }+ expect(ql.every((x) => Math.abs(x.facing - Math.PI) < 1e-9 || Math.abs(x.facing + Math.PI) < 1e-9)).toBe(true);+});++test("the nearest places of a kind come from a grid, the same as sorting them all", () => {+ const r = rng(91);+ const many: Place[] = Array.from({ length: 3000 }, (_, i) => ({ id: `s${i}`, kind: "shop", at: [r.next() * 4000 - 2000, 0, r.next() * 4000 - 2000] as V3 }));+ const g = new Grid(many, 250);+ for (let t = 0; t < 200; t++) {+ const at: V3 = [r.next() * 5000 - 2500, 0, r.next() * 5000 - 2500];+ const d = (p: Place) => Math.hypot(p.at[0] - at[0], p.at[2] - at[2]);+ const want = [...many].sort((a, b) => d(a) - d(b)).slice(0, 4).map(d);+ expect(g.nearest(at, 4).map(d)).toEqual(want);+ const reach = 50 + r.next() * 600;+ expect(new Set(g.within(at, reach).map((p) => p.id))).toEqual(new Set(many.filter((p) => d(p) <= reach).map((p) => p.id)));+ }+ expect(g.nearest([0, 0, 0], 5000).length).toBe(3000);+});++test("a block with nowhere to happen is not lived: no workplace, no shift; no post, no patrol at the front door", () => {+ const bare = places.filter((p) => p.kind !== "post" && p.kind !== "munitions");+ const ps = populate({ roles, places: bare, folk, mix, seed: 5 });+ const d = cityDay(ps, roles, bare, { key: "1917-12-03", weekday: 1 });+ const workers = ps.filter((x) => x.role === "munitions-worker"), sentries = ps.filter((x) => x.role === "sentry");+ expect(workers.length).toBeGreaterThan(0);+ expect(sentries.length).toBeGreaterThan(0);+ for (const p of workers) expect(p.work).toBeUndefined();+ for (const p of [...workers, ...sentries]) {+ const day = d.days.get(p.id)!;+ expect(day.every((a) => a.kind === "stay" ? a.at === p.home || !["shift", "patrol"].includes(a.what) : true)).toBe(true);+ expect(day.some((a) => a.kind === "stay" && a.what === "patrol")).toBe(false);+ }+});++test("passers-by: as many as the line and the hour say, on it, keeping right, the same each time, moving at a walk", () => {+ const walk: Walk = { id: "w", path: [[0, 0, 0], [200, 0, 0], [200, 0, 100]], perMetre: 0.3, width: 3 };+ const f = { roles, folk, mix, seed: "flow" };+ const at17 = passersBy([walk], 17 * 60, f), at3 = passersBy([walk], 3 * 60, f);+ // 300 m at 0.3 a metre at the busiest hour (5 pm), a fiftieth of that at 3 am+ expect(Math.abs(at17.length - 90)).toBeLessThan(15);+ expect(at3.length).toBeLessThan(8);+ expect(passersBy([walk], 17 * 60, f)).toEqual(at17);+ for (const p of at17) {+ const onFirst = Math.abs(p.at[2]) <= 1.5 && p.at[0] >= -1e-6 && p.at[0] <= 200 + 1.5;+ const onSecond = Math.abs(p.at[0] - 200) <= 1.5 && p.at[2] >= -1.5 && p.at[2] <= 100;+ expect(onFirst || onSecond).toBe(true);+ }+ // on the first leg (along +x), those walking +x keep to one side and those walking -x to the other+ const leg = at17.filter((p) => p.at[0] < 190 && Math.abs(p.at[2]) < 2);+ const east = leg.filter((p) => Math.sin(p.facing) > 0.5), west = leg.filter((p) => Math.sin(p.facing) < -0.5);+ expect(east.length + west.length).toBe(leg.length);+ expect(east.every((p) => p.at[2] > 0) && west.every((p) => p.at[2] < 0)).toBe(true);+ // a second later each has moved about a walking pace along the line+ const later = new Map(passersBy([walk], 17 * 60 + 1 / 60, f).map((p) => [p.id, p]));+ for (const p of leg.slice(0, 20)) {+ const q = later.get(p.id)!;+ const d = Math.hypot(q.at[0] - p.at[0], q.at[2] - p.at[2]);+ if (d < 5) expect(d).toBeGreaterThan(0.7), expect(d).toBeLessThan(1.8);+ }});