ravensight-playtest 0.13.3 → 0.17.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 +82 -1
- package/addons/ravensight_driver/driver.gd +472 -28
- package/docs/godot-driver.md +66 -2
- package/package.json +4 -4
- package/src/api/README.md +8 -1
- package/src/api/client.js +24 -1
- package/src/cli.js +19 -0
- package/src/commands/check.js +5 -2
- package/src/commands/run.js +40 -5
- package/src/commands/setup.js +176 -0
- package/src/packs/index.js +37 -5
- package/src/packs/keys.json +11 -0
- package/src/packs/pack-signing-hashes.json +7 -0
- package/src/packs/pack-signing-vectors.json +119 -0
- package/src/packs/signature.js +186 -0
- package/src/run/anygame/gamenotes.js +74 -12
- package/src/run/anygame/index.js +97 -34
- package/src/run/anygame/language.js +100 -10
- package/src/run/anygame/memory.js +70 -13
- package/src/run/anygame/shared-hashes.json +9 -8
- package/src/run/anygame/shared.js +6 -5
- package/src/run/anygame/sound.js +59 -16
- package/src/run/args.js +5 -0
- package/src/run/claimwords.js +43 -7
- package/src/run/drivers/godot-cursor.js +96 -0
- package/src/run/drivers/godot-observation.js +29 -5
- package/src/run/drivers/godot.js +60 -5
- package/src/run/drivers/web.js +181 -10
- package/src/run/egress.js +282 -0
- package/src/run/eventclaims.js +102 -6
- package/src/run/events.js +64 -6
- package/src/run/gameMemory.js +14 -5
- package/src/run/honesty.js +49 -2
- package/src/run/judge.js +22 -10
- package/src/run/liveFeed.js +254 -0
- package/src/run/networkRun.js +54 -0
- package/src/run/personaLoop.js +70 -20
- package/src/run/pixels.js +491 -2
- package/src/run/replay.js +11 -0
- package/src/run/resume.js +3 -1
- package/src/run/tools.js +2 -2
package/src/run/eventclaims.js
CHANGED
|
@@ -153,6 +153,101 @@ const ODD_VALUE = /^(?:nan|undefined|null|infinity|-infinity)$/i;
|
|
|
153
153
|
const memo = new WeakMap();
|
|
154
154
|
/** The verdicts the gate reached on this run, by claim title: for the report (lib/events.mjs). */
|
|
155
155
|
export const eventsDecided = run => (run && memo.get(run)) || new Map();
|
|
156
|
+
/** A verdict on one claim, kept for the report. */
|
|
157
|
+
const decide = (run, title) => (verdict, why, list, extra = {}) => {
|
|
158
|
+
const v = { verdict, why: noDashes(why), events: list.slice(0, 4).map(e => ({ step: e.step, name: e.name, props: e.props })), ...extra };
|
|
159
|
+
if (!memo.has(run)) memo.set(run, new Map());
|
|
160
|
+
memo.get(run).set(title, v);
|
|
161
|
+
return v;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// ---- Numbers read off the screen ---------------------------------------------------------------------------------------
|
|
165
|
+
//
|
|
166
|
+
// A claim that quotes a number ("score stays at 40", "only 1 life left", "Bois 12") is held to the value the game's own events
|
|
167
|
+
// carried for that same quantity in the steps the claim is about. The quantity is found by the game's own word for it first: the
|
|
168
|
+
// word beside the number is one of the event's own key or name words ("lives" for `{ livesLeft: 1 }`, "bois" for `{ bois: 12 }`),
|
|
169
|
+
// in whatever language the game uses, and only then by the English topic words above. When the events held that quantity there and
|
|
170
|
+
// never at the quoted value:
|
|
171
|
+
// contradicted for a claim about the game itself (the playtester's reading of the state), turned away like any claim the
|
|
172
|
+
// events contradict;
|
|
173
|
+
// disagrees for a claim about what the screen shows (a counter, a bar, a display): the screen may really show a number
|
|
174
|
+
// the game does not hold, which is a fault, so the claim is kept and the finding says what the events held.
|
|
175
|
+
// A number beside a word of comparison ("over 40", "more than 3") or after a slash (a maximum, "2/3") is not a reading, and only
|
|
176
|
+
// a quantity the events sent inside the claim's steps is held against it (a value can change with no event).
|
|
177
|
+
const READ_TOKENS = /(\p{L}[\p{L}\p{N}_']*)|(-?\d+(?:\.\d+)?)|(\/)|([,;.!?()\[\]])/gu;
|
|
178
|
+
const BETWEEN = new Set(['is', 'was', 'are', 'were', 'at', 'of', 'shows', 'showed', 'show', 'reads', 'read', 'says', 'said', 'stays', 'stayed', 'remains', 'stuck', 'frozen', 'to', 'from', 'only', 'still']);
|
|
179
|
+
const COMPARE = new Set(['over', 'under', 'than', 'above', 'below', 'least', 'most', 'max', 'min', 'maximum', 'minimum', 'about', 'around', 'nearly', 'almost', 'approximately', 'roughly', 'per', 'every', 'each', 'step', 'steps', 'turn', 'level', 'room', 'wave', 'round', 'x']);
|
|
180
|
+
// Events can reach the runner a few steps after the input that sent them (lib/events.mjs).
|
|
181
|
+
const LATE_STEPS = 2;
|
|
182
|
+
const singular = w => (w.length > 3 && w.endsWith('s') ? w.slice(0, -1) : w);
|
|
183
|
+
|
|
184
|
+
/** The numbers a claim quotes, each with the words beside it: `[{ value, words }]`. */
|
|
185
|
+
export function quotedNumbers(title) {
|
|
186
|
+
// Punctuation ends a phrase: "after the coin, 2 hearts" puts no word of the first part beside the 2.
|
|
187
|
+
const toks = [...noDashes(String(title || '')).replace(/(\d)\.(?!\d)/g, '$1 .').matchAll(READ_TOKENS)].map(m => (m[1] ? { word: m[1].toLowerCase().replace(/'s$/, '') } : m[2] ? { value: Number(m[2]) } : m[3] ? { slash: true } : { stop: true }));
|
|
188
|
+
const out = [];
|
|
189
|
+
toks.forEach((t, i) => {
|
|
190
|
+
if (t.value === undefined || !Number.isFinite(t.value)) return;
|
|
191
|
+
if (toks[i - 1]?.slash) return;
|
|
192
|
+
// Up to three words before it in its phrase, past the words that only join ("score is 40", "the score counter shows 40",
|
|
193
|
+
// "le bois reste à 9"), and the word just after ("40 points"). Which of them names the quantity is decided by the game's own
|
|
194
|
+
// event keys (keysFor), never by knowing the language.
|
|
195
|
+
const near = [];
|
|
196
|
+
for (let j = i - 1; j >= 0 && toks[j].word && near.length < 3; j--) if (!BETWEEN.has(toks[j].word) || j === i - 1) near.push(toks[j].word);
|
|
197
|
+
if (near.some(w => w && COMPARE.has(w))) return;
|
|
198
|
+
// "2/3 hearts": the word after the maximum.
|
|
199
|
+
const after = (toks[i + 1]?.slash && toks[i + 2]?.value !== undefined ? toks[i + 3]?.word : toks[i + 1]?.word) || null;
|
|
200
|
+
const words = [...near, after].filter(w => w && !BETWEEN.has(w) && !COMPARE.has(w)).map(singular);
|
|
201
|
+
if (words.length) out.push({ value: t.value, words });
|
|
202
|
+
});
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** The event keys holding a quoted number's quantity, by the game's own words first, then by the English topic words. */
|
|
207
|
+
function keysFor(evs, q, claimOther) {
|
|
208
|
+
const keys = new Set();
|
|
209
|
+
for (const e of evs) {
|
|
210
|
+
const otherInEvent = [...ownTokens(e)].some(w => OTHER_TOKENS.has(w));
|
|
211
|
+
if (otherInEvent !== claimOther) continue;
|
|
212
|
+
for (const [k, v] of Object.entries(e.props)) {
|
|
213
|
+
if (typeof v !== 'number' || !Number.isFinite(v)) continue;
|
|
214
|
+
const own = new Set([...tokensOf(k), ...tokensOf(e.name)].map(singular));
|
|
215
|
+
const byOwn = q.words.some(w => own.has(w) && !NO_ONE.has(w));
|
|
216
|
+
const byTopic = q.words.some(w => TOPICS.some(tp => VALUED.has(tp.id) && tp.words.test(w) && tokensOf(k).some(x => tp.tokens.includes(x) || tp.tokens.includes(singular(x)))));
|
|
217
|
+
if (byOwn || byTopic) keys.add(k);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return keys;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** What the game's own events say about a number the claim quotes: `contradicted`, `disagrees` or null (see above). */
|
|
224
|
+
function numberVerdict(run, claim) {
|
|
225
|
+
const evs = (run?.gameEvents?.events || []).filter(e => e.phase === 'play' && Number.isSafeInteger(e.step) && e.props && typeof e.props === 'object');
|
|
226
|
+
if (!evs.length || !claim) return null;
|
|
227
|
+
const win = windowOf(claim);
|
|
228
|
+
if (!win) return null;
|
|
229
|
+
const title = String(claim.title || '');
|
|
230
|
+
// A value no game should have, and a reset to zero, are the rules above: they confirm, and a value they do not find says nothing.
|
|
231
|
+
if (IMPOSSIBLE.test(title) || RESET.test(title)) return null;
|
|
232
|
+
const claimOther = OTHER_ACTOR.test(title);
|
|
233
|
+
for (const q of quotedNumbers(title)) {
|
|
234
|
+
for (const k of keysFor(evs, q, claimOther)) {
|
|
235
|
+
const keyed = evs.filter(e => typeof e.props[k] === 'number' && [...ownTokens(e)].some(w => OTHER_TOKENS.has(w)) === claimOther);
|
|
236
|
+
// The value entering the claim's steps, and every value inside them (with the few steps an event may come late).
|
|
237
|
+
const prior = keyed.filter(e => e.step < win.from).at(-1);
|
|
238
|
+
const inside = keyed.filter(e => e.step >= win.from && earliest(e) <= win.to + LATE_STEPS);
|
|
239
|
+
// Only a quantity the game sent inside those steps speaks to them: a value can change with no event.
|
|
240
|
+
if (!inside.length) continue;
|
|
241
|
+
const held = [...(prior ? [prior] : []), ...inside];
|
|
242
|
+
if (held.some(e => e.props[k] === q.value)) return null;
|
|
243
|
+
const values = [...new Set(held.map(e => e.props[k]))];
|
|
244
|
+
const why = `it reads ${k} as ${q.value}, and the game's own events held ${k} at ${values.slice(0, 4).join(', ')} in the steps it is about (${show(held.at(-1))}${atStep(held.at(-1))})`;
|
|
245
|
+
// A claim about what the screen shows may be the screen's own fault: it is labelled, not turned away.
|
|
246
|
+
return decide(run, title)(NOT_STATE.test(title) ? 'disagrees' : 'contradicted', why, held);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
156
251
|
|
|
157
252
|
/**
|
|
158
253
|
* What the game's own events say about a claim (`{ title, step, inputs }`): `{ verdict: 'contradicted' | 'confirmed', why,
|
|
@@ -160,18 +255,19 @@ export const eventsDecided = run => (run && memo.get(run)) || new Map();
|
|
|
160
255
|
* empty), so such a run's gate is exactly what it was. See the top of this file for the rules.
|
|
161
256
|
*/
|
|
162
257
|
export function eventsVerdict(run, claim) {
|
|
258
|
+
const v = topicVerdict(run, claim);
|
|
259
|
+
if (v) return v;
|
|
260
|
+
return numberVerdict(run, claim);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function topicVerdict(run, claim) {
|
|
163
264
|
const evs = run?.gameEvents?.events;
|
|
164
265
|
if (!Array.isArray(evs) || !evs.length || !claim) return null;
|
|
165
266
|
const win = windowOf(claim);
|
|
166
267
|
if (!win) return null;
|
|
167
268
|
const title = String(claim.title || '');
|
|
168
269
|
const inWin = evs.filter(e => e.phase === 'play' && Number.isSafeInteger(e.step) && earliest(e) >= win.from && e.step <= win.to);
|
|
169
|
-
const done = (
|
|
170
|
-
const v = { verdict, why: noDashes(why), events: list.slice(0, 4).map(e => ({ step: e.step, name: e.name, props: e.props })), ...extra };
|
|
171
|
-
if (!memo.has(run)) memo.set(run, new Map());
|
|
172
|
-
memo.get(run).set(title, v);
|
|
173
|
-
return v;
|
|
174
|
-
};
|
|
270
|
+
const done = decide(run, title);
|
|
175
271
|
|
|
176
272
|
// An error the game itself reported, in the steps the claim is about: a fault in itself.
|
|
177
273
|
if (ERROR_CLAIM.test(title) && !NEG_AT.test(title) && !/\bno\b/i.test(title)) {
|
package/src/run/events.js
CHANGED
|
@@ -80,14 +80,15 @@ function cleanValue(v) {
|
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
/** An event's top-level properties, bounded. The SDKs' own tags (rs_*, pt_*) are left out except the
|
|
83
|
+
/** An event's top-level properties, bounded. The SDKs' own tags (rs_*, pt_*) are left out except the typed kind and its status. */
|
|
84
84
|
export function cleanProps(data) {
|
|
85
85
|
const out = {};
|
|
86
86
|
if (!data || typeof data !== 'object' || Array.isArray(data)) return out;
|
|
87
87
|
let n = 0;
|
|
88
88
|
for (const [k0, v0] of Object.entries(data)) {
|
|
89
89
|
if (n >= EVENT_LIMITS.props) break;
|
|
90
|
-
|
|
90
|
+
// Normalised first (width, case, spaces and separators), so " RS_secret", "Rs-token" or a full-width "rs_x" is filtered too.
|
|
91
|
+
if (k0 !== 'rs_kind' && k0 !== 'rs_status' && /^(?:rs|pt)_/.test(String(k0).normalize('NFKC').trim().toLowerCase().replace(/[\s.\-]+/g, '_'))) continue;
|
|
91
92
|
const k = cleanKey(k0), v = cleanValue(v0);
|
|
92
93
|
if (!k || v === undefined) continue;
|
|
93
94
|
out[k] = v;
|
|
@@ -230,6 +231,15 @@ export function createGameEvents({ now = Date.now, limits = EVENT_LIMITS } = {})
|
|
|
230
231
|
return { lines: planLines(fresh.map(e => ({ ...e, ...place(e) })), limits), upTo: events.length };
|
|
231
232
|
}
|
|
232
233
|
function planned(upTo) { if (Number.isSafeInteger(upTo) && upTo > shownUpTo) shownUpTo = Math.min(upTo, events.length); }
|
|
234
|
+
/**
|
|
235
|
+
* The game's events kept after the first `from`, as it sent them (`{ name, props }`, the SDK's own left out), and the
|
|
236
|
+
* cursor for the next call. For the run's notebook (anygame/memory observe), which keeps a cursor of its own, so the
|
|
237
|
+
* planner's (`pendingForPlan`, `planned`) is untouched.
|
|
238
|
+
*/
|
|
239
|
+
function since(from = 0) {
|
|
240
|
+
const start = Number.isSafeInteger(from) && from > 0 ? from : 0;
|
|
241
|
+
return { events: events.slice(start).filter(e => !systemEvent(e.name)).map(e => ({ name: e.name, props: e.props })), upTo: events.length };
|
|
242
|
+
}
|
|
233
243
|
|
|
234
244
|
/**
|
|
235
245
|
* Ask the game's SDK to send what it still holds, as it does when a tab is
|
|
@@ -270,7 +280,7 @@ export function createGameEvents({ now = Date.now, limits = EVENT_LIMITS } = {})
|
|
|
270
280
|
return { total, kept: events.length, dropped, duplicates, untimed, coarse: events.filter(e => e.coarse).length, bodies, clock: by.arrival ? (by.clock ? 'mixed' : 'arrival') : 'clock', names, marks: marks.length, events: placed };
|
|
271
281
|
}
|
|
272
282
|
|
|
273
|
-
return { tap, mark, markPage, flush, pendingForPlan, planned, record, get size() { return events.length; } };
|
|
283
|
+
return { tap, mark, markPage, flush, pendingForPlan, planned, since, record, get size() { return events.length; } };
|
|
274
284
|
}
|
|
275
285
|
|
|
276
286
|
/** Where an event was placed, in words: a step, or the steps a whole-second timestamp spans. */
|
|
@@ -319,6 +329,44 @@ export function planLines(placed, limits = EVENT_LIMITS) {
|
|
|
319
329
|
return lines;
|
|
320
330
|
}
|
|
321
331
|
|
|
332
|
+
// ---- Outcomes ---------------------------------------------------------------------------------------------------------
|
|
333
|
+
|
|
334
|
+
// What a game's own event says about how play went: a level cleared, the game won, or the game lost (over). A win a game draws
|
|
335
|
+
// only on its canvas (a Unity web build's "LEVEL COMPLETE") is otherwise one reading of the picture; an event the game sent is
|
|
336
|
+
// measured, so it is preferred, and a game that sends events of an outcome's kind and sent none there contradicts a reading.
|
|
337
|
+
// Kept narrow on purpose: a death is not a game over, a level start or a level up is not a level cleared.
|
|
338
|
+
const PLACE_WORDS = new Set(['level', 'stage', 'round', 'wave', 'chapter', 'mission', 'puzzle', 'room', 'floor', 'world', 'act', 'quest']);
|
|
339
|
+
const DONE_WORDS = new Set(['complete', 'completed', 'clear', 'cleared', 'done', 'finished', 'finish', 'passed', 'beaten', 'won', 'win', 'success', 'succeeded']);
|
|
340
|
+
const FAIL_WORDS = new Set(['failed', 'fail', 'lost', 'lose']);
|
|
341
|
+
// A word that undoes a done word or names something else done: "level_not_complete", "retry_level_done", "level_cache_done".
|
|
342
|
+
const NOT_WORDS = new Set(['not', 'no', 'non', 'never', 'fail', 'failed', 'failure', 'cancel', 'cancelled', 'canceled', 'retry', 'retried', 'abort', 'aborted', 'skip', 'skipped', 'cache', 'cached', 'undo', 'reset', 'incomplete', 'uncleared', 'unfinished']);
|
|
343
|
+
const WON_NAMES = new Set(['won', 'win', 'victory', 'you_win', 'you_won', 'game_won', 'game_win', 'game_complete', 'game_completed', 'game_finished', 'game_beaten', 'player_won', 'player_win']);
|
|
344
|
+
const LOST_NAMES = new Set(['game_over', 'gameover', 'game_lost', 'defeat', 'defeated', 'you_lose', 'you_lost', 'player_lost']);
|
|
345
|
+
const nameWords = name => String(name || '').normalize('NFKC').replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The outcome an event of the game's own records: 'level_complete', 'won', 'lost', or null for anything else. Whole names only:
|
|
349
|
+
* one of the names above, or a place word followed by a done (or fail) word and nothing else (a level number may sit between).
|
|
350
|
+
*/
|
|
351
|
+
export function outcomeOfEvent(e) {
|
|
352
|
+
const props = e?.props && typeof e.props === 'object' ? e.props : {};
|
|
353
|
+
if (props.rs_kind === 'level_complete') return 'level_complete';
|
|
354
|
+
if (props.rs_kind === 'progression') return props.rs_status === 'complete' ? 'level_complete' : props.rs_status === 'fail' ? 'lost' : null;
|
|
355
|
+
const words = nameWords(e?.name);
|
|
356
|
+
if (!words.length) return null;
|
|
357
|
+
const joined = words.join('_');
|
|
358
|
+
if (WON_NAMES.has(joined)) return 'won';
|
|
359
|
+
if (LOST_NAMES.has(joined)) return 'lost';
|
|
360
|
+
const core = words.filter(w => !/^\d+$/.test(w));
|
|
361
|
+
if (core.length !== 2 || !PLACE_WORDS.has(core[0])) return null;
|
|
362
|
+
if (FAIL_WORDS.has(core[1])) return 'lost';
|
|
363
|
+
if (NOT_WORDS.has(core[1])) return null;
|
|
364
|
+
return DONE_WORDS.has(core[1]) ? 'level_complete' : null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The outcome events of a run's event record (`run.gameEvents`) placed in play, each with its `outcome`. */
|
|
368
|
+
export const outcomeEvents = record => (Array.isArray(record?.events) ? record.events : []).filter(e => e && e.phase === 'play' && Number.isSafeInteger(e.step) && !systemEvent(e.name)).map(e => ({ ...e, outcome: outcomeOfEvent(e) })).filter(e => e.outcome);
|
|
369
|
+
|
|
322
370
|
/** The plan request's fixed line about the events (before its untrusted-data line), or ''. */
|
|
323
371
|
export const EVENTS_RULE = 'Below the line are events the game itself sent through its own Ravensight analytics since your last plan, each at the step it happened (they can arrive a few steps late). They are measured, not read off the picture: use them to tell whether an input landed, whether you took damage or died, and what the score is, and never report that something did not happen when an event shows it did.';
|
|
324
372
|
/** The events part of a plan request, after its untrusted-data line, or ''. */
|
|
@@ -328,17 +376,25 @@ export const eventsBlock = lines => (Array.isArray(lines) && lines.length ? `Gam
|
|
|
328
376
|
|
|
329
377
|
// ---- The report ------------------------------------------------------------------------------------------------------
|
|
330
378
|
|
|
331
|
-
/**
|
|
379
|
+
/**
|
|
380
|
+
* The findings the game's own events confirmed, each with one more sentence saying so, and those that quote a number off the
|
|
381
|
+
* screen the events never held (lib/eventclaims.mjs `disagrees`), labelled with what the events held. Returns the same list.
|
|
382
|
+
*/
|
|
332
383
|
export function withEventEvidence(findings, run) {
|
|
333
384
|
const decided = eventsDecided(run);
|
|
334
385
|
for (const f of findings || []) {
|
|
335
386
|
const v = decided.get(f.title);
|
|
336
|
-
if (
|
|
387
|
+
if (typeof f.description !== 'string') continue;
|
|
388
|
+
if (v?.verdict === 'confirmed' && !f.description.includes('Measured from the game\'s own events')) {
|
|
337
389
|
f.description = `${f.description} Measured from the game's own events: ${v.why}.`.slice(0, 2000);
|
|
338
390
|
}
|
|
391
|
+
if (v?.verdict === 'disagrees' && !f.description.includes(DISAGREES)) {
|
|
392
|
+
f.description = `${f.description} ${DISAGREES}: ${v.why}. The screen may show a number the game does not hold, or the playtester misread it.`.slice(0, 2000);
|
|
393
|
+
}
|
|
339
394
|
}
|
|
340
395
|
return findings;
|
|
341
396
|
}
|
|
397
|
+
const DISAGREES = 'The number it reads off the screen disagrees with the game\'s own events';
|
|
342
398
|
|
|
343
399
|
/** Whether a finding was confirmed by the game's own events (usage.json `finding_basis` says 'events'). */
|
|
344
400
|
export const eventBacked = (run, f) => eventsDecided(run).get(f?.title)?.verdict === 'confirmed';
|
|
@@ -360,7 +416,9 @@ export function eventsReportLines(run, { findings = [], turnedAway = [] } = {})
|
|
|
360
416
|
const contradicted = (turnedAway || []).filter(t => decided.get(t.title)?.verdict === 'contradicted');
|
|
361
417
|
for (const f of confirmed) md.push(`- Confirmed by the game's own events: "${cleanText(f.title, 120)}". ${decided.get(f.title).why}.`);
|
|
362
418
|
for (const t of contradicted) md.push(`- Contradicted by the game's own events, so not reported as a finding: "${cleanText(t.title, 120)}". ${decided.get(t.title).why}.`);
|
|
363
|
-
|
|
419
|
+
const disagrees = (findings || []).filter(f => decided.get(f.title)?.verdict === 'disagrees');
|
|
420
|
+
for (const f of disagrees) md.push(`- Reported, with a number that disagrees with the game's own events: "${cleanText(f.title, 120)}". ${decided.get(f.title).why}.`);
|
|
421
|
+
if (!confirmed.length && !contradicted.length && !disagrees.length) md.push('- No claim of the playtester\'s was about something these events measure, so they confirmed and contradicted nothing.');
|
|
364
422
|
md.push('');
|
|
365
423
|
const shown = g.events.filter(e => !systemEvent(e.name)).slice(0, EVENT_LIMITS.reportLines);
|
|
366
424
|
if (shown.length) {
|
package/src/run/gameMemory.js
CHANGED
|
@@ -25,13 +25,13 @@ import path from 'node:path';
|
|
|
25
25
|
import { promisify } from 'node:util';
|
|
26
26
|
import {
|
|
27
27
|
MEMORY_SCHEMA, note, startRoute, controlNotes, progressNote, measuredStuckNotes, deathTexts, ruleTexts, messageNotes, designedNotes,
|
|
28
|
-
collectNotes, earlierNotesBlock, withoutSteps
|
|
28
|
+
collectNotes, earlierNotesBlock, withoutSteps, recordNumbers
|
|
29
29
|
} from './anygame/gamenotes.js';
|
|
30
30
|
|
|
31
31
|
const execFileAsync = promisify(execFile);
|
|
32
32
|
|
|
33
33
|
// The words a claim is about (the server's own test, playtestMemoryService sameClaim): four letters or more, plain endings off.
|
|
34
|
-
const words = t => new Set(String(t || '').toLowerCase().replace(/[
|
|
34
|
+
const words = t => new Set(String(t || '').toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, ' ').split(/\s+/).filter(w => w.length >= 4).map(w => w.replace(/(ly|ing|ed|s)$/, '')));
|
|
35
35
|
/** Whether two notes or claims say the same thing: most of the shorter one's words are in the other, and at least two. */
|
|
36
36
|
export function sameClaim(a, b) {
|
|
37
37
|
const x = words(a);
|
|
@@ -119,8 +119,15 @@ export const memoryBlock = memory => earlierNotesBlock({ memory: memory || null
|
|
|
119
119
|
* measured controls, the same shapes a cloud run keeps); `turnedAway` the claims the
|
|
120
120
|
* judge turned away (those found to be as designed become notes). The playtester's own
|
|
121
121
|
* words about where it lost are kept only when no claim turned away says the same thing.
|
|
122
|
+
* `gameEvents` is the run's usage record of the game's own events (./events.js eventsUsage).
|
|
123
|
+
*
|
|
124
|
+
* Held to the record by the hosted runner's own rule (gamenotes holdToRecord): a note of
|
|
125
|
+
* the playtester's that states a number is handed on only when the record holds it, a
|
|
126
|
+
* number the game itself said (a tutorial's words) or a value its own events sent under a
|
|
127
|
+
* word the note uses. A local run has no frames to count losses or wins from, so the
|
|
128
|
+
* progress note names no count, and the notebook's own tally is never handed on.
|
|
122
129
|
*/
|
|
123
|
-
export function extractLocalNotes({ digest = null, turnedAway = [] } = {}) {
|
|
130
|
+
export function extractLocalNotes({ digest = null, turnedAway = [], gameEvents = null } = {}) {
|
|
124
131
|
const memory = digest && digest.memory ? digest.memory : null;
|
|
125
132
|
const measured = digest && digest.controls && Array.isArray(digest.controls.measured) ? digest.controls.measured : [];
|
|
126
133
|
const away = (Array.isArray(turnedAway) ? turnedAway : []).filter(entry => entry && entry.title);
|
|
@@ -130,13 +137,15 @@ export function extractLocalNotes({ digest = null, turnedAway = [] } = {}) {
|
|
|
130
137
|
const start = startRoute(memory);
|
|
131
138
|
if (start) all.push(note('start', start, 'measured', { subject: 'start' }));
|
|
132
139
|
all.push(...controlNotes(measured));
|
|
133
|
-
all.push(progressNote(null, memory));
|
|
140
|
+
all.push(progressNote(null, memory, null));
|
|
134
141
|
all.push(...measuredStuckNotes({ memory }));
|
|
135
142
|
for (const t of notShownFalse(deathTexts(memory)).slice(0, 2)) all.push(note('stuck', withoutSteps(t), 'playtester'));
|
|
136
143
|
all.push(...messageNotes(null, memory));
|
|
137
144
|
all.push(...notShownFalse(ruleTexts(memory)).map(t => note('rule', t, 'playtester')).filter(Boolean));
|
|
138
145
|
all.push(...designedNotes(away.map(entry => ({ outcome: entry.outcome, title: entry.title, reason: entry.reason })), sameClaim));
|
|
139
|
-
|
|
146
|
+
const texts = (memory && Array.isArray(memory.learned) ? memory.learned : []).filter(f => f && f.kind === 'tutorial').map(f => f.text);
|
|
147
|
+
const record = recordNumbers({ counts: null, texts, events: gameEvents && Array.isArray(gameEvents.events) ? gameEvents.events : [] });
|
|
148
|
+
return collectNotes(all, sameClaim, record);
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
/** The `game_memory` a local run's `complete` carries, or null when the game's memory did not ask for notes. */
|
package/src/run/honesty.js
CHANGED
|
@@ -515,8 +515,37 @@ export const EVIDENCE_HEADING = '## Where to look (added by the runner)';
|
|
|
515
515
|
* @param {Map<string, Object>} [context.anchors] the runner's own findings, by id
|
|
516
516
|
* @returns {{report: Object, index: Array<{id: string, action: number|null, screenshot: string|null, video: string|null}>}}
|
|
517
517
|
*/
|
|
518
|
+
/**
|
|
519
|
+
* Every finding with its own id. A report that repeats an id (the model wrote
|
|
520
|
+
* two F001s) keeps the first and gives each repeat the next free id after the
|
|
521
|
+
* report's highest (`F007`, in the schema's F and three digits form), so every
|
|
522
|
+
* consumer that looks a finding up by id, first match or last, reaches the
|
|
523
|
+
* same one. Run once, as soon as the report is settled; running it again
|
|
524
|
+
* changes nothing.
|
|
525
|
+
*/
|
|
526
|
+
export function uniqueFindingIds(report) {
|
|
527
|
+
if (!report || !Array.isArray(report.findings)) return report;
|
|
528
|
+
const taken = new Set(report.findings.map(finding => finding && typeof finding === 'object' ? finding.id : undefined).filter(id => id !== undefined && id !== null && id !== ''));
|
|
529
|
+
const seen = new Set();
|
|
530
|
+
let changed = false;
|
|
531
|
+
const findings = report.findings.map(finding => {
|
|
532
|
+
if (!finding || typeof finding !== 'object' || finding.id === undefined || finding.id === null || finding.id === '') return finding;
|
|
533
|
+
if (!seen.has(finding.id)) { seen.add(finding.id); return finding; }
|
|
534
|
+
let n = Math.max(0, ...[...taken].map(id => Number((String(id).match(/^F(\d+)$/) || [])[1]) || 0)) + 1;
|
|
535
|
+
while (taken.has(`F${String(n).padStart(3, '0')}`)) n += 1;
|
|
536
|
+
const id = `F${String(n).padStart(3, '0')}`;
|
|
537
|
+
taken.add(id);
|
|
538
|
+
seen.add(id);
|
|
539
|
+
changed = true;
|
|
540
|
+
return { ...finding, id };
|
|
541
|
+
});
|
|
542
|
+
return changed ? { ...report, findings } : report;
|
|
543
|
+
}
|
|
544
|
+
|
|
518
545
|
export function attachWhereToLook(report, { observations = [], notes = [], screenshots = [], video = null, anchors = new Map(), bindings = new Map() } = {}) {
|
|
519
546
|
if (!report || !Array.isArray(report.findings)) return { report, index: [] };
|
|
547
|
+
// One finding per id, so the index has one entry per id and a binding one owner.
|
|
548
|
+
report = uniqueFindingIds(report);
|
|
520
549
|
const byIndex = new Map(observations.map(entry => [entry.index, entry]));
|
|
521
550
|
const every = (screenshots || []).filter(shot => shot && typeof shot.relativePath === 'string' && shot.relativePath);
|
|
522
551
|
const shotByPath = new Map(every.map(shot => [String(shot.relativePath).replace(/\\/g, '/'), shot]));
|
|
@@ -525,11 +554,29 @@ export function attachWhereToLook(report, { observations = [], notes = [], scree
|
|
|
525
554
|
// it, never for something the persona saw.
|
|
526
555
|
const shots = every.filter(shot => !shot.edge && !shot.derived);
|
|
527
556
|
const index = [];
|
|
557
|
+
const unbound = new Map(bindings);
|
|
528
558
|
const findings = report.findings.map(finding => {
|
|
529
559
|
if (!finding || typeof finding !== 'object') return finding;
|
|
530
560
|
// Later report formatting may append evidence; it cannot redefine the
|
|
531
561
|
// provenance of the picture already sent to the claim check.
|
|
532
|
-
|
|
562
|
+
// The step and the video time it was placed at still land in its evidence,
|
|
563
|
+
// said once; a time the finding cites itself stands.
|
|
564
|
+
// Each binding is used once: a later finding that repeats an id is placed
|
|
565
|
+
// on its own evidence and inherits nothing from the first.
|
|
566
|
+
if (unbound.has(finding.id)) {
|
|
567
|
+
const bound = unbound.get(finding.id);
|
|
568
|
+
unbound.delete(finding.id);
|
|
569
|
+
index.push(bound);
|
|
570
|
+
const original = Array.isArray(finding.evidence) ? finding.evidence : null;
|
|
571
|
+
const kept = original ? [...original] : [];
|
|
572
|
+
const has = (type, test) => kept.some(item => item && item.type === type && test(String(item.ref)));
|
|
573
|
+
if (Number.isInteger(bound.action) && !has('transcript_step', ref => new RegExp(`^\\s*action\\s*#?\\s*${bound.action}\\s*$`, 'i').test(ref))) {
|
|
574
|
+
kept.push({ type: 'transcript_step', ref: `action ${bound.action}` });
|
|
575
|
+
}
|
|
576
|
+
if (typeof bound.video === 'string' && bound.video && !has('video_ts', () => true)) kept.push({ type: 'video_ts', ref: bound.video });
|
|
577
|
+
// Evidence that was not a list is always replaced by the list.
|
|
578
|
+
return original && kept.length === original.length ? finding : { ...finding, evidence: kept };
|
|
579
|
+
}
|
|
533
580
|
const evidence = Array.isArray(finding.evidence) ? [...finding.evidence] : [];
|
|
534
581
|
let at = null;
|
|
535
582
|
let action = null;
|
|
@@ -704,5 +751,5 @@ export function playOnText(actions, maxActions) {
|
|
|
704
751
|
|
|
705
752
|
export default {
|
|
706
753
|
createCapabilityLedger, capabilityLines, writeCapabilitySection, capabilityPrompt, flatShare, isBlankScreen, createBlankWatch,
|
|
707
|
-
describeInput, stepsBefore, runnerFinding, addRunnerFindings, runnerFindingsMarkdown, dialogNote, videoTime, attachWhereToLook, whereToLookMarkdown, playOnText
|
|
754
|
+
describeInput, stepsBefore, runnerFinding, addRunnerFindings, runnerFindingsMarkdown, dialogNote, videoTime, attachWhereToLook, uniqueFindingIds, whereToLookMarkdown, playOnText
|
|
708
755
|
};
|
package/src/run/judge.js
CHANGED
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
// as an ended-empty or thin run, and never charged for a falsehood. Local money follows the honesty bar exactly
|
|
37
37
|
// as hosted money does. With the switch off, both would be kept as `opinion` impressions instead.
|
|
38
38
|
import { claimClass, claimBasis, checkSaid, praiseClaim } from './claimwords.js';
|
|
39
|
-
|
|
39
|
+
// A report written in another language: its claims are sorted by their fixed fields, never by English words (./claimwords.js readsEnglish).
|
|
40
|
+
import { eventsVerdict, eventsConfirmed, contradictedReason, eventsDecided } from './eventclaims.js';
|
|
40
41
|
import { STILL_MIN_GAME_MS } from './stillWatch.js';
|
|
41
42
|
|
|
42
43
|
/** Turn away unsettled taste and own-play difficulty, as the hosted judge does. See MONEY above: the owner's call. */
|
|
@@ -54,10 +55,11 @@ const text = x => String(x ?? '').replace(/[\u2013\u2014]/g, ',').replace(/\s+/g
|
|
|
54
55
|
* `plain` for taste, and null when no check is asked (praise, difficulty).
|
|
55
56
|
*
|
|
56
57
|
* @param {{title?: string, description?: string, severity?: string, category?: string}} finding
|
|
57
|
-
* @param {{marked?: boolean}} [opts] marked: the picture the playtester judged from carried the runner's marks and grid
|
|
58
|
+
* @param {{marked?: boolean, english?: boolean}} [opts] marked: the picture the playtester judged from carried the runner's marks and grid;
|
|
59
|
+
* english: the report is written in English, so its words are read (false: praise, stuck, absence and layout are not told by words)
|
|
58
60
|
*/
|
|
59
|
-
export function claimShape(finding, { marked = false } = {}) {
|
|
60
|
-
const claim = { title: finding?.title || '', detail: finding?.description || '', severity: finding?.severity || null, category: finding?.category || null, marked };
|
|
61
|
+
export function claimShape(finding, { marked = false, english = true } = {}) {
|
|
62
|
+
const claim = { title: finding?.title || '', detail: finding?.description || '', severity: finding?.severity || null, category: finding?.category || null, marked, english };
|
|
61
63
|
// Praise filed as a problem is the playtester's liking; a blocker or a major is never read as praise, so its grade stands.
|
|
62
64
|
if (claim.severity === 'praise' || (!['blocker', 'major'].includes(claim.severity) && praiseClaim(claim))) return { cls: 'praise', basis: null, question: null };
|
|
63
65
|
const cls = claimClass(claim);
|
|
@@ -97,8 +99,8 @@ const designedWords = check => {
|
|
|
97
99
|
* @param {{measured: Object|null, replay: Object|null}|null} [opts.still] for a claim that nothing happens: what the run measured of its input (./stillWatch.js noEffectTries) and the replay that watched it (./reportChecks.js replayWebFindings)
|
|
98
100
|
* @returns {{route: string, outcome: string|null, reason: string|null, cls: string, basis: string|null, impression?: {kind: string, check: string|null, note: string}, evidence?: string, events?: Array}}
|
|
99
101
|
*/
|
|
100
|
-
export function judgeIssue(finding, { check = null, run = null, step = null, marked = false, turnAwayUnsettled = TURN_AWAY_UNSETTLED, still = null } = {}) {
|
|
101
|
-
const { cls, basis } = claimShape(finding, { marked });
|
|
102
|
+
export function judgeIssue(finding, { check = null, run = null, step = null, marked = false, turnAwayUnsettled = TURN_AWAY_UNSETTLED, still = null, english = true } = {}) {
|
|
103
|
+
const { cls, basis } = claimShape(finding, { marked, english });
|
|
102
104
|
const base = { cls, basis };
|
|
103
105
|
const finding_ = extra => ({ ...base, route: 'finding', outcome: null, reason: null, ...extra });
|
|
104
106
|
const away = (outcome, reason, extra = {}) => ({ ...base, route: 'turned_away', outcome, reason: text(reason), ...extra });
|
|
@@ -113,7 +115,11 @@ export function judgeIssue(finding, { check = null, run = null, step = null, mar
|
|
|
113
115
|
return impression('opinion', saidOf === null ? 'not_made' : saidOf === 'not_contradicted' ? 'not_contradicted' : 'cannot_tell', { ownPlay: true });
|
|
114
116
|
}
|
|
115
117
|
const claim = { title: finding?.title || '', step: Number.isSafeInteger(step) ? step : null };
|
|
116
|
-
|
|
118
|
+
// The game's own events are matched in every language (step, phase, the numbers they carry). In another language they may only turn a
|
|
119
|
+
// claim away: a confirmation rests on the claim's English words, so it is dropped here and from the verdicts the report reads.
|
|
120
|
+
const ev0 = run ? eventsVerdict(run, claim) : null;
|
|
121
|
+
const ev = english || ev0?.verdict === 'contradicted' ? ev0 : null;
|
|
122
|
+
if (ev0 && !ev) eventsDecided(run).delete(claim.title);
|
|
117
123
|
if (ev?.verdict === 'contradicted') return away('contradicted', contradictedReason(ev), { evidence: 'events', events: ev.events });
|
|
118
124
|
|
|
119
125
|
const said = checkSaid(check);
|
|
@@ -133,11 +139,17 @@ export function judgeIssue(finding, { check = null, run = null, step = null, mar
|
|
|
133
139
|
if (cls === 'stuck') {
|
|
134
140
|
if (said === 'opposite') return away('contradicted', 'the frame at its moment contradicts it');
|
|
135
141
|
if (designed) return designed;
|
|
142
|
+
// In another language `stuck` is the class a claim gets when nothing settles which it is (./claimwords.js claimClass): it needs the
|
|
143
|
+
// watch, and its frame at fault too, so neither one answer of the frame nor the watch alone publishes it.
|
|
144
|
+
if (!english && (!still || !still.measured)) return away('unconfirmed', 'it is written in a language whose claims the runner does not sort by their words, so it may be a claim that nothing happens, which one frame cannot show, and no watch of the screen while game time ran confirmed it');
|
|
136
145
|
if (!still || !still.measured) return away('unconfirmed', 'a claim that nothing happens is confirmed only by watching the screen while game time runs with no input, and the run did not press the same control again and again with nothing changing; one still frame cannot settle it');
|
|
137
146
|
// The hosted gate's stuck rule, word for word: reproduced counts only from a watch, since the same screen following the same input says nothing about stillness.
|
|
138
147
|
const replay = still.replay || null;
|
|
139
148
|
const detail = replay && replay.detail ? ` (${text(replay.detail)})` : '';
|
|
140
|
-
if (replay?.state === 'reproduced' && Number(replay.watched_ms) >= STILL_MIN_GAME_MS)
|
|
149
|
+
if (replay?.state === 'reproduced' && Number(replay.watched_ms) >= STILL_MIN_GAME_MS) {
|
|
150
|
+
if (english || said === 'at_fault') return finding_({ evidence: 'still_watch' });
|
|
151
|
+
return away('unconfirmed', `it is written in a language whose claims the runner does not sort by their words, so it is held to both a watch and its frame; the watch saw the screen still, and ${made ? 'its frame did not show the game at fault' : unasked}`);
|
|
152
|
+
}
|
|
141
153
|
if (replay?.state === 'reproduced') return away('unconfirmed', 'the replay reached the same screen but did not watch it while game time ran, so it could not test a claim that nothing happens');
|
|
142
154
|
if (replay?.state === 'not_reproduced') return away('not_reproduced', `it did not come back when the recorded inputs were played again${detail}`);
|
|
143
155
|
return away('unconfirmed', `a claim that nothing happens is confirmed only by watching the screen while game time runs for ${STILL_MIN_GAME_MS / 1000} seconds with no input, and that could not be done${detail}; one still frame cannot settle it`);
|
|
@@ -177,8 +189,8 @@ export function judgeIssue(finding, { check = null, run = null, step = null, mar
|
|
|
177
189
|
* A claim the picture contradicts is turned away; a claim of fact stands when the picture shows it (as designed or at
|
|
178
190
|
* fault included) and is turned away otherwise; anything else stands.
|
|
179
191
|
*/
|
|
180
|
-
export function legacyIssue(finding, { check = null, marked = false } = {}) {
|
|
181
|
-
const { cls, basis, question } = claimShape(finding, { marked });
|
|
192
|
+
export function legacyIssue(finding, { check = null, marked = false, english = true } = {}) {
|
|
193
|
+
const { cls, basis, question } = claimShape(finding, { marked, english });
|
|
182
194
|
const said = checkSaid(check);
|
|
183
195
|
const base = { cls, basis };
|
|
184
196
|
if (said === 'opposite') return { ...base, route: 'turned_away', outcome: 'contradicted', reason: 'the frame at its moment contradicts it' };
|