ravensight-playtest 0.13.0 → 0.13.2
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 +58 -3
- package/package.json +1 -1
- package/src/commands/run.js +35 -6
- package/src/run/aggregate.js +2 -1
- package/src/run/anygame/shared-hashes.json +2 -2
- package/src/run/claimGate.js +9 -0
- package/src/run/drivers/mobile/target.js +22 -3
- package/src/run/drivers/web.js +45 -1
- package/src/run/eventclaims.js +6 -3
- package/src/run/events.js +33 -7
- package/src/run/intent.js +604 -0
- package/src/run/judge.js +19 -5
- package/src/run/personaLoop.js +194 -17
- package/src/run/reportChecks.js +119 -26
- package/src/run/sdkSession.js +114 -0
- package/src/run/stillWatch.js +123 -0
- package/src/run/thinRun.js +35 -11
- package/src/run/tools.js +52 -14
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
// What an input was meant to do, held against the screen that came after it, and what a run actually played.
|
|
2
|
+
//
|
|
3
|
+
// The paid local run on Wish You Were Hired (2026-11-20, CLI 0.13.1, job pt_job_c0a8d44d64fe1a9a85e7) pressed Enter 16
|
|
4
|
+
// times in a row (41% of its actions), each time expecting to "sit at desk and start the ticket", while every frame showed
|
|
5
|
+
// the character beside the PM, the log reading "> talk pm" and the map saying "[Enter] Talk to the PM". Each press drew a
|
|
6
|
+
// new PM line, so the screen changed every time and no stuck check fired; the persona never pressed an arrow key, and its
|
|
7
|
+
// in-character text later said it "walked onto" the desk. The cloud runner's paid run on the same game the same day missed
|
|
8
|
+
// the other way (it clicked into the Tutorial the focus said to stay out of). This file is the local half of one answer;
|
|
9
|
+
// the cloud half is the direct runner's lib/intent.mjs, and the words, the part check and the report's "What was played"
|
|
10
|
+
// line are ported from it, not reinvented:
|
|
11
|
+
//
|
|
12
|
+
// check Every input with a stated expectation is held against the screen after it: the screen not changing at all
|
|
13
|
+
// (measured), a part of the game the focus or the input said to stay out of read as the screen's state ("TUTORIAL
|
|
14
|
+
// 1/7", from the page's own text or the playtester's reading), the playtester's own answer on its next tool call
|
|
15
|
+
// ("intent_check": met or missed, and what the screen shows "instead"), and the record (the same input sent again
|
|
16
|
+
// for the same result: the playtester's own next move says the last one did not get it).
|
|
17
|
+
// repeat An input that missed the same result twice in a row is not sent a third time. The playtester is told what the
|
|
18
|
+
// screen showed instead and asked for a different approach (move first, another target). Inputs that move the game
|
|
19
|
+
// on a step at a time ("advance the story", "dismiss the tip") are never counted as a miss from the record alone.
|
|
20
|
+
// played Which part of the game the run played: how far it got, as the record and the game's own events show it, and the
|
|
21
|
+
// result it aimed at and never reached. A run that played to its budget is said so, never "stopped early".
|
|
22
|
+
// held The in-character section is held to the record: a sentence that says the playtester walked or moved to a result
|
|
23
|
+
// the record shows it only ever pressed a non-moving key for, or that repeats a claim the frames contradicted, is
|
|
24
|
+
// left out, and the record's own fact is said instead.
|
|
25
|
+
//
|
|
26
|
+
// No model is asked anything in this file.
|
|
27
|
+
|
|
28
|
+
const clip = (s, n) => noDashes(String(s ?? '')).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
29
|
+
const esc = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
30
|
+
|
|
31
|
+
/** The hosted runner's own: an em or en dash becomes a comma (no dashes in anything a customer reads). */
|
|
32
|
+
export function noDashes(s) {
|
|
33
|
+
return String(s ?? '').replace(/[\u2013\u2014]/g, ',');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ---- What a text says to stay out of (ported from the direct runner's lib/intent.mjs) -----------------------------------
|
|
37
|
+
|
|
38
|
+
// "(not the Tutorial)", "not Tutorial", "without the tutorial", "instead of the Tutorial", "rather than Endless", "skip the intro".
|
|
39
|
+
const EXCLUDE = /\b(?:not|never|without|instead of|rather than|other than|except(?: for)?|skip(?:ping)?|avoid(?:ing)?)\s+(?:(the|a|an|any)\s+)?([A-Za-z][\w'-]*(?:\s+[A-Za-z][\w'-]*){0,2})/g;
|
|
40
|
+
// Words that end a named thing ("not the Tutorial and then ...").
|
|
41
|
+
const PHRASE_END = /^(and|then|or|but|to|so|as|if|when|while|because|yet|for|with|of|in|on|at|by|it|is|was|will|first|again|anymore)$/i;
|
|
42
|
+
// What a "not the ..." names that is no part of a game ("not the same", "not a bug", "without a doubt").
|
|
43
|
+
const NOT_A_PLACE = /^(one|it|this|that|these|those|yet|sure|now|much|many|more|less|only|all|enough|really|least|most|exactly|here|there|anything|nothing|everything|something|first|last|next|same|end|doubt|problem|issue|bug|bugs|case|way|time|point|idea|clue|reason|fault|game|player|screen|button|thing|things|right|wrong|best|worst|kind|sort|rest)$/i;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The parts of a game a text says to stay out of: `["tutorial"]` for "pick New Run then START RUN (not the Tutorial)". A term is
|
|
47
|
+
* a name: after an article ("not the tutorial") or capitalised ("not Tutorial"), one to three words, never a word that names no
|
|
48
|
+
* place ("not the same", "not a bug"). Lower case, in the order they come.
|
|
49
|
+
*/
|
|
50
|
+
export function excludedTerms(text) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const m of String(text || '').matchAll(EXCLUDE)) {
|
|
53
|
+
const article = m[1];
|
|
54
|
+
const words = [];
|
|
55
|
+
for (const w of m[2].split(/\s+/)) { if (PHRASE_END.test(w)) break; words.push(w); }
|
|
56
|
+
if (!words.length) continue;
|
|
57
|
+
if (!article && !/^[A-Z]/.test(words[0])) continue;
|
|
58
|
+
const named = article ? words : words.filter((w, i) => i === 0 || /^[A-Z]/.test(w));
|
|
59
|
+
const term = named.join(' ').replace(/['-]+$/, '').toLowerCase();
|
|
60
|
+
if (term.length < 3 || NOT_A_PLACE.test(term)) continue;
|
|
61
|
+
if (!out.includes(term)) out.push(term);
|
|
62
|
+
}
|
|
63
|
+
return out.slice(0, 4);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Labels a text names as places to go or things to press: quoted ("Start"), in capitals (START RUN), or in title case after the
|
|
68
|
+
* start of a clause (New Run). The terms it says to stay out of are left out. In the order they come.
|
|
69
|
+
*/
|
|
70
|
+
export function namedTargets(text) {
|
|
71
|
+
const t = String(text || '');
|
|
72
|
+
const excluded = excludedTerms(t);
|
|
73
|
+
const out = [];
|
|
74
|
+
const add = s => { const v = clip(s, 40).replace(/^[^\w]+|[^\w]+$/g, ''); if (v.length >= 2 && !excluded.includes(v.toLowerCase()) && !out.some(x => x.toLowerCase() === v.toLowerCase())) out.push(v); };
|
|
75
|
+
for (const m of t.matchAll(/["“`]([^"”`]{2,40})["”`]/g)) add(m[1]);
|
|
76
|
+
for (const m of t.matchAll(/\b([A-Z]{2,}(?:\s+[A-Z]{2,}){0,2})\b/g)) add(m[1]);
|
|
77
|
+
for (const m of t.matchAll(/(?<![.;:,(]\s*|^\s*)(?<=\s)([A-Z][a-z]+(?:\s+[A-Z][a-z]+){1,2})\b/g)) add(m[1]);
|
|
78
|
+
return out.slice(0, 6);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether `text` shows `term` as where the player is, not as a choice on a menu: the term with a counter ("TUTORIAL 1/7",
|
|
83
|
+
* "Tutorial 2 of 7", "tutorial step 3"), as a heading in capitals ending in a colon ("TUTORIAL:"), or "<term> mode". A menu that
|
|
84
|
+
* lists "Tutorial" beside "New Run" shows none of these. Answers `{ quote, n, of }` (n and of when a counter was read) or null.
|
|
85
|
+
*/
|
|
86
|
+
export function sectionShown(term, text) {
|
|
87
|
+
const t = String(text || '');
|
|
88
|
+
if (!term || !t) return null;
|
|
89
|
+
const body = esc(String(term)).replace(/\s+/g, '\\s+');
|
|
90
|
+
const counter = new RegExp(`\\b(${body})\\b\\s*(?:(\\d{1,3})\\s*(?:/|of)\\s*(\\d{1,3})|(?:step|part|stage|lesson|page)\\s*(\\d{1,3}))`, 'i').exec(t);
|
|
91
|
+
if (counter) {
|
|
92
|
+
const n = Number(counter[2] ?? counter[4]), of = counter[3] !== undefined ? Number(counter[3]) : null;
|
|
93
|
+
if (of === null || (n <= of && of <= 99)) return { quote: clip(counter[0], 40), n, ...(of !== null ? { of } : {}) };
|
|
94
|
+
}
|
|
95
|
+
const caps = new RegExp(`\\b(${esc(String(term).toUpperCase()).replace(/\s+/g, '\\s+')})\\s*:`).exec(t);
|
|
96
|
+
if (caps) return { quote: clip(caps[1], 40) };
|
|
97
|
+
const mode = new RegExp(`\\b(${body})\\s+mode\\b`, 'i').exec(t);
|
|
98
|
+
if (mode) return { quote: clip(mode[0], 40) };
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ---- The input and what it was meant to do --------------------------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
/** The most times one input may miss the same result in a row before the runner stops sending it. */
|
|
105
|
+
export const MAX_SAME_MISSES = 2;
|
|
106
|
+
|
|
107
|
+
/** The most times the playtester is told to leave a part of the game it should stay out of (the cloud runner's MAX_RECOVERY_ASKS). */
|
|
108
|
+
export const MAX_RECOVERY_ASKS = 2;
|
|
109
|
+
|
|
110
|
+
/** What the playtester is told when the screen shows a part of the game it should stay out of (the cloud runner's recoverLine). */
|
|
111
|
+
export function recoverLine(part) {
|
|
112
|
+
return noDashes(`Recover first: the screen reads "${String(part.quote).replace(/"/g, "'")}"${part.source === 'reading' ? ' (as you read it)' : ''}, so you are in the ${part.label}, which ${part.who} says to stay out of. Go back first (Back, Escape, Cancel or the game's own menu), then go for what you meant, by its own label.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The longest "instead" kept: what the screen showed in place of what an input was meant to do. */
|
|
116
|
+
export const INSTEAD_MAX = 120;
|
|
117
|
+
|
|
118
|
+
/** Keys that move a character or a cursor across the game: the arrows, W A S D, the number pad's four. */
|
|
119
|
+
export const MOVEMENT_KEY = /^(?:arrow(?:up|down|left|right)|up|down|left|right|[wasd]|numpad[2468])$/i;
|
|
120
|
+
|
|
121
|
+
const lower = s => String(s ?? '').trim().toLowerCase();
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* One input as a key two sends of the same input share: the same key (and how it was held), the same named target or ref, the
|
|
125
|
+
* same point (to within a few pixels), the same text. Null for a tool that sends nothing to the game.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} tool
|
|
128
|
+
* @param {Object} input
|
|
129
|
+
* @returns {string|null}
|
|
130
|
+
*/
|
|
131
|
+
export function inputKey(tool, input = {}) {
|
|
132
|
+
const i = input || {};
|
|
133
|
+
const point = (x, y) => (Number.isFinite(Number(x)) && Number.isFinite(Number(y)) && x !== null && y !== null && x !== '' && y !== '' ? `${Math.round(Number(x) / 8)},${Math.round(Number(y) / 8)}` : '');
|
|
134
|
+
switch (tool) {
|
|
135
|
+
case 'key': {
|
|
136
|
+
if (Array.isArray(i.sequence) && i.sequence.length) return `key:sequence:${JSON.stringify(i.sequence.map(s => [s.key ?? '', point(s.x, s.y)]))}`;
|
|
137
|
+
const keys = [lower(i.key), ...(Array.isArray(i.with_keys) ? i.with_keys.map(lower).sort() : [])].join('+');
|
|
138
|
+
return `key:${keys}${Number(i.hold_ms) > 0 ? ':held' : ''}`;
|
|
139
|
+
}
|
|
140
|
+
case 'click': case 'hover': case 'select': case 'scroll': case 'pinch':
|
|
141
|
+
return `${tool}:${lower(i.ref) || lower(i.target) || point(i.x, i.y)}${i.button ? `:${lower(i.button)}` : ''}${i.double ? ':double' : ''}${i.option !== undefined ? `:${lower(i.option)}` : ''}${i.value !== undefined ? `:${i.value}` : ''}${i.dy !== undefined || i.dx !== undefined ? `:${Number(i.dx) || 0},${Number(i.dy) || 0}` : ''}`;
|
|
142
|
+
case 'type':
|
|
143
|
+
return `type:${lower(i.ref) || lower(i.target)}:${String(i.text ?? '')}`;
|
|
144
|
+
case 'drag': case 'swipe':
|
|
145
|
+
return `${tool}:${lower(i.from) || point(i.x, i.y)}>${lower(i.to) || point(i.toX, i.toY)}`;
|
|
146
|
+
case 'gamepad':
|
|
147
|
+
return `gamepad:${JSON.stringify([i.buttons || [], i.left_stick || null, i.right_stick || null])}`;
|
|
148
|
+
case 'navigate':
|
|
149
|
+
return `navigate:${String(i.url ?? '')}`;
|
|
150
|
+
default:
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Whether an input moves something across the game: a movement key, a held key, a timed sequence, a drag, a stick. */
|
|
156
|
+
export function movementInput(tool, input = {}) {
|
|
157
|
+
const i = input || {};
|
|
158
|
+
if (tool === 'key') {
|
|
159
|
+
if (Array.isArray(i.sequence) && i.sequence.length) return true;
|
|
160
|
+
if (Number(i.hold_ms) > 0) return true;
|
|
161
|
+
return [i.key, ...(Array.isArray(i.with_keys) ? i.with_keys : [])].some(k => MOVEMENT_KEY.test(String(k ?? '').trim()));
|
|
162
|
+
}
|
|
163
|
+
if (tool === 'drag' || tool === 'swipe') return true;
|
|
164
|
+
if (tool === 'gamepad') {
|
|
165
|
+
const stick = s => s && (Number(s.x) !== 0 || Number(s.y) !== 0);
|
|
166
|
+
return Boolean(stick(i.left_stick) || stick(i.right_stick) || (Array.isArray(i.buttons) && i.buttons.some(b => /^d?pad|^(?:up|down|left|right)$/i.test(String(b)))));
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** How an input reads in a sentence: "key Enter", "click New Run", "click at (639,411)". */
|
|
172
|
+
export function inputWords(tool, input = {}) {
|
|
173
|
+
const i = input || {};
|
|
174
|
+
if (tool === 'key') return Array.isArray(i.sequence) && i.sequence.length ? 'a timed key sequence' : `key ${String(i.key || '')}${Number(i.hold_ms) > 0 ? ` held ${Math.round(Number(i.hold_ms))} ms` : ''}`;
|
|
175
|
+
if (tool === 'type') return 'typing';
|
|
176
|
+
if (typeof i.ref === 'string' && i.ref.trim()) return `${tool} ${i.ref.trim()}`;
|
|
177
|
+
if (typeof i.target === 'string' && i.target.trim()) return `${tool} ${clip(i.target, 40)}`;
|
|
178
|
+
if (Number.isFinite(Number(i.x)) && Number.isFinite(Number(i.y))) return `${tool} at (${Math.round(Number(i.x))},${Math.round(Number(i.y))})`;
|
|
179
|
+
return tool;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Words that say nothing about which result was meant.
|
|
183
|
+
const STOP = new Set(('the a an of to on in for or and that it its is are was were be not there any at all my your by with from this has have does do did can still also only just than then them they their what which who how when while into onto out over under very more most some such each other these those would could should will may might been being as so if but no yes '
|
|
184
|
+
+ 'since because already now again see seen shows show shown showing appear appears appeared screen game should expect expected expecting likely probably maybe hopefully me i im ill ive let lets us we our').split(' '));
|
|
185
|
+
|
|
186
|
+
/** A word's stem: the endings off and a doubled last letter single (sitting, sits and sit are one word). */
|
|
187
|
+
function stem(word) {
|
|
188
|
+
let w = word.replace(/(?:ing|ed|es|s)$/, '');
|
|
189
|
+
if (w.length > 3 && /([b-df-hj-np-tv-z])\1$/.test(w)) w = w.slice(0, -1);
|
|
190
|
+
return w.length >= 2 ? w : word;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** The words an expectation is about, without the common ones, stemmed. */
|
|
194
|
+
export function intentWords(text) {
|
|
195
|
+
return new Set(String(text ?? '').toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').split(/\s+/)
|
|
196
|
+
.filter(w => w.length > 2 && !STOP.has(w)).map(stem));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Whether two expectations name the same result: they share at least two words, and at least half of the shorter one's.
|
|
201
|
+
* "Sit at desk and start the ticket" and "Sit at own desk (E4) and start first ticket, since character stands on it" are one
|
|
202
|
+
* result; "Dismiss PM dialogue" is another.
|
|
203
|
+
*/
|
|
204
|
+
export function sameIntent(a, b) {
|
|
205
|
+
const x = a instanceof Set ? a : intentWords(a);
|
|
206
|
+
const y = b instanceof Set ? b : intentWords(b);
|
|
207
|
+
if (!x.size || !y.size) return false;
|
|
208
|
+
let shared = 0;
|
|
209
|
+
for (const w of x) if (y.has(w)) shared += 1;
|
|
210
|
+
return shared >= Math.min(2, x.size, y.size) && shared >= Math.ceil(Math.min(x.size, y.size) / 2);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* An expectation that moves the game on a step at a time, so the same input meant for it again is the next step and not a
|
|
215
|
+
* retry: the next page of a story, the next tip dismissed, a walk, a scroll, a turn.
|
|
216
|
+
*/
|
|
217
|
+
export const PROGRESSIVE = /\b(?:advanc\w*|next|continu\w*|proceed\w*|more|another|again|page|scroll\w*|skip\w*|dismiss\w*|clos(?:e|es|ed|ing)|mov(?:e|es|ed|ing)|walk\w*|run(?:s|ning)?|step(?:s|ped|ping)?|turn(?:s|ed)?|jump\w*|further|keep\w*|typing|cycl\w*|toggl\w*|increas\w*|decreas\w*|count\w*|through|attack\w*|hit(?:s|ting)?|fir(?:e|es|ed|ing)|shoot\w*|shot|strik\w*|swing\w*|slash\w*|punch\w*|kick\w*|collect\w*|gather\w*|harvest\w*|min(?:e|es|ed|ing)|chop\w*|dig\w*|buy\w*|bought|sell\w*|sold|spend\w*|spent|earn\w*|add(?:s|ed|ing)?|damage\w*|score\w*|coins?|points?)\b/i;
|
|
218
|
+
|
|
219
|
+
/** Whether an expectation moves the game on a step at a time (see PROGRESSIVE). */
|
|
220
|
+
export function progressive(expect) {
|
|
221
|
+
return PROGRESSIVE.test(String(expect || ''));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The expectation of a tool call, trimmed, as ./tools.js keeps it. */
|
|
225
|
+
const expectOf = input => (input && typeof input.expect === 'string' ? input.expect.replace(/\s+/g, ' ').trim().slice(0, 160) : '');
|
|
226
|
+
|
|
227
|
+
/** The playtester's answer about its last input, from a tool call's own fields: `{ intent: 'met'|'missed'|null, instead }`. */
|
|
228
|
+
export function answerOf(input) {
|
|
229
|
+
const i = input || {};
|
|
230
|
+
const raw = lower(i.intent_check);
|
|
231
|
+
const intent = raw === 'met' || raw === 'missed' ? raw : null;
|
|
232
|
+
return { intent, instead: clip(typeof i.instead === 'string' ? i.instead : '', INSTEAD_MAX) };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ---- The run's watch over its inputs --------------------------------------------------------------------------------------
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The goals a run plays towards, from the brief the persona reads: the run's own focus (`this_run_focus.play_towards`) first,
|
|
239
|
+
* then the brief's success criteria. Each `{ text, focus }`.
|
|
240
|
+
*/
|
|
241
|
+
export function goalsOf(brief) {
|
|
242
|
+
const fields = brief && typeof brief === 'object' ? (brief.fields && typeof brief.fields === 'object' ? brief.fields : brief) : {};
|
|
243
|
+
const towards = Array.isArray(fields?.this_run_focus?.play_towards) ? fields.this_run_focus.play_towards : [];
|
|
244
|
+
const criteria = Array.isArray(fields?.success_criteria) ? fields.success_criteria : [];
|
|
245
|
+
return [...towards.map(text => ({ text: String(text), focus: true })), ...criteria.map(c => ({ text: String(typeof c === 'string' ? c : c?.text || c?.criterion || ''), focus: false }))].filter(g => g.text.trim().length >= 2).slice(0, 8);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Hold each input with a stated expectation against the screen after it, and stop an input that keeps missing the same result.
|
|
250
|
+
*
|
|
251
|
+
* The play loop calls, for each tool call in order: `answer(input, { first })` (the playtester's own answer about its last
|
|
252
|
+
* input, read only from the first call of a turn, the one made after it saw that screen), then for an input to the game
|
|
253
|
+
* `refusal(tool, input, { turn })` (a text when the input is not to be sent), and after the driver played it
|
|
254
|
+
* `played({ tool, input, action, turn, ok, changed, pageText, reading })`. `notices()` is what the playtester is told with the
|
|
255
|
+
* next tool results; `summary()` and `families()` are the record the report and usage.json carry.
|
|
256
|
+
*
|
|
257
|
+
* @param {{goals?: Array<{text: string, focus?: boolean}>, onEvent?: (line: Object) => void}} [options] `onEvent` gets each
|
|
258
|
+
* `intent_check` (an answer or a miss) and `intent_refused` line for the step log
|
|
259
|
+
*/
|
|
260
|
+
export function createIntentWatch({ goals = [], onEvent = () => {} } = {}) {
|
|
261
|
+
const emit = line => { try { onEvent(line); } catch { /* the step log never stops play */ } };
|
|
262
|
+
const goalTerms = goals.map(g => ({ ...g, terms: excludedTerms(g.text) }));
|
|
263
|
+
const stayOut = [...new Set(goalTerms.flatMap(g => g.terms))];
|
|
264
|
+
// The last input that reached the game with a stated expectation, waiting for its answer.
|
|
265
|
+
let pending = null;
|
|
266
|
+
// Inputs of one kind in a row: what each result they were meant for has missed.
|
|
267
|
+
let streak = { key: null, results: [] };
|
|
268
|
+
const checks = [];
|
|
269
|
+
const missed = [];
|
|
270
|
+
const refused = [];
|
|
271
|
+
const queued = [];
|
|
272
|
+
const parts = new Map();
|
|
273
|
+
let met = 0;
|
|
274
|
+
let answered = 0;
|
|
275
|
+
|
|
276
|
+
/** The result record of the streak an expectation belongs to, made when `create`. */
|
|
277
|
+
function resultOf(expect, words, create = false) {
|
|
278
|
+
let r = streak.results.find(x => sameIntent(x.words, words));
|
|
279
|
+
if (!r && create) { r = { expect, words, misses: 0, actions: [], saw: [], by: new Set() }; streak.results.push(r); }
|
|
280
|
+
return r;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** A part of the game a goal (or the input itself) said to stay out of, shown as the screen's state in one of `texts`. */
|
|
284
|
+
function shownPart(texts, extra = []) {
|
|
285
|
+
for (const term of [...new Set([...stayOut, ...extra])]) {
|
|
286
|
+
for (const t of texts) {
|
|
287
|
+
if (!t || !t.text) continue;
|
|
288
|
+
const hit = sectionShown(term, t.text);
|
|
289
|
+
if (!hit) continue;
|
|
290
|
+
const owners = goalTerms.filter(g => g.terms.includes(term));
|
|
291
|
+
const spelled = owners.map(g => new RegExp(`\\b${esc(term).replace(/\s+/g, '\\s+')}\\b`, 'i').exec(g.text)?.[0]).find(Boolean);
|
|
292
|
+
return { term, label: spelled || term.replace(/^\w/, ch => ch.toUpperCase()), ...hit, source: t.source, who: owners.some(g => g.focus) ? 'the focus' : owners.length ? 'the brief' : 'your own plan' };
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* A part of the game the run is found in that it should stay out of: a miss the first time (counted once a part, however long
|
|
300
|
+
* the run stays, as the cloud runner counts it), and the playtester told to leave at most MAX_RECOVERY_ASKS times.
|
|
301
|
+
*/
|
|
302
|
+
function inPart(p, part, by) {
|
|
303
|
+
const known = parts.get(part.term);
|
|
304
|
+
if (!known) { miss(p, { by, saw: part.quote, why: by === 'runner' && part.source === 'page' ? 'the page reads it' : `the screen is the ${part.label}`, part }); return; }
|
|
305
|
+
if (known.asks >= MAX_RECOVERY_ASKS) return;
|
|
306
|
+
known.asks += 1;
|
|
307
|
+
queued.push(recoverLine(part));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** A miss of the pending input's expectation: kept, counted against its result, and said to the playtester unless it said so. */
|
|
311
|
+
function miss(p, { by, saw = '', why = '', part = null }) {
|
|
312
|
+
if (!p || p.missed) return;
|
|
313
|
+
p.missed = { by, saw: clip(saw, INSTEAD_MAX), why };
|
|
314
|
+
missed.push({ action: p.action, input: p.words, tool: p.tool, expected: p.expect, by, saw: p.missed.saw, why, movement: p.movement, ...(part ? { part: part.term } : {}) });
|
|
315
|
+
const check = checks.find(c => c.action === p.action);
|
|
316
|
+
if (check) Object.assign(check, { result: 'missed', by, saw: p.missed.saw, ...(why ? { why } : {}) });
|
|
317
|
+
emit({ kind: 'intent_check', action: p.action, input: p.words, expected: p.expect, result: 'missed', by, ...(p.missed.saw ? { saw: p.missed.saw } : {}), ...(why ? { why } : {}), ...(part ? { part: part.term } : {}) });
|
|
318
|
+
if (p.key === streak.key) {
|
|
319
|
+
const r = resultOf(p.expect, p.intentWords, true);
|
|
320
|
+
r.misses += 1;
|
|
321
|
+
r.actions.push(p.action);
|
|
322
|
+
if (p.missed.saw) r.saw.push(p.missed.saw);
|
|
323
|
+
r.by.add(by);
|
|
324
|
+
}
|
|
325
|
+
if (part) {
|
|
326
|
+
if (!parts.has(part.term)) parts.set(part.term, { label: part.label, since: p.action, quote: part.quote, who: part.who, source: part.source, asks: 1 });
|
|
327
|
+
queued.push(recoverLine(part));
|
|
328
|
+
} else if (by === 'record') {
|
|
329
|
+
// A screen that did not change is already said with the tool result, and the playtester knows its own answer.
|
|
330
|
+
queued.push(noDashes(`Your input at action ${p.action} (${p.words}) was meant to: "${clip(p.expect, 100).replace(/"/g, "'")}", and you sent it again for the same result, so it did not get there. Do not count it as done; look at what the screen shows instead.`));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
/** The playtester's own answer about its last input. Only the first tool call of a turn can carry one. */
|
|
336
|
+
answer(input, { first = true } = {}) {
|
|
337
|
+
if (!first || !pending || pending.answered) return null;
|
|
338
|
+
const said = answerOf(input);
|
|
339
|
+
if (!said.intent) return null;
|
|
340
|
+
pending.answered = said.intent;
|
|
341
|
+
answered += 1;
|
|
342
|
+
// A part the playtester's own reading names ("TUTORIAL 2/7") is a miss whatever it answered.
|
|
343
|
+
const part = said.instead ? shownPart([{ text: said.instead, source: 'reading' }], pending.excluded) : null;
|
|
344
|
+
if (part) inPart(pending, part, 'runner');
|
|
345
|
+
if (pending.missed) return said;
|
|
346
|
+
if (said.intent === 'missed') miss(pending, { by: 'playtester', saw: said.instead });
|
|
347
|
+
else if (!pending.missed) {
|
|
348
|
+
met += 1;
|
|
349
|
+
const check = checks.find(c => c.action === pending.action);
|
|
350
|
+
if (check) Object.assign(check, { result: 'met', by: 'playtester' });
|
|
351
|
+
emit({ kind: 'intent_check', action: pending.action, input: pending.words, expected: pending.expect, result: 'met', by: 'playtester' });
|
|
352
|
+
}
|
|
353
|
+
return said;
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* A text when this input is not to be sent: the same input, in a row, meant for a result it has already missed
|
|
358
|
+
* MAX_SAME_MISSES times. Also the record's own check, when the playtester gave no answer about its last input: the same
|
|
359
|
+
* input sent again for the same result, in a later turn, says the last one did not get it (never for a result that moves
|
|
360
|
+
* the game on a step at a time or is done again and again: a page, a tip, a walk, an attack, a coin).
|
|
361
|
+
*/
|
|
362
|
+
refusal(tool, input, { turn = 0 } = {}) {
|
|
363
|
+
const key = inputKey(tool, input);
|
|
364
|
+
const expect = expectOf(input);
|
|
365
|
+
if (!key || !expect) return null;
|
|
366
|
+
const words = intentWords(expect);
|
|
367
|
+
// Only when the playtester gave no answer of its own: one it gave is believed unless the screen did not change.
|
|
368
|
+
if (pending && !pending.missed && !pending.answered && pending.key === key && pending.turn < turn && !progressive(pending.expect) && sameIntent(pending.intentWords, words)) {
|
|
369
|
+
miss(pending, { by: 'record', why: 'the same input was sent again for the same result' });
|
|
370
|
+
}
|
|
371
|
+
if (streak.key !== key) return null;
|
|
372
|
+
const r = resultOf(expect, words);
|
|
373
|
+
if (!r || r.misses < MAX_SAME_MISSES) return null;
|
|
374
|
+
const saw = [...new Set(r.saw)].slice(-2);
|
|
375
|
+
const label = inputWords(tool, input);
|
|
376
|
+
refused.push({ input: label, expected: expect, misses: r.misses, actions: [...r.actions], ...(saw.length ? { saw } : {}) });
|
|
377
|
+
emit({ kind: 'intent_refused', input: label, expected: expect, misses: r.misses, actions: [...r.actions], ...(saw.length ? { saw } : {}) });
|
|
378
|
+
const moving = movementInput(tool, input);
|
|
379
|
+
return noDashes(`Not sent: ${label} has already been sent ${r.misses} times in a row for "${clip(r.expect, 100).replace(/"/g, "'")}", and the screen ${saw.length ? `showed "${saw.join('" and "').replace(/\s+/g, ' ')}" instead` : 'did not show that'} each time. A third time will not do it. Choose a different approach: ${moving ? 'another direction, another key or another target' : 'move first (the arrow keys or W A S D, held with hold_ms) to reach what you are aiming at, or click another target'}, and read what the screen says each key or button does.`);
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
/** An input the driver played: held against the screen after it. */
|
|
383
|
+
played({ tool, input, action, turn = 0, ok = true, changed = true, pageText = '', thought = '' }) {
|
|
384
|
+
const key = inputKey(tool, input);
|
|
385
|
+
if (!key || !ok) return;
|
|
386
|
+
if (streak.key !== key) streak = { key, results: [] };
|
|
387
|
+
const expect = expectOf(input);
|
|
388
|
+
if (!expect) { pending = null; return; }
|
|
389
|
+
const label = inputWords(tool, input);
|
|
390
|
+
pending = { action, turn, key, tool, words: label, expect, intentWords: intentWords(expect), excluded: excludedTerms(`${thought || ''} ${expect}`), movement: movementInput(tool, input), answered: null, missed: null };
|
|
391
|
+
checks.push({ action, input: label, expected: expect, movement: pending.movement, result: null });
|
|
392
|
+
if (!changed) { miss(pending, { by: 'runner', why: 'the screen did not change' }); return; }
|
|
393
|
+
const part = pageText ? shownPart([{ text: pageText, source: 'page' }], pending.excluded) : null;
|
|
394
|
+
if (part) inPart(pending, part, 'runner');
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
/** What the playtester is told with the next tool results, once. */
|
|
398
|
+
notices() {
|
|
399
|
+
return queued.splice(0, queued.length);
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
/** The results the run aimed at and missed, by input: `{ expected, input, misses, actions, saw, reached }`. */
|
|
403
|
+
families() {
|
|
404
|
+
const out = [];
|
|
405
|
+
for (const m of missed) {
|
|
406
|
+
let f = out.find(x => x.input === m.input && sameIntent(intentWords(x.expected), intentWords(m.expected)));
|
|
407
|
+
if (!f) { f = { expected: m.expected, input: m.input, movement: Boolean(m.movement), misses: 0, actions: [], saw: [], reached: false }; out.push(f); }
|
|
408
|
+
f.misses += 1;
|
|
409
|
+
f.actions.push(m.action);
|
|
410
|
+
if (m.saw && !f.saw.includes(m.saw)) f.saw.push(m.saw);
|
|
411
|
+
}
|
|
412
|
+
// A result counts as reached when a later check of the same result was answered met.
|
|
413
|
+
for (const f of out) f.reached = checks.some(c => c.result === 'met' && c.action > Math.max(...f.actions) && sameIntent(intentWords(c.expected), intentWords(f.expected)));
|
|
414
|
+
// Inputs refused for repeating a miss were meant for the same result: they belong to it.
|
|
415
|
+
for (const r of refused) { const f = out.find(x => x.input === r.input && sameIntent(intentWords(x.expected), intentWords(r.expected))); if (f) f.refused = (f.refused || 0) + 1; }
|
|
416
|
+
return out;
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
/** The record for usage.json and the step log. */
|
|
420
|
+
summary() {
|
|
421
|
+
return {
|
|
422
|
+
checks: checks.length,
|
|
423
|
+
answered,
|
|
424
|
+
met,
|
|
425
|
+
missed: missed.map(m => ({ ...m })),
|
|
426
|
+
refused: refused.map(r => ({ ...r })),
|
|
427
|
+
parts: [...parts].map(([term, p]) => ({ term, label: p.label, since: p.since, quote: p.quote, who: p.who, source: p.source })),
|
|
428
|
+
movement: checks.some(c => c.movement)
|
|
429
|
+
};
|
|
430
|
+
},
|
|
431
|
+
|
|
432
|
+
/** The checks, in action order: `{ action, input, expected, movement, result, by?, saw? }`. */
|
|
433
|
+
checks() {
|
|
434
|
+
return checks.map(c => ({ ...c }));
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* The report's action log (./personaLoop.js actionLogFrom) with each checked input's result on its entry: `intent` is
|
|
441
|
+
* `{ result: 'met'|'missed', saw }`. Entries with no check are left as they are.
|
|
442
|
+
*/
|
|
443
|
+
export function annotateActionLog(log, checks = []) {
|
|
444
|
+
const by = new Map((checks || []).filter(c => c && c.result).map(c => [c.action, c]));
|
|
445
|
+
return (Array.isArray(log) ? log : []).map(entry => {
|
|
446
|
+
const c = by.get(entry.action);
|
|
447
|
+
return c ? { ...entry, intent: { result: c.result, ...(c.saw ? { saw: c.saw } : {}) } } : entry;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ---- What the run played ----------------------------------------------------------------------------------------------------
|
|
452
|
+
|
|
453
|
+
const quoted = (s, n = 80) => {
|
|
454
|
+
const text = clip(s, 400);
|
|
455
|
+
if (text.length <= n) return `"${text.replace(/"/g, "'")}"`;
|
|
456
|
+
const cut = text.slice(0, n - 3);
|
|
457
|
+
const space = cut.lastIndexOf(' ');
|
|
458
|
+
return `"${(space > n / 2 ? cut.slice(0, space) : cut).replace(/[\s,;:]+$/, '').replace(/"/g, "'")}..."`;
|
|
459
|
+
};
|
|
460
|
+
const actionRange = list => {
|
|
461
|
+
const xs = [...new Set(list)].sort((a, b) => a - b);
|
|
462
|
+
if (xs.length === 1) return `action ${xs[0]}`;
|
|
463
|
+
return `actions ${xs[0]} to ${xs.at(-1)}`;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* How play ended, said for a run that used what it was given: "played to its budget" for a run that stopped on its action or
|
|
468
|
+
* model budget (the report reserve included), never "stopped early". Null for any other ending.
|
|
469
|
+
*/
|
|
470
|
+
export function playedToBudget({ quitReason, actionsTaken = 0, maxActions = 0, minimum = 15 } = {}) {
|
|
471
|
+
if (quitReason !== 'budget_exhausted') return null;
|
|
472
|
+
const bar = Math.min(minimum, Number(maxActions) || minimum);
|
|
473
|
+
if (!(Number(actionsTaken) >= bar)) return null;
|
|
474
|
+
return `Played to its budget: ${actionsTaken}${maxActions ? ` of ${maxActions}` : ''} actions`;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Which part of the game a local run played, in one paragraph for report.md's "What was played" line and usage.json `scope`:
|
|
479
|
+
* how play ended, the last result the playtester confirmed or moved on from, the results it aimed at again and again and never
|
|
480
|
+
* reached (with what the screen showed instead), a part of the game it was in that the focus said to stay out of, and the
|
|
481
|
+
* game's own events. Null when there is nothing to say.
|
|
482
|
+
*
|
|
483
|
+
* @param {{watch?: Object, actionsTaken?: number, maxActions?: number, quitReason?: string, reserveStopped?: boolean, eventNames?: string[], eventTotal?: number}} args
|
|
484
|
+
* @returns {{line: string, families: Array<Object>, parts: Array<Object>, reached: Object|null, budget: boolean}|null}
|
|
485
|
+
*/
|
|
486
|
+
export function playedScope({ watch = null, actionsTaken = 0, maxActions = 0, quitReason = '', reserveStopped = false, eventNames = [], eventTotal = 0 } = {}) {
|
|
487
|
+
const sentences = [];
|
|
488
|
+
const budget = playedToBudget({ quitReason, actionsTaken, maxActions });
|
|
489
|
+
if (budget) sentences.push(`${budget}${reserveStopped ? ', then play stopped so the rest of the model budget paid for the report' : ''}.`);
|
|
490
|
+
const families = watch ? watch.families().filter(f => f.misses >= MAX_SAME_MISSES && !f.reached) : [];
|
|
491
|
+
const summary = watch ? watch.summary() : null;
|
|
492
|
+
const checks = watch ? watch.checks() : [];
|
|
493
|
+
// The last result the playtester confirmed, else the last input before the first unreached result that changed the screen
|
|
494
|
+
// and was moved on from (said as such: it is the playtester's expectation, not a reading of the screen).
|
|
495
|
+
const firstStuck = families.length ? Math.min(...families.flatMap(f => f.actions)) : Infinity;
|
|
496
|
+
const confirmed = checks.filter(c => c.result === 'met').at(-1) || null;
|
|
497
|
+
const movedOn = checks.filter(c => c.action < firstStuck && c.result !== 'missed').at(-1) || null;
|
|
498
|
+
const reached = confirmed && confirmed.action < firstStuck ? { ...confirmed, how: 'confirmed by the playtester' } : movedOn ? { ...movedOn, how: 'the screen changed and the playtester moved on' } : confirmed ? { ...confirmed, how: 'confirmed by the playtester' } : null;
|
|
499
|
+
if (reached) sentences.push(`Furthest it got, as the playtester expected it: ${quoted(reached.expected)} (action ${reached.action}; ${reached.how}).`);
|
|
500
|
+
for (const f of families.slice(0, 2)) {
|
|
501
|
+
sentences.push(`Never reached: ${quoted(f.expected)}. ${f.misses} inputs (${f.input}, ${actionRange(f.actions)}) were meant to do it, and the screen ${f.saw.length ? `showed ${f.saw.slice(0, 2).map(x => quoted(x)).join(' and ')} instead` : 'never showed it'}${f.refused ? `; ${f.refused} more were not sent because they repeated the miss` : ''}.`);
|
|
502
|
+
}
|
|
503
|
+
const parts = summary ? summary.parts : [];
|
|
504
|
+
for (const p of parts.slice(0, 1)) sentences.push(`Played the ${p.label}, which ${p.who === 'your own plan' ? 'the playtester\'s own input' : p.who} said to stay out of: ${p.source === 'reading' ? 'the playtester read' : 'the page read'} ${quoted(p.quote)} at action ${p.since}.`);
|
|
505
|
+
const names = [...new Set((eventNames || []).filter(Boolean))].slice(0, 8);
|
|
506
|
+
if (names.length) sentences.push(`The game's own events: ${names.join(', ')}${eventTotal ? ` (${eventTotal} in all)` : ''}.`);
|
|
507
|
+
if (!sentences.length) return null;
|
|
508
|
+
return { line: noDashes(sentences.join(' ')), families, parts, reached: reached ? { action: reached.action, expected: reached.expected, how: reached.how } : null, budget: Boolean(budget) };
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/** The line report.md carries under its title, in the hosted report's words. */
|
|
512
|
+
export const PLAYED_LABEL = '**What was played:**';
|
|
513
|
+
|
|
514
|
+
/** report.md with the "What was played" line under the generated-at line (one already there is replaced). */
|
|
515
|
+
export function withPlayedLine(markdown, line) {
|
|
516
|
+
const lines = String(markdown || '').split('\n').filter(entry => !entry.startsWith(PLAYED_LABEL));
|
|
517
|
+
if (!line) return lines.join('\n');
|
|
518
|
+
const at = lines.findIndex(entry => /^\*\*Generated at:\*\* /.test(entry));
|
|
519
|
+
const heading = lines.findIndex(entry => /^# /.test(entry));
|
|
520
|
+
const where = at !== -1 ? at + 1 : heading !== -1 ? heading + 1 : 0;
|
|
521
|
+
lines.splice(where, 0, `${PLAYED_LABEL} ${line}`);
|
|
522
|
+
return lines.join('\n');
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ---- The in-character section, held to the record ---------------------------------------------------------------------------
|
|
526
|
+
|
|
527
|
+
/** A sentence that says the playtester moved itself somewhere (English words). */
|
|
528
|
+
export const MOVED = /\b(?:walk(?:ed|ing)?\s+(?:onto|on|over|up|to|into|across|around|back)|walked|mov(?:ed|ing)\s+(?:onto|on|over|up|to|into|across|my|the|him|her)|ran\s+(?:onto|over|up|to|into|across)|step(?:ped|ping)\s+(?:onto|on|over|up|to|into)|head(?:ed|ing)\s+(?:over|to|for)|made\s+my\s+way|went\s+(?:over\s+)?(?:to|onto|up\s+to)|got\s+(?:over\s+)?to\s+(?:my|the)|stood\s+(?:on|at)\s+(?:my|the)|climb(?:ed|ing))\b/i;
|
|
529
|
+
|
|
530
|
+
/** Heading of the in-character section, as the report template spells it. */
|
|
531
|
+
const IN_CHARACTER = /^##\s+In-character experience\b/i;
|
|
532
|
+
|
|
533
|
+
/** A paragraph's sentences, split where one ends and the next begins. */
|
|
534
|
+
function sentencesOf(text) {
|
|
535
|
+
return String(text).split(/(?<=[.!?]["')\]]?)\s+(?=["'(\[*A-Z0-9])/);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* report.md with the in-character section held to the run's record, one sentence at a time:
|
|
540
|
+
* - a sentence that says the playtester walked or moved to a result it aimed at and never reached, where every input it sent
|
|
541
|
+
* for that result was one that moves nothing (a sentence naming that result, by its words, and a movement verb), or that
|
|
542
|
+
* says it moved at all in a run whose record has no input that could move anything;
|
|
543
|
+
* - a sentence that repeats a claim the frames contradicted (`turnedAway` with outcome `contradicted`, by `repeats`).
|
|
544
|
+
* Each is left out, and the record's own fact is said in a runner's line at the end of the section. Answers `{ markdown, held }`.
|
|
545
|
+
*
|
|
546
|
+
* @param {string} markdown
|
|
547
|
+
* @param {{families?: Array<Object>, movedAtAll?: boolean, turnedAway?: Array<Object>, repeats?: (sentence: string, entry: Object) => boolean}} record
|
|
548
|
+
*/
|
|
549
|
+
export function holdInCharacter(markdown, { families = [], movedAtAll = true, turnedAway = [], repeats = () => false } = {}) {
|
|
550
|
+
const lines = String(markdown || '').split('\n');
|
|
551
|
+
const start = lines.findIndex(line => IN_CHARACTER.test(line.trim()));
|
|
552
|
+
if (start === -1) return { markdown, held: [] };
|
|
553
|
+
let end = lines.findIndex((line, i) => i > start && /^##\s/.test(line));
|
|
554
|
+
if (end === -1) end = lines.length;
|
|
555
|
+
const contradicted = (turnedAway || []).filter(entry => entry && entry.outcome === 'contradicted');
|
|
556
|
+
const held = [];
|
|
557
|
+
const why = sentence => {
|
|
558
|
+
if (MOVED.test(sentence)) {
|
|
559
|
+
const words = intentWords(sentence);
|
|
560
|
+
const aimed = families.find(f => !f.movement && sameIntent(words, intentWords(f.expected)));
|
|
561
|
+
if (aimed) return { sentence, fact: `no input that moves anything was sent for ${quoted(aimed.expected)}: every one sent for it (${aimed.misses}, ${actionRange(aimed.actions)}) was ${aimed.input}${aimed.refused ? `, ${aimed.refused} more were not sent because they repeated the miss,` : ''} and the screen ${aimed.saw.length ? `showed ${aimed.saw.slice(0, 2).map(x => quoted(x)).join(' and ')}` : 'never showed it'}` };
|
|
562
|
+
if (!movedAtAll) return { sentence, fact: 'the run sent no input that moves anything (no arrow key, no W A S D, no held key, no drag)' };
|
|
563
|
+
}
|
|
564
|
+
const twin = contradicted.find(entry => repeats(sentence, entry));
|
|
565
|
+
if (twin) return { sentence, fact: `${twin.id}, which says the same, is contradicted by the frame at its moment (see "Raised by the playtester, not confirmed")` };
|
|
566
|
+
return null;
|
|
567
|
+
};
|
|
568
|
+
const body = [];
|
|
569
|
+
for (const line of lines.slice(start + 1, end)) {
|
|
570
|
+
if (!line.trim() || /^\s*[|>#]/.test(line) || line.startsWith('Held to the run\'s record')) { if (!line.startsWith('Held to the run\'s record')) body.push(line); continue; }
|
|
571
|
+
const kept = [];
|
|
572
|
+
for (const sentence of sentencesOf(line)) {
|
|
573
|
+
const found = why(sentence);
|
|
574
|
+
if (found) held.push(found);
|
|
575
|
+
else kept.push(sentence);
|
|
576
|
+
}
|
|
577
|
+
if (kept.length) body.push(kept.join(' '));
|
|
578
|
+
}
|
|
579
|
+
if (!held.length) return { markdown, held: [] };
|
|
580
|
+
while (body.length && !body.at(-1).trim()) body.pop();
|
|
581
|
+
body.push('', noDashes(`Held to the run's record (written by the runner): ${held.map(h => `${quoted(h.sentence, 140)} is left out, because ${h.fact}`).join('; ')}.`), '');
|
|
582
|
+
return { markdown: [...lines.slice(0, start + 1), ...body, ...lines.slice(end)].join('\n'), held };
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* What the report step is told about the inputs it held against the screens: the results missed again and again, the inputs not
|
|
587
|
+
* sent for repeating a miss, a part of the game the focus said to stay out of, and whether anything that moves was ever sent.
|
|
588
|
+
* '' when there is nothing to say.
|
|
589
|
+
*/
|
|
590
|
+
export function intentReportLines(watch, scope = null) {
|
|
591
|
+
if (!watch) return '';
|
|
592
|
+
const summary = watch.summary();
|
|
593
|
+
const families = watch.families().filter(f => f.misses >= 1);
|
|
594
|
+
if (!summary.checks) return '';
|
|
595
|
+
const lines = [`The runner held each input you stated an expectation for against the screen after it (${summary.checks} inputs; ${summary.met} you confirmed, ${summary.missed.length} missed).`];
|
|
596
|
+
for (const f of families.slice(0, 4)) lines.push(`- ${f.input}, meant to ${quoted(f.expected)}: missed ${f.misses} time(s) (${actionRange(f.actions)})${f.saw.length ? `; the screen showed ${f.saw.slice(0, 2).map(x => quoted(x)).join(' and ')} instead` : ''}${f.refused ? `; ${f.refused} more not sent because they repeated the miss` : ''}${f.reached ? '; reached later' : '; never reached'}.`);
|
|
597
|
+
for (const p of summary.parts.slice(0, 2)) lines.push(`- The run was in the ${p.label}, which ${p.who} said to stay out of (${quoted(p.quote)} at action ${p.since}).`);
|
|
598
|
+
if (!summary.movement) lines.push('- No input you gave an expectation for moves anything (no arrow key, no W A S D, no held key, no drag).');
|
|
599
|
+
if (scope && scope.line) lines.push(`What was played, from the run's record: ${scope.line}`);
|
|
600
|
+
lines.push('Write nothing, in any section and in the in-character one too, that says an input did what this record shows it did not, or that you walked, moved or went somewhere the action list has no input for. Say what the screen showed instead. The runner leaves out a sentence that does.');
|
|
601
|
+
return noDashes(lines.join('\n'));
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export default { createIntentWatch, excludedTerms, namedTargets, sectionShown, playedScope, holdInCharacter, intentReportLines, withPlayedLine };
|