Files
VibemakerSandbox/app/test/session-environment.test.js
T
chenlin a8be5e0134 feat: release v0.5 with shared interactive arenas and textured RP1
Unify lighting and line-colour controls across robots, replace the football with a shared layout of draggable physical props, and import the supplied RP1 GLBs without changing trained physics or policies.

Include reproducible visual import/provenance, regression coverage and verification records. Verified 66 unit tests, 55 browser tests and production-build checks.
2026-10-30 14:14:03 +08:00

37 lines
1.3 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { createSessionEnvironment } from "../src/game/worlds/arena/session-environment.js";
const world = (scale) => ({
presentation: "arena-grid",
boundary: { half_extent: 2.25 * scale },
});
test("all robot sizes share one random layout, with scaled geometry and spawn clearances", () => {
let seed = 42;
const scene = createSessionEnvironment(
() => (seed = (1664525 * seed + 1013904223) >>> 0) / 4294967296,
);
const duck = scene.propsFor(world(1));
for (const scale of [1, 0.33 / 0.27, 1.32 / 0.27]) {
const props = scene.propsFor(world(scale));
assert.equal(props.length, duck.length);
props.forEach((p, i) => {
assert.equal(p.type, duck[i].type);
assert.equal(p.color, duck[i].color);
p.pos.forEach((v, j) =>
assert.ok(Math.abs(v / scale - duck[i].pos[j]) < 1e-12),
);
p.size.forEach((v, j) =>
assert.ok(Math.abs(v / scale - duck[i].size[j]) < 1e-12),
);
assert.ok(Math.hypot(p.pos[0] / scale, p.pos[1] / scale) > 0.34);
assert.ok(Math.hypot(p.pos[0] / scale + 0.6, p.pos[1] / scale) > 0.34);
});
}
const copy = scene.propsFor(world(1));
copy[0].pos[0] = 100;
copy[0].quat[0] = 0;
assert.deepEqual(scene.propsFor(world(1)), duck);
assert.deepEqual(scene.propsFor({ type: "flat" }), []);
});