ravensight-playtest 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -16
- package/addons/desktop/RavensightDesktop.swift +367 -0
- package/addons/mobile/UITests/MobileInputTests.swift +67 -1
- package/addons/ravensight_driver/driver.gd +557 -4
- package/docs/ADAPTERS.md +37 -7
- package/docs/DESKTOP.md +117 -0
- package/docs/MOBILE.md +30 -3
- package/docs/UNITY.md +149 -0
- package/docs/UNREAL.md +123 -0
- package/docs/godot-driver.md +98 -1
- package/package.json +15 -5
- package/src/cli.js +26 -10
- package/src/commands/build.js +40 -0
- package/src/commands/fakeCore.js +1 -1
- package/src/commands/feature.js +1 -1
- package/src/commands/hosted.js +78 -9
- package/src/commands/run.js +47 -13
- package/src/commands/validate.js +1 -1
- package/src/commands/validateHosted.js +4 -1
- package/src/hosted/archivePreflight.js +31 -4
- package/src/hosted/buildStatus.js +26 -0
- package/src/hosted/buildUpload.js +39 -22
- package/src/hosted/nativeBuild.js +87 -0
- package/src/hosted/recordedRun.js +15 -3
- package/src/run/anygame/genre.js +98 -24
- package/src/run/anygame/genre2d.js +108 -0
- package/src/run/anygame/index.js +33 -7
- package/src/run/anygame/memory.js +31 -0
- package/src/run/anygame/scene3d.js +562 -0
- package/src/run/anygame/shared-hashes.json +5 -3
- package/src/run/anygame/shared.js +3 -3
- package/src/run/args.js +15 -4
- package/src/run/drivers/desktop/app.js +104 -0
- package/src/run/drivers/desktop/common.js +336 -0
- package/src/run/drivers/desktop/driver.js +383 -0
- package/src/run/drivers/desktop/helper.js +98 -0
- package/src/run/drivers/desktop/keys.js +124 -0
- package/src/run/drivers/desktop/output.js +107 -0
- package/src/run/drivers/desktop/preflight.js +134 -0
- package/src/run/drivers/desktop3d.js +106 -0
- package/src/run/drivers/desktopSequence.js +72 -0
- package/src/run/drivers/godot-3d.js +298 -0
- package/src/run/drivers/godot.js +465 -30
- package/src/run/drivers/index.js +6 -0
- package/src/run/drivers/mobile/adb.js +25 -1
- package/src/run/drivers/mobile/frame.js +3 -2
- package/src/run/drivers/mobile/gestures.js +76 -0
- package/src/run/drivers/mobile/lock.js +51 -11
- package/src/run/drivers/mobile/multitouch.js +150 -0
- package/src/run/drivers/mobile/native.js +229 -31
- package/src/run/drivers/mobile/preflight.js +14 -1
- package/src/run/drivers/mobile/target.js +21 -1
- package/src/run/drivers/stdio.js +150 -12
- package/src/run/drivers/unity/app.js +72 -0
- package/src/run/drivers/unity/engine.js +58 -0
- package/src/run/drivers/unity/link.js +108 -0
- package/src/run/drivers/unity/logs.js +76 -0
- package/src/run/drivers/unreal/app.js +40 -0
- package/src/run/drivers/unreal/driver.js +686 -0
- package/src/run/drivers/unreal/frames.js +243 -0
- package/src/run/drivers/unreal/logs.js +276 -0
- package/src/run/drivers/unreal/preflight.js +61 -0
- package/src/run/drivers/web.js +211 -13
- package/src/run/drivers/webdriver.js +79 -12
- package/src/run/endScreen.js +88 -0
- package/src/run/engineErrors.js +16 -0
- package/src/run/featureLoop.js +1 -1
- package/src/run/fingers.js +99 -0
- package/src/run/focusForKeys.js +54 -0
- package/src/run/gameMemory.js +4 -3
- package/src/run/godotTesterProbes.js +21 -2
- package/src/run/honesty.js +11 -1
- package/src/run/inputs.js +3 -3
- package/src/run/intent.js +12 -0
- package/src/run/pauseHook.js +494 -0
- package/src/run/personaLoop.js +139 -10
- package/src/run/pixels.js +22 -10
- package/src/run/planGuard.js +103 -0
- package/src/run/replay.js +5 -1
- package/src/run/reportChecks.js +17 -4
- package/src/run/resume.js +6 -2
- package/src/run/sessions.js +170 -0
- package/src/run/startFrom.js +415 -0
- package/src/run/testerProbes.js +36 -5
- package/src/run/tools.js +191 -10
- package/src/run/view3dState.js +125 -0
- package/src/run/web3d.js +375 -0
- package/src/run/world3d.js +164 -0
- package/src/upload/host.js +40 -0
- package/src/upload/index.js +15 -1
- package/templates/godot-3d/README.md +3 -2
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
// Where the player is in a 3D game, measured, and what a run's inputs did to
|
|
2
|
+
// it: the evidence behind the 3D findings (stuck on geometry, fell out of the
|
|
3
|
+
// world, the camera inside a wall, no way forward, an input that changed
|
|
4
|
+
// nothing).
|
|
5
|
+
//
|
|
6
|
+
// 1. The page side (`scene3dInit`, added before any page script runs). Most
|
|
7
|
+
// web 3D games are three.js or Babylon. three.js tells a developer tools
|
|
8
|
+
// hook about every renderer and scene it makes (`window.__THREE_DEVTOOLS__`,
|
|
9
|
+
// the hook its own browser extension uses); the runner stands in for that
|
|
10
|
+
// hook, notes the camera each frame is drawn with, and reads from it: where
|
|
11
|
+
// the camera is and which way it faces, where the player object is (an
|
|
12
|
+
// object named player, hero, character, car, vehicle or ship), which solid
|
|
13
|
+
// boxes the camera is inside, and the lowest point of the level. Babylon
|
|
14
|
+
// keeps its scene on its global. Read-only: nothing the game draws or does
|
|
15
|
+
// is changed. A page with neither engine (a Godot or Unity export, or any
|
|
16
|
+
// game on the Ravensight JS SDK) is read third, from the 3D view its
|
|
17
|
+
// Ravensight SDK publishes on the page during a playtest
|
|
18
|
+
// (`window.__ravensightView3d`, the platform's PAUSE_HOOK_CONTRACT.md
|
|
19
|
+
// section 10); the page is marked as a playtest by
|
|
20
|
+
// `window.__RAVENSIGHT_PLAYTEST__`, which this sets (empty) when nothing
|
|
21
|
+
// else has. A page with none of the three reads as null: its findings then
|
|
22
|
+
// rest on frames alone.
|
|
23
|
+
//
|
|
24
|
+
// 2. The pure side (no I/O, no page): `cleanPose` checks what the page said,
|
|
25
|
+
// and `world3dFindings` reads a run's steps (each with the pose before and
|
|
26
|
+
// after, whether the page received the input, and whether the screen
|
|
27
|
+
// changed) and returns the 3D findings with the measurements they rest on.
|
|
28
|
+
// A finding is filed only when the page received the input and nothing
|
|
29
|
+
// about the run explains it; a tool limit is never one.
|
|
30
|
+
//
|
|
31
|
+
// The same file is carried by the hosted runner (the platform repo, infrastructure/hosted-playtest/direct-runner/lib/anygame/scene3d.mjs).
|
|
32
|
+
|
|
33
|
+
/* c8 ignore start */
|
|
34
|
+
export function scene3dInit() {
|
|
35
|
+
if (window.__rsScene3d) return;
|
|
36
|
+
// The playtest marker an SDK looks for before it publishes its 3D view (section 10). A marker the runner set already (the
|
|
37
|
+
// playtest identity, a live site's marker) is kept; this one is empty, holds nothing about the run, and can be replaced.
|
|
38
|
+
try {
|
|
39
|
+
if (typeof window.__RAVENSIGHT_PLAYTEST__ === 'undefined') Object.defineProperty(window, '__RAVENSIGHT_PLAYTEST__', { value: Object.freeze({}), configurable: true, writable: true, enumerable: false });
|
|
40
|
+
} catch { /* fixed */ }
|
|
41
|
+
// Taken before any page script runs, so a page that replaces them later is not what reads its own answer.
|
|
42
|
+
const toJson = JSON.stringify, fromJson = JSON.parse, call = Reflect.apply;
|
|
43
|
+
let last = null, lastPersp = null, subject = null, subjectAt = 0, floor = null, floorAt = 0, floorCount = -1;
|
|
44
|
+
const SUBJECT = /^(?:player|hero|character|avatar|car|kart|vehicle|ship|plane)(?:[\s_-]?\d+)?$/i;
|
|
45
|
+
const wrap = r => {
|
|
46
|
+
try {
|
|
47
|
+
if (!r || r.__rsWrapped || typeof r.render !== 'function') return;
|
|
48
|
+
const orig = r.render;
|
|
49
|
+
r.render = function (scene, camera) {
|
|
50
|
+
try {
|
|
51
|
+
if (scene && scene.isScene && camera && camera.isCamera && !(typeof this.getRenderTarget === 'function' && this.getRenderTarget())) {
|
|
52
|
+
last = { scene, camera };
|
|
53
|
+
if (camera.isPerspectiveCamera) lastPersp = last;
|
|
54
|
+
}
|
|
55
|
+
} catch { /* odd arguments */ }
|
|
56
|
+
return orig.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(r, '__rsWrapped', { value: true });
|
|
59
|
+
} catch { /* frozen */ }
|
|
60
|
+
};
|
|
61
|
+
try {
|
|
62
|
+
if (typeof window.__THREE_DEVTOOLS__ === 'undefined') {
|
|
63
|
+
const hook = new EventTarget();
|
|
64
|
+
hook.addEventListener('observe', e => {
|
|
65
|
+
const o = e && e.detail;
|
|
66
|
+
if (o && (o.isWebGLRenderer || o.isWebGPURenderer)) { wrap(o); Promise.resolve().then(() => wrap(o)); }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(window, '__THREE_DEVTOOLS__', { value: hook, configurable: true, writable: true });
|
|
69
|
+
}
|
|
70
|
+
} catch { /* fixed */ }
|
|
71
|
+
|
|
72
|
+
const r3 = v => Math.round(v * 1000) / 1000;
|
|
73
|
+
const top = (o, root) => { let t = o; while (t && t.parent && t.parent !== root) t = t.parent; return t; };
|
|
74
|
+
const solid = m => {
|
|
75
|
+
if (!m || !m.isMesh || m.isInstancedMesh || m.isSkinnedMesh || !m.visible || !m.geometry) return false;
|
|
76
|
+
const mat = Array.isArray(m.material) ? m.material[0] : m.material;
|
|
77
|
+
if (!mat || mat.visible === false || (mat.transparent && mat.opacity < 1) || mat.side !== 0 || mat.depthWrite === false) return false;
|
|
78
|
+
for (let a = m.parent; a; a = a.parent) if (a.visible === false) return false;
|
|
79
|
+
return true;
|
|
80
|
+
};
|
|
81
|
+
const bbox = m => { const g = m.geometry; if (!g.boundingBox && typeof g.computeBoundingBox === 'function') g.computeBoundingBox(); return g.boundingBox; };
|
|
82
|
+
// Whether a point (in the mesh's own space) is inside its closed surface: a ray from it crosses the surface an odd number of
|
|
83
|
+
// times, along two directions. A box around a ring, an arch or a doorway holds its hole; the surface does not, so a camera
|
|
84
|
+
// flying through a ring or walking through a door is not inside. A mesh too big to test, or with no triangles, counts as not.
|
|
85
|
+
const DIRS = [[1, 0.0013, 0.0007], [-0.0011, 1, 0.0017]];
|
|
86
|
+
function enclosed(g, x, y, z) {
|
|
87
|
+
const pos = g.attributes && g.attributes.position;
|
|
88
|
+
if (!pos || !pos.array || pos.itemSize !== 3) return false;
|
|
89
|
+
const a = pos.array, idx = g.index ? g.index.array : null, n = idx ? idx.length : pos.count;
|
|
90
|
+
if (n < 3 || n > 90000) return false;
|
|
91
|
+
for (const [dx, dy, dz] of DIRS) {
|
|
92
|
+
let hits = 0;
|
|
93
|
+
for (let t = 0; t + 2 < n; t += 3) {
|
|
94
|
+
const i0 = (idx ? idx[t] : t) * 3, i1 = (idx ? idx[t + 1] : t + 1) * 3, i2 = (idx ? idx[t + 2] : t + 2) * 3;
|
|
95
|
+
const e1x = a[i1] - a[i0], e1y = a[i1 + 1] - a[i0 + 1], e1z = a[i1 + 2] - a[i0 + 2];
|
|
96
|
+
const e2x = a[i2] - a[i0], e2y = a[i2 + 1] - a[i0 + 1], e2z = a[i2 + 2] - a[i0 + 2];
|
|
97
|
+
const px = dy * e2z - dz * e2y, py = dz * e2x - dx * e2z, pz = dx * e2y - dy * e2x;
|
|
98
|
+
const det = e1x * px + e1y * py + e1z * pz;
|
|
99
|
+
if (Math.abs(det) < 1e-12) continue;
|
|
100
|
+
const tx = x - a[i0], ty = y - a[i0 + 1], tz = z - a[i0 + 2];
|
|
101
|
+
const u = (tx * px + ty * py + tz * pz) / det;
|
|
102
|
+
if (u < 0 || u > 1) continue;
|
|
103
|
+
const qx = ty * e1z - tz * e1y, qy = tz * e1x - tx * e1z, qz = tx * e1y - ty * e1x;
|
|
104
|
+
const v = (dx * qx + dy * qy + dz * qz) / det;
|
|
105
|
+
if (v < 0 || u + v > 1) continue;
|
|
106
|
+
if ((e2x * qx + e2y * qy + e2z * qz) / det > 1e-6) hits++;
|
|
107
|
+
}
|
|
108
|
+
if (hits % 2 === 0) return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function three() {
|
|
114
|
+
const L = lastPersp || last;
|
|
115
|
+
if (!L) return null;
|
|
116
|
+
const { scene, camera } = L;
|
|
117
|
+
const e = camera.matrixWorld.elements;
|
|
118
|
+
const fx = -e[8], fy = -e[9], fz = -e[10], fl = Math.hypot(fx, fy, fz) || 1;
|
|
119
|
+
const now = performance.now();
|
|
120
|
+
if (!subject || now - subjectAt > 2000 || !subject.parent) {
|
|
121
|
+
subjectAt = now; subject = null;
|
|
122
|
+
let n = 0;
|
|
123
|
+
scene.traverse(o => { if (!subject && n++ < 5000 && o !== scene && typeof o.name === 'string' && SUBJECT.test(o.name)) subject = o; });
|
|
124
|
+
}
|
|
125
|
+
const groups = new Set([top(camera, scene)]);
|
|
126
|
+
if (subject) groups.add(top(subject, scene));
|
|
127
|
+
const V = camera.position.constructor, M = camera.matrixWorld.constructor;
|
|
128
|
+
const p = new V(e[12], e[13], e[14]), local = new V(), inv = new M();
|
|
129
|
+
const inside = [];
|
|
130
|
+
let visited = 0, meshes = 0;
|
|
131
|
+
const needFloor = !floorAt || now - floorAt > 3000;
|
|
132
|
+
let low = Infinity;
|
|
133
|
+
const corner = new V();
|
|
134
|
+
scene.traverse(o => {
|
|
135
|
+
if (visited++ > 4000 || !o.isMesh) return;
|
|
136
|
+
meshes++;
|
|
137
|
+
if (!solid(o) || groups.has(top(o, scene))) return;
|
|
138
|
+
const b = bbox(o);
|
|
139
|
+
if (!b || b.isEmpty()) return;
|
|
140
|
+
if (needFloor) {
|
|
141
|
+
for (let i = 0; i < 8; i++) {
|
|
142
|
+
corner.set(i & 1 ? b.max.x : b.min.x, i & 2 ? b.max.y : b.min.y, i & 4 ? b.max.z : b.min.z).applyMatrix4(o.matrixWorld);
|
|
143
|
+
if (corner.y < low) low = corner.y;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const sx = b.max.x - b.min.x, sy = b.max.y - b.min.y, sz = b.max.z - b.min.z;
|
|
147
|
+
if (sx < 0.05 || sy < 0.05 || sz < 0.05 || inside.length >= 5) return;
|
|
148
|
+
local.copy(p).applyMatrix4(inv.copy(o.matrixWorld).invert());
|
|
149
|
+
const m = Math.min(sx, sy, sz) * 0.02;
|
|
150
|
+
if (local.x > b.min.x + m && local.x < b.max.x - m && local.y > b.min.y + m && local.y < b.max.y - m && local.z > b.min.z + m && local.z < b.max.z - m && enclosed(o.geometry, local.x, local.y, local.z)) inside.push(String(o.name || o.geometry.type || 'mesh').slice(0, 40));
|
|
151
|
+
});
|
|
152
|
+
if (needFloor && (low < Infinity || meshes !== floorCount)) { floor = low < Infinity ? low : null; floorAt = now; floorCount = meshes; }
|
|
153
|
+
const s = subject ? subject.matrixWorld.elements : null;
|
|
154
|
+
return {
|
|
155
|
+
engine: 'three', camera: [r3(e[12]), r3(e[13]), r3(e[14])],
|
|
156
|
+
yaw: r3(Math.atan2(-fx, -fz)), pitch: r3(Math.asin(Math.max(-1, Math.min(1, fy / fl)))), roll: r3(Math.atan2(-e[1], e[5])),
|
|
157
|
+
subject: subject ? String(subject.name).slice(0, 40) : 'camera', pos: s ? [r3(s[12]), r3(s[13]), r3(s[14])] : [r3(e[12]), r3(e[13]), r3(e[14])],
|
|
158
|
+
inside, floorY: floor === null ? null : r3(floor), meshes
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function babylon() {
|
|
163
|
+
const B = window.BABYLON;
|
|
164
|
+
const scene = B && ((B.EngineStore && B.EngineStore.LastCreatedScene) || (B.Engine && B.Engine.LastCreatedScene));
|
|
165
|
+
const cam = scene && scene.activeCamera;
|
|
166
|
+
if (!cam || !cam.globalPosition) return null;
|
|
167
|
+
const c = cam.globalPosition, d = typeof cam.getForwardRay === 'function' ? cam.getForwardRay(1).direction : null;
|
|
168
|
+
const who = typeof scene.getMeshByName === 'function' ? (['player', 'Player', 'hero', 'car', 'ship'].map(n => scene.getMeshByName(n)).find(Boolean) || null) : null;
|
|
169
|
+
const w = who && who.getAbsolutePosition ? who.getAbsolutePosition() : null;
|
|
170
|
+
return {
|
|
171
|
+
engine: 'babylon', camera: [r3(c.x), r3(c.y), r3(c.z)],
|
|
172
|
+
yaw: d ? r3(Math.atan2(d.x, d.z)) : null, pitch: d ? r3(Math.asin(Math.max(-1, Math.min(1, d.y)))) : null, roll: null,
|
|
173
|
+
subject: who ? String(who.name).slice(0, 40) : 'camera', pos: w ? [r3(w.x), r3(w.y), r3(w.z)] : [r3(c.x), r3(c.y), r3(c.z)],
|
|
174
|
+
inside: [], floorY: null, meshes: Array.isArray(scene.meshes) ? scene.meshes.length : 0
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// The view a Ravensight SDK publishes (section 10), as text and back: only plain data leaves the page, at most 4,096
|
|
179
|
+
// characters of it. Nothing is checked here; `cleanPose` checks it outside the page, where the page cannot reach.
|
|
180
|
+
function sdk() {
|
|
181
|
+
const f = window.__ravensightView3d;
|
|
182
|
+
if (typeof f !== 'function') return null;
|
|
183
|
+
const v = call(f, undefined, []);
|
|
184
|
+
if (v === null || typeof v !== 'object') return null;
|
|
185
|
+
const text = toJson(v);
|
|
186
|
+
if (typeof text !== 'string' || text.length > 4096) return null;
|
|
187
|
+
return { engine: 'sdk', view: fromJson(text) };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const guard = read => { try { return read(); } catch { return null; } };
|
|
191
|
+
Object.defineProperty(window, '__rsScene3d', { value: () => guard(three) || guard(babylon) || guard(sdk), enumerable: false });
|
|
192
|
+
}
|
|
193
|
+
/* c8 ignore stop */
|
|
194
|
+
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
// The pure side.
|
|
197
|
+
|
|
198
|
+
export const WORLD3D_LIMITS = Object.freeze({
|
|
199
|
+
// Less than this is no movement (world units, usually metres) and no turn (radians).
|
|
200
|
+
moveEps: 0.05, turnEps: 0.01,
|
|
201
|
+
// Stuck: this many movement inputs in a row, received, that left the player within stuckRadius of where the stretch began.
|
|
202
|
+
stuckSteps: 3, stuckRadius: 0.15, movedBefore: 0.5,
|
|
203
|
+
// Fell out of the world: further below the level's lowest point than this, still going down, and at least fallDepth below it at the end.
|
|
204
|
+
fallBelow: 2, fallDepth: 20,
|
|
205
|
+
// No way forward: at least lostSteps inputs to the end of play, a whole turn or more, at least lostPath walked, and a path lostRatio times
|
|
206
|
+
// as long as the stretch ever got from its own middle.
|
|
207
|
+
lostSteps: 10, lostTurn: 2 * Math.PI, lostPath: 10, lostRatio: 5,
|
|
208
|
+
// A dead input: tried this many times (with the pose known), or lookFrames times with frames alone.
|
|
209
|
+
deadTries: 2, deadFrames: 3,
|
|
210
|
+
// A drag or swipe tried this far apart (px) was not aimed at one dead spot; one that stopped is retried within samePlacePx.
|
|
211
|
+
apartPx: 150, samePlacePx: 100,
|
|
212
|
+
// Blocked: a movement input that went less than this share of the run's usual distance for the time it was held.
|
|
213
|
+
blockedShare: 0.3, blockedPlaces: 2, blockedApart: 2,
|
|
214
|
+
// A key pressed at two places this far apart, or two facings this far apart, is not one wall in the way.
|
|
215
|
+
apart: 0.5, facings: 0.5
|
|
216
|
+
});
|
|
217
|
+
const L = WORLD3D_LIMITS;
|
|
218
|
+
|
|
219
|
+
const fin = v => (typeof v === 'number' && Number.isFinite(v) ? v : null);
|
|
220
|
+
const vec = v => (Array.isArray(v) && v.length === 3 && v.every(x => fin(x) !== null) ? v.map(x => Math.round(x * 1000) / 1000) : null);
|
|
221
|
+
const plain = (s, n = 40) => String(s ?? '').replace(/[‒-―−-]/g, ' ').replace(/[^\p{L}\p{N} _.()]/gu, '').replace(/\s+/g, ' ').trim().slice(0, n);
|
|
222
|
+
|
|
223
|
+
/** What a page said of its pose, checked: `{ engine, camera, yaw, pitch, roll, subject, pos, inside, floorY }` or null. */
|
|
224
|
+
export function cleanPose(raw) {
|
|
225
|
+
if (!raw || typeof raw !== 'object') return null;
|
|
226
|
+
if (raw.engine === 'sdk' && Object.hasOwn(raw, 'view')) return poseFromView3d(raw.view);
|
|
227
|
+
const camera = vec(raw.camera), pos = vec(raw.pos) || camera;
|
|
228
|
+
if (!camera || !pos) return null;
|
|
229
|
+
return {
|
|
230
|
+
engine: raw.engine === 'babylon' || raw.engine === 'sdk' ? raw.engine : 'three',
|
|
231
|
+
camera, pos,
|
|
232
|
+
yaw: fin(raw.yaw), pitch: fin(raw.pitch), roll: fin(raw.roll),
|
|
233
|
+
subject: plain(raw.subject) || 'camera',
|
|
234
|
+
inside: (Array.isArray(raw.inside) ? raw.inside : []).slice(0, 5).map(n => plain(n) || 'mesh'),
|
|
235
|
+
floorY: fin(raw.floorY)
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// The 3D view a Ravensight SDK publishes on the page (the platform's PAUSE_HOOK_CONTRACT.md sections 9 and 10, vectors
|
|
240
|
+
// `view3d.runner` and `web.pose`). Never repaired: anything malformed drops the whole view, as if the page had none, so it can
|
|
241
|
+
// never become a finding. A view the game itself says is paused is dropped too: an input then moves nothing, by design.
|
|
242
|
+
export const VIEW3D_WEB = Object.freeze({ maxBytes: 4096, maxNameChars: 64, maxAbs: 1000000, directionMin: 0.5, directionMax: 2 });
|
|
243
|
+
const isObj = v => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
244
|
+
const r3z = v => Math.round(v * 1000) / 1000 || 0;
|
|
245
|
+
const vec3 = v => (Array.isArray(v) && v.length === 3 && v.every(n => typeof n === 'number' && Number.isFinite(n) && Math.abs(n) <= VIEW3D_WEB.maxAbs) ? v.slice() : null);
|
|
246
|
+
function unit3(v) {
|
|
247
|
+
const u = vec3(v);
|
|
248
|
+
const n = u ? Math.hypot(u[0], u[1], u[2]) : 0;
|
|
249
|
+
return u && n >= VIEW3D_WEB.directionMin && n <= VIEW3D_WEB.directionMax ? u.map(x => x / n) : null;
|
|
250
|
+
}
|
|
251
|
+
// eslint-disable-next-line no-control-regex
|
|
252
|
+
const wireName = v => (typeof v === 'string' && Array.from(v).length >= 1 && Array.from(v).length <= VIEW3D_WEB.maxNameChars && !/[\u0000-\u001f\u007f]/.test(v) ? v : null);
|
|
253
|
+
const bool = v => typeof v === 'boolean';
|
|
254
|
+
|
|
255
|
+
/** The pose for a view an SDK published (`web.pose`), or null to drop it. */
|
|
256
|
+
export function poseFromView3d(view) {
|
|
257
|
+
if (!isObj(view)) return null;
|
|
258
|
+
let bytes;
|
|
259
|
+
try { bytes = new TextEncoder().encode(JSON.stringify(view)).length; } catch { return null; }
|
|
260
|
+
if (bytes > VIEW3D_WEB.maxBytes) return null;
|
|
261
|
+
const c = view.camera;
|
|
262
|
+
if (!isObj(c)) return null;
|
|
263
|
+
const camera = vec3(c.position), f = unit3(c.forward), u = unit3(c.up);
|
|
264
|
+
if (!camera || !f || !u || !bool(c.obstructed)) return null;
|
|
265
|
+
const by = c.obstructed_by === undefined ? null : wireName(c.obstructed_by);
|
|
266
|
+
if (c.obstructed_by !== undefined && !by) return null;
|
|
267
|
+
if (view.game_paused !== undefined && !bool(view.game_paused)) return null;
|
|
268
|
+
let player = null;
|
|
269
|
+
if (view.player !== undefined && view.player !== null) {
|
|
270
|
+
const p = view.player;
|
|
271
|
+
if (!isObj(p)) return null;
|
|
272
|
+
player = { name: wireName(p.name), at: vec3(p.position) };
|
|
273
|
+
if (!player.name || !player.at || !vec3(p.velocity) || !bool(p.grounded) || !bool(p.against_wall)) return null;
|
|
274
|
+
}
|
|
275
|
+
let floorY = null;
|
|
276
|
+
if (view.world !== undefined && view.world !== null) {
|
|
277
|
+
const w = view.world;
|
|
278
|
+
if (!isObj(w)) return null;
|
|
279
|
+
const min = vec3(w.min), max = vec3(w.max);
|
|
280
|
+
if (!min || !max || min.some((n, i) => n > max[i])) return null;
|
|
281
|
+
floorY = r3z(min[1]);
|
|
282
|
+
}
|
|
283
|
+
if (view.game_paused === true) return null;
|
|
284
|
+
// Roll as three.js gives it: the camera's right (forward x up) against its up.
|
|
285
|
+
const rightY = f[2] * u[0] - f[0] * u[2];
|
|
286
|
+
return {
|
|
287
|
+
engine: 'sdk', camera: camera.map(r3z),
|
|
288
|
+
yaw: r3z(Math.atan2(-f[0], -f[2])), pitch: r3z(Math.asin(Math.max(-1, Math.min(1, f[1])))), roll: r3z(Math.atan2(-rightY || 0, u[1])),
|
|
289
|
+
subject: player ? plain(player.name) || 'player' : 'camera', pos: (player ? player.at : camera).map(r3z),
|
|
290
|
+
inside: c.obstructed ? [plain(by) || 'level geometry'] : [], floorY
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
295
|
+
const flat = (a, b) => Math.hypot(a[0] - b[0], a[2] - b[2]);
|
|
296
|
+
const angle = (a, b) => { if (a === null || b === null) return 0; let d = b - a; while (d > Math.PI) d -= 2 * Math.PI; while (d < -Math.PI) d += 2 * Math.PI; return Math.abs(d); };
|
|
297
|
+
/** How a pose changed: `{ moved, camMoved, turned }`. */
|
|
298
|
+
export function poseChange(a, b) {
|
|
299
|
+
if (!a || !b) return null;
|
|
300
|
+
return { moved: dist(a.pos, b.pos), camMoved: dist(a.camera, b.camera), turned: angle(a.yaw, b.yaw) + angle(a.pitch, b.pitch) + angle(a.roll, b.roll) };
|
|
301
|
+
}
|
|
302
|
+
const changed = c => Boolean(c && (c.moved > L.moveEps || c.camMoved > L.moveEps || c.turned > L.turnEps));
|
|
303
|
+
const at = p => `x ${p[0].toFixed(1)}, y ${p[1].toFixed(1)}, z ${p[2].toFixed(1)}`;
|
|
304
|
+
const deg = r => Math.round((r * 180) / Math.PI);
|
|
305
|
+
const plural = (n, w) => `${n} ${w}${n === 1 ? '' : 's'}`;
|
|
306
|
+
|
|
307
|
+
// Keys that move a player in most 3D games, by their lower-case names.
|
|
308
|
+
const MOVE_KEY = /^(?:w|a|s|d|arrowup|arrowdown|arrowleft|arrowright)$/;
|
|
309
|
+
/** A key name as the checks compare them: "KeyW", "W" and "w" are all "w". */
|
|
310
|
+
export const keyWord = k => String(k || '').replace(/^Key(?=[A-Z]$)/, '').replace(/^Digit(?=\d$)/, '').toLowerCase();
|
|
311
|
+
const isMove = s => s.kind === 'stick' || (s.kind === 'key' && s.keys.length > 0 && s.keys.some(k => MOVE_KEY.test(k)));
|
|
312
|
+
// Which ways an input pushes the player: forward, back, left, right.
|
|
313
|
+
const WAY = { w: 'f', arrowup: 'f', s: 'b', arrowdown: 'b', a: 'l', arrowleft: 'l', d: 'r', arrowright: 'r' };
|
|
314
|
+
function waysOf(s) {
|
|
315
|
+
if (s.kind === 'stick' && s.push) return [s.push.dy < -10 ? 'f' : s.push.dy > 10 ? 'b' : null, s.push.dx < -10 ? 'l' : s.push.dx > 10 ? 'r' : null].filter(Boolean);
|
|
316
|
+
return [...new Set((s.keys || []).map(k => WAY[k]).filter(Boolean))];
|
|
317
|
+
}
|
|
318
|
+
const opposite = ways => (ways.has('f') && ways.has('b')) || (ways.has('l') && ways.has('r'));
|
|
319
|
+
const px = (a, b) => (a && b ? Math.hypot(a.x - b.x, a.y - b.y) : null);
|
|
320
|
+
// The game's own words asking for a key: "Press E to pull the lever", "press [F] to open".
|
|
321
|
+
const PROMPT = /\bpress\s+(?:the\s+)?\[?([a-z0-9]|space|enter)\]?(?:\s+key)?\s+to\b[^.!?\n]{0,60}/i;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* One step as the 3D checks read it, built by each repo from its own record:
|
|
325
|
+
* `{ step, kind, keys, ms, from, push, received, captured, changed, selfOnly, blank, before, after, text, textAfter, shotBefore, shotAfter, label }`.
|
|
326
|
+
* `kind` is key, look, drag, swipe, scroll, stick, click, wait or other; `keys` the key names held (lower case); `received`
|
|
327
|
+
* whether the page got the input (true, false or null for unknown); `captured` for a look, whether the mouse was held by the
|
|
328
|
+
* game; `changed` whether the screen changed; `selfOnly` when only the screen's own motion did; `before` and `after` poses;
|
|
329
|
+
* `ms` how long the input was held; `from` where a drag, swipe, wheel or stick began ({ x, y }, screen pixels); `push` a stick's
|
|
330
|
+
* push ({ dx, dy }). Any of the last three may be null. `blank` when the screen after the input was one flat colour: a
|
|
331
|
+
* screen that shows nothing cannot show a turn, so such a step is never counted as an input that did nothing by its frames.
|
|
332
|
+
*/
|
|
333
|
+
export function world3dFindings(steps, { won = false } = {}) {
|
|
334
|
+
const list = (Array.isArray(steps) ? steps : []).filter(s => s && Number.isSafeInteger(s.step));
|
|
335
|
+
const out = [];
|
|
336
|
+
// A look or a movement input with the pose known both sides is judged by the pose alone: a HUD note fading or a clock ticking
|
|
337
|
+
// changes the screen, not the view. Anything else answered when the pose or the screen changed.
|
|
338
|
+
const byPose = s => Boolean(s.before && s.after) && (s.kind === 'look' || s.kind === 'stick' || (s.kind === 'key' && s.keys.some(k => MOVE_KEY.test(k))));
|
|
339
|
+
const responded = s => changed(poseChange(s.before, s.after)) || (!byPose(s) && s.changed === true && !s.selfOnly);
|
|
340
|
+
const posed = s => Boolean(s.before && s.after);
|
|
341
|
+
const shots = ss => [...new Set(ss.flatMap(s => [s.shotBefore, s.shotAfter]).filter(Boolean))].slice(0, 3);
|
|
342
|
+
|
|
343
|
+
// An input that changed nothing. With the pose known: tried at least twice, the page received it every time, neither the pose
|
|
344
|
+
// nor the screen moved, and other inputs in the same run moved the pose (the game was in play). With frames alone: a look the
|
|
345
|
+
// game held the mouse for, three times or more, or a drag, a swipe or the wheel that worked earlier and then three times did not.
|
|
346
|
+
const sig = s => (s.kind === 'key' ? `key ${s.keys.join('+')}` : s.kind);
|
|
347
|
+
const groups = new Map();
|
|
348
|
+
for (const s of list) {
|
|
349
|
+
if (!['key', 'look', 'drag', 'swipe', 'scroll', 'stick'].includes(s.kind)) continue;
|
|
350
|
+
if (s.kind === 'key' && !s.keys.some(k => MOVE_KEY.test(k))) continue;
|
|
351
|
+
if (!groups.has(sig(s))) groups.set(sig(s), []);
|
|
352
|
+
groups.get(sig(s)).push(s);
|
|
353
|
+
}
|
|
354
|
+
const live = list.some(s => posed(s) && changed(poseChange(s.before, s.after)));
|
|
355
|
+
for (const [name, ss] of groups) {
|
|
356
|
+
// A look counts only when the game held the mouse it was delivered to: a free mouse moving need not turn anything.
|
|
357
|
+
const heard = ss.filter(s => (s.kind === 'look' ? s.captured === true : s.received === true));
|
|
358
|
+
if (!heard.length || heard.some(responded)) {
|
|
359
|
+
// Worked at some point: a drag, a swipe or the wheel that then stopped (frames alone).
|
|
360
|
+
if (!['drag', 'swipe', 'scroll'].includes(name)) continue;
|
|
361
|
+
const lastGood = heard.findLastIndex(responded);
|
|
362
|
+
// Begun where it worked before: a drag that starts somewhere else may be aimed at nothing.
|
|
363
|
+
const after = heard.slice(lastGood + 1).filter(s => lastGood < 0 || px(s.from, heard[lastGood].from) === null || px(s.from, heard[lastGood].from) <= L.samePlacePx);
|
|
364
|
+
if (lastGood < 0 || after.length < L.deadFrames) continue;
|
|
365
|
+
const others = list.filter(s => s.step > after[0].step && !ss.includes(s) && s.kind !== 'wait' && s.changed === true && !s.selfOnly);
|
|
366
|
+
if (!others.length) continue;
|
|
367
|
+
out.push({
|
|
368
|
+
kind: 'stopped_input', key: `world3d:stopped:${name}`, atStep: after[0].step, severity: 'major', category: 'bug',
|
|
369
|
+
title: `${verb(name)} stopped having any effect`,
|
|
370
|
+
description: `${verb(name)} changed the screen at step ${heard[lastGood].step}. From step ${after[0].step} on it was tried ${plural(after.length, 'more time')} (steps ${after.map(s => s.step).join(', ')}); the page received the input each time and the screen did not change, while ${others[0].label ? `"${plain(others[0].label, 60)}"` : 'another input'} at step ${others[0].step} still changed it.`,
|
|
371
|
+
steps: [heard[lastGood], ...after].map(s => s.step), shots: shots([after[0], after.at(-1)]),
|
|
372
|
+
facts: { tries: after.length, worked: heard[lastGood].step }
|
|
373
|
+
});
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (name.startsWith('key ') || name === 'stick') {
|
|
377
|
+
// A movement key: only with the pose, pressed at two places or facings, and the game in play.
|
|
378
|
+
const withPose = heard.filter(posed);
|
|
379
|
+
if (withPose.length < L.deadTries || !live) continue;
|
|
380
|
+
const spread = withPose.some(a => withPose.some(b => flat(a.before.pos, b.before.pos) > L.apart || poseChange(a.before, b.before).turned > L.facings));
|
|
381
|
+
if (!spread) continue;
|
|
382
|
+
const k = name === 'stick' ? 'the on screen stick' : name.slice(4).toUpperCase();
|
|
383
|
+
out.push({
|
|
384
|
+
kind: 'dead_input', key: `world3d:dead:${name}`, atStep: withPose[0].step, severity: 'major', category: 'bug',
|
|
385
|
+
title: `${verb(name)} did nothing`,
|
|
386
|
+
description: `The player ${name === 'stick' ? 'pushed' : 'pressed'} ${k} ${plural(withPose.length, 'time')} (steps ${withPose.map(s => s.step).join(', ')}), from different places or facings. The page received the input every time, and neither the player (${withPose[0].after.subject === 'camera' ? 'the camera' : `"${withPose[0].after.subject}"`}) nor the view moved, while other inputs in the same run did move it.`,
|
|
387
|
+
steps: withPose.map(s => s.step), shots: shots([withPose[0], withPose.at(-1)]),
|
|
388
|
+
facts: { tries: withPose.length, key: k, at: withPose[0].before.pos }
|
|
389
|
+
});
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
const withPose = heard.filter(posed);
|
|
393
|
+
const frameOnly = heard.filter(s => !posed(s) && !s.blank && (s.changed === false || s.selfOnly));
|
|
394
|
+
const enough = withPose.length >= L.deadTries ? withPose : frameOnly.length >= L.deadFrames && name === 'look' ? frameOnly : null;
|
|
395
|
+
if (!enough) continue;
|
|
396
|
+
// A drag, a swipe or the wheel that did nothing in one spot may be aimed where the game takes none: it must have been tried
|
|
397
|
+
// in places far apart (or, where the places are not known, three times).
|
|
398
|
+
if (name !== 'look') {
|
|
399
|
+
const placed = enough.every(s => s.from);
|
|
400
|
+
if (placed ? !enough.some(a => enough.some(b => px(a.from, b.from) >= L.apartPx)) : enough.length < L.deadFrames) continue;
|
|
401
|
+
}
|
|
402
|
+
// The game was in play: with the pose, another input moved it; with frames alone, another input changed the screen.
|
|
403
|
+
const alive = enough === withPose ? live : list.some(s => !ss.includes(s) && s.kind !== 'wait' && s.changed === true && !s.selfOnly);
|
|
404
|
+
if (!alive) continue;
|
|
405
|
+
out.push({
|
|
406
|
+
kind: 'dead_input', key: `world3d:dead:${name}`, atStep: enough[0].step, severity: 'major', category: 'bug',
|
|
407
|
+
title: `${verb(name)} did nothing`,
|
|
408
|
+
description: `${verb(name)} was tried ${plural(enough.length, 'time')} (steps ${enough.map(s => s.step).join(', ')}). ${name === 'look' ? 'The game held the mouse each time and the movement was delivered to it' : 'The page received the input each time'}, and ${enough === withPose ? 'the view did not turn or move' : 'the screen did not change'}, while other inputs in the same run ${enough === withPose ? 'moved it' : 'changed it'}.`,
|
|
409
|
+
steps: enough.map(s => s.step), shots: shots([enough[0], enough.at(-1)]),
|
|
410
|
+
facts: { tries: enough.length, measured: enough === withPose ? 'pose' : 'frames' }
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Stuck on geometry: movement worked earlier; then movement inputs in a row, by two keys or two facings, all received, left the
|
|
415
|
+
// player where the stretch began, while the view could still turn (the game was in play, not in a menu).
|
|
416
|
+
let i = 0;
|
|
417
|
+
while (i < list.length) {
|
|
418
|
+
const s = list[i];
|
|
419
|
+
if (!(isMove(s) && s.received === true && posed(s) && poseChange(s.before, s.after).moved <= L.stuckRadius)) { i++; continue; }
|
|
420
|
+
let j = i;
|
|
421
|
+
const run = [];
|
|
422
|
+
while (j < list.length) {
|
|
423
|
+
const t = list[j];
|
|
424
|
+
if (t.kind === 'wait' || (t.kind === 'look' && posed(t))) { if (t.kind === 'look') run.push(t); j++; continue; }
|
|
425
|
+
if (!(isMove(t) && t.received === true && posed(t) && dist(s.before.pos, t.after.pos) <= L.stuckRadius * 2)) break;
|
|
426
|
+
run.push(t); j++;
|
|
427
|
+
}
|
|
428
|
+
const moves = run.filter(isMove);
|
|
429
|
+
const earlier = list.slice(0, i).some(t => isMove(t) && posed(t) && poseChange(t.before, t.after).moved > L.movedBefore);
|
|
430
|
+
// Tried opposite ways (forward and back, or left and right), so it is not one wall in front of the player.
|
|
431
|
+
// An input that turned the view was answered (arrows often turn): only those that neither moved nor turned count as tries.
|
|
432
|
+
const ways = opposite(new Set(moves.filter(t => poseChange(t.before, t.after).turned <= L.turnEps).flatMap(waysOf)));
|
|
433
|
+
const turning = run.some(t => poseChange(t.before, t.after).turned > L.turnEps);
|
|
434
|
+
if (moves.length >= L.stuckSteps && earlier && ways && turning) {
|
|
435
|
+
out.push({
|
|
436
|
+
kind: 'stuck', key: `world3d:stuck:${s.step}`, atStep: s.step, severity: 'major', category: 'level_design',
|
|
437
|
+
title: `The player got stuck at ${at(s.before.pos)}`,
|
|
438
|
+
description: `Movement worked earlier in the run. From step ${moves[0].step} to step ${moves.at(-1).step} the player tried ${plural(moves.length, 'movement input')} (${[...new Set(moves.map(t => t.keys.map(k => k.toUpperCase()).join('+') || t.kind))].join(', ')}), in opposite directions; the page received each one and the view still turned, but the player stayed within ${(L.stuckRadius * 2).toFixed(1)} units of ${at(s.before.pos)}.`,
|
|
439
|
+
steps: run.map(t => t.step), shots: shots([moves[0], moves.at(-1)]),
|
|
440
|
+
facts: { at: s.before.pos, tries: moves.length }
|
|
441
|
+
});
|
|
442
|
+
i = j;
|
|
443
|
+
} else i = Math.max(i + 1, j);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Fell out of the world: below the level's lowest point, still going down at the end of play, and far below it.
|
|
447
|
+
const posedSteps = list.filter(posed);
|
|
448
|
+
const last = posedSteps.at(-1);
|
|
449
|
+
if (last && last.after.floorY !== null) {
|
|
450
|
+
const floorY = last.after.floorY, y = p => p.pos[1];
|
|
451
|
+
const firstBelow = posedSteps.findIndex(t => y(t.after) < floorY - L.fallBelow);
|
|
452
|
+
const tail = firstBelow >= 0 ? posedSteps.slice(firstBelow) : [];
|
|
453
|
+
const stayed = tail.length && tail.every(t => y(t.after) < floorY - L.fallBelow);
|
|
454
|
+
const falling = tail.length >= 2 && y(tail.at(-1).after) < y(tail.at(-2).after);
|
|
455
|
+
// Play reached the game: an input it received came at or before the fall, so the pose is not the page's word alone.
|
|
456
|
+
const played = tail.length > 0 && list.some(t => t.step <= tail[0].step && (t.received === true || t.captured === true));
|
|
457
|
+
if (stayed && falling && played && y(last.after) < floorY - L.fallDepth) {
|
|
458
|
+
const f = tail[0];
|
|
459
|
+
out.push({
|
|
460
|
+
kind: 'fell_out', key: 'world3d:fell', atStep: f.step, severity: 'major', category: 'bug',
|
|
461
|
+
title: 'The player fell out of the world',
|
|
462
|
+
description: `At step ${f.step} the player (${f.after.subject === 'camera' ? 'the camera' : `"${f.after.subject}"`}) went below the lowest point of the level (height ${floorY.toFixed(1)}) and never came back: at the end of play, step ${last.step}, it was at height ${y(last.after).toFixed(1)} and still falling. Nothing put it back on the level.`,
|
|
463
|
+
steps: [list[list.indexOf(f) - 1], f, last].filter(Boolean).map(t => t.step), shots: shots([f, last]),
|
|
464
|
+
facts: { floorY, at: f.after.pos, endY: y(last.after) }
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// The camera inside a solid: the first input the page received after which the camera was inside a box the game draws as solid.
|
|
470
|
+
const named = new Set();
|
|
471
|
+
for (const s of list) {
|
|
472
|
+
if (!s.after || !s.after.inside.length || s.kind === 'wait' || !(s.received === true || s.captured === true)) continue;
|
|
473
|
+
const fresh = s.after.inside.filter(n => !named.has(n));
|
|
474
|
+
if (!fresh.length) continue;
|
|
475
|
+
fresh.forEach(n => named.add(n));
|
|
476
|
+
out.push({
|
|
477
|
+
kind: 'camera_inside', key: `world3d:inside:${fresh[0]}`, atStep: s.step, severity: 'minor', category: 'bug',
|
|
478
|
+
title: `The camera went inside "${fresh[0]}"`,
|
|
479
|
+
description: `After step ${s.step}${s.label ? ` ("${plain(s.label, 60)}")` : ''} the camera was at ${at(s.after.camera)}, inside the solid box of "${fresh[0]}"${fresh.length > 1 ? ` (and ${fresh.slice(1).map(n => `"${n}"`).join(', ')})` : ''}. From inside, its faces are not drawn, so the player sees through it or sees only its inside.`,
|
|
480
|
+
steps: [s.step], shots: shots([s]).slice(-1),
|
|
481
|
+
facts: { camera: s.after.camera, mesh: fresh[0] }
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// A prompt that asks for a key the game then ignores: "Press E to ..." on screen, E pressed and received, nothing changed.
|
|
486
|
+
const prompts = new Map();
|
|
487
|
+
for (const s of list) {
|
|
488
|
+
if (s.kind !== 'key' || s.received !== true || s.keys.length !== 1) continue;
|
|
489
|
+
const m = PROMPT.exec(s.text || '');
|
|
490
|
+
if (!m || keyWord(m[1]) !== s.keys[0]) continue;
|
|
491
|
+
const still = PROMPT.exec(s.textAfter || '');
|
|
492
|
+
if (responded(s) || !still || still[0] !== m[0]) { prompts.set(m[0].toLowerCase(), { ok: true }); continue; }
|
|
493
|
+
const k = m[0].toLowerCase(), e = prompts.get(k) || { ok: false, said: m[0], tries: [] };
|
|
494
|
+
if (!e.ok) e.tries.push(s);
|
|
495
|
+
prompts.set(k, e);
|
|
496
|
+
}
|
|
497
|
+
for (const e of prompts.values()) {
|
|
498
|
+
if (e.ok || e.tries.length < L.deadTries) continue;
|
|
499
|
+
const k = keyWord(PROMPT.exec(e.said)[1]).toUpperCase();
|
|
500
|
+
out.push({
|
|
501
|
+
kind: 'dead_prompt', key: `world3d:prompt:${e.said.toLowerCase()}`, atStep: e.tries[0].step, severity: 'major', category: 'bug',
|
|
502
|
+
title: `Pressing ${k} at "${plain(e.said, 60)}" did nothing`,
|
|
503
|
+
description: `The game showed "${plain(e.said, 80)}". The player pressed ${k} ${plural(e.tries.length, 'time')} while it was showing (steps ${e.tries.map(s => s.step).join(', ')}); the page received the key each time, the prompt stayed, and nothing else changed.`,
|
|
504
|
+
steps: e.tries.map(s => s.step), shots: shots([e.tries[0], e.tries.at(-1)]),
|
|
505
|
+
facts: { prompt: plain(e.said, 80), key: k, tries: e.tries.length }
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// No way forward: to the end of play, without a win, the player turned a whole circle and more and walked a long way, never got
|
|
510
|
+
// far from the middle of where it walked, and was stopped by something in the way at two places or more. A player who only
|
|
511
|
+
// wandered (nothing stopped it) is not evidence about the game: that may be the playtester's own way of looking round.
|
|
512
|
+
if (!won) {
|
|
513
|
+
const tailSteps = [];
|
|
514
|
+
for (let k = list.length - 1; k >= 0; k--) { const t = list[k]; if (t.kind === 'wait') continue; if (!posed(t)) break; tailSteps.unshift(t); }
|
|
515
|
+
if (tailSteps.length >= L.lostSteps) {
|
|
516
|
+
const pts = [tailSteps[0].before.pos, ...tailSteps.map(t => t.after.pos)];
|
|
517
|
+
const mid = [0, 1, 2].map(a => pts.reduce((v, p) => v + p[a], 0) / pts.length);
|
|
518
|
+
const reach = Math.max(...pts.map(p => flat(p, mid)));
|
|
519
|
+
const path = tailSteps.reduce((v, t) => v + flat(t.before.pos, t.after.pos), 0);
|
|
520
|
+
const turn = tailSteps.reduce((v, t) => v + angle(t.before.yaw, t.after.yaw), 0);
|
|
521
|
+
const stops = blockedPlaces(list, tailSteps);
|
|
522
|
+
if (turn >= L.lostTurn && path >= L.lostPath && reach > 0 && path >= L.lostRatio * reach && stops.length >= L.blockedPlaces) {
|
|
523
|
+
out.push({
|
|
524
|
+
kind: 'no_way_forward', key: 'world3d:lost', atStep: tailSteps[0].step, severity: 'minor', category: 'level_design',
|
|
525
|
+
title: 'The player went round in circles and found no way forward',
|
|
526
|
+
description: `From step ${tailSteps[0].step} to the end of play (step ${tailSteps.at(-1).step}) the player turned ${deg(turn)} degrees in all and walked ${path.toFixed(1)} units, but never got more than ${reach.toFixed(1)} units from the middle of where it walked. Something in the way stopped it at ${plural(stops.length, 'place')} (${stops.map(t => `step ${t.step}, at ${at(t.before.pos)}`).join('; ')}), and the game was not won.`,
|
|
527
|
+
steps: [tailSteps[0], ...stops, tailSteps.at(-1)].map(t => t.step).filter((v, k, a) => a.indexOf(v) === k), shots: shots([stops[0], tailSteps.at(-1)]),
|
|
528
|
+
facts: { turnDegrees: deg(turn), path: Math.round(path * 10) / 10, reach: Math.round(reach * 10) / 10, blocked: stops.length }
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return out;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Movement inputs of `among` that something stopped: held long enough, received, and moved the player less than blockedShare of
|
|
538
|
+
* the run's usual distance for that time (the median over the run's movement inputs that moved), one a place (places at least
|
|
539
|
+
* blockedApart apart).
|
|
540
|
+
*/
|
|
541
|
+
function blockedPlaces(all, among) {
|
|
542
|
+
const speed = t => (t.ms > 0 && t.before && t.after ? flat(t.before.pos, t.after.pos) / t.ms : null);
|
|
543
|
+
const moving = all.filter(t => isMove(t) && t.received === true && speed(t) !== null && flat(t.before.pos, t.after.pos) > L.moveEps).map(speed).sort((a, b) => a - b);
|
|
544
|
+
if (!moving.length) return [];
|
|
545
|
+
const usual = moving[Math.floor(moving.length / 2)];
|
|
546
|
+
const out = [];
|
|
547
|
+
for (const t of among) {
|
|
548
|
+
if (!isMove(t) || t.received !== true || !(t.ms >= 200) || speed(t) === null || speed(t) >= L.blockedShare * usual || poseChange(t.before, t.after).turned > L.turnEps) continue;
|
|
549
|
+
if (out.some(o => flat(o.before.pos, t.before.pos) < L.blockedApart)) continue;
|
|
550
|
+
out.push(t);
|
|
551
|
+
}
|
|
552
|
+
return out;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function verb(name) {
|
|
556
|
+
if (name === 'look') return 'Turning the view';
|
|
557
|
+
if (name === 'drag') return 'Dragging';
|
|
558
|
+
if (name === 'swipe') return 'Swiping';
|
|
559
|
+
if (name === 'scroll') return 'Turning the mouse wheel';
|
|
560
|
+
if (name === 'stick') return 'Pushing the on screen stick';
|
|
561
|
+
return `Pressing ${name.slice(4).toUpperCase()}`;
|
|
562
|
+
}
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
"comment": "Hashes of the files shared by the hosted runner (lib/anygame/*.mjs including gamenotes, and lib/claimwords.mjs, lib/events.mjs, lib/eventclaims.mjs, lib/egress.mjs) and the local CLI (src/run/anygame/*.js, and src/run/claimwords.js, src/run/events.js, src/run/eventclaims.js, src/run/egress.js), taken over the code both carry (see shared.mjs or shared.js). The same file in both repos: update it in both, after copying the change.",
|
|
3
3
|
"files": {
|
|
4
4
|
"language": "2b95828c77a8e82440c53d330381b7ba830796312d2ae9b7edc8fd95ff72e1ef",
|
|
5
|
-
"memory": "
|
|
5
|
+
"memory": "76ad175baeb3f066ff566f76460d4b414c545f683fe4fe0ab16b0125a63d3fce",
|
|
6
6
|
"controlbook": "1b388c0dd0c60f332131a095cf89eb4ee181671c60a2b4e45750a0a918c6ea9e",
|
|
7
|
-
"genre": "
|
|
7
|
+
"genre": "605e550f1f26c1ed68d68d51ac1e38ae10d986eb80603f9a255b51be134fc666",
|
|
8
|
+
"genre2d": "1d4f0178b8b0157f8d655eaaccf62e6afbd7851aec5e0bf019ebf2264b7b170b",
|
|
8
9
|
"sound": "bc1264cb971417f4c6c6966ecba217721e59bc30dc069b48ade0bf8174e1444e",
|
|
9
10
|
"gamenotes": "f0ab9c9be900c17824d6e37beeead7210bfe280573860e4d0ecd4ac2edd36678",
|
|
10
11
|
"claimwords": "6cd99897a09dae67d0b657a110476fb0f8b27ae4124da9c60b79b2b0d28133b7",
|
|
11
12
|
"events": "8b1cbb4cf48b1e1e1f1de064e2f3cbf4ecd8473d4a518c20caa3c8953a3a1708",
|
|
12
13
|
"eventclaims": "11dfdd3e0928447ce3e21408c7b2f9eedb499e92ada39ca8b48222646cadc23b",
|
|
13
|
-
"egress": "65053e3fc47f9746f9662da8a5bfa2c31b7252d8c66528849fd0bf0b0006dd80"
|
|
14
|
+
"egress": "65053e3fc47f9746f9662da8a5bfa2c31b7252d8c66528849fd0bf0b0006dd80",
|
|
15
|
+
"scene3d": "9d2cdbc47985935e1e81993d196bae0e1c2b7046a666113d5bb75f4ed2314a4e"
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// The files this folder shares with the hosted runner (the platform repo,
|
|
2
|
-
// infrastructure/hosted-playtest/direct-runner/lib/anygame): language, memory, controlbook, genre, sound and
|
|
2
|
+
// infrastructure/hosted-playtest/direct-runner/lib/anygame): language, memory, controlbook, genre, sound, gamenotes and scene3d are
|
|
3
3
|
// the same code in both repos, and so are four files one folder up that the
|
|
4
4
|
// claim judge, the game's own events and a run's network access use (claimwords, events, eventclaims, egress). Each repo checks its own copies against one
|
|
5
5
|
// table of hashes (shared-hashes.json, the same file in both), so a change to
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// name the other repo, and how each gets its `noDashes`.
|
|
12
12
|
import crypto from 'node:crypto';
|
|
13
13
|
|
|
14
|
-
export const SHARED = ['language', 'memory', 'controlbook', 'genre', 'sound', 'gamenotes', 'claimwords', 'events', 'eventclaims', 'egress'];
|
|
14
|
+
export const SHARED = ['language', 'memory', 'controlbook', 'genre', 'genre2d', 'sound', 'gamenotes', 'claimwords', 'events', 'eventclaims', 'egress', 'scene3d'];
|
|
15
15
|
|
|
16
16
|
// Where a shared file lives, from this folder: src/run/anygame/<name>.js, or one folder up for the four that are not any-game code
|
|
17
17
|
// (egress is a run's network access to the game's listed servers, docs/playtest-network/CONTRACT.md).
|
|
@@ -23,7 +23,7 @@ export function normalizeShared(text) {
|
|
|
23
23
|
return String(text).replace(/\r\n/g, '\n').split('\n')
|
|
24
24
|
.filter(line => !/hosted runner|platform repo|local CLI|ravensight-playtest, src|PLAYTESTER_EDGE_CASES/.test(line))
|
|
25
25
|
.filter(line => !/^import \{ noDashes \}|^const noDashes = /.test(line))
|
|
26
|
-
.map(line => line.replace(/(from '\.\/[a-
|
|
26
|
+
.map(line => line.replace(/(from '\.\/[a-z0-9]+)\.mjs'/g, "$1.js'"))
|
|
27
27
|
.join('\n').trim();
|
|
28
28
|
}
|
|
29
29
|
|