Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ First release in preparation: v0.1 "Playable".
unchanged mechanics, in plainer language (fewer harbour terms), pacing
`narrative`, about 65 minutes.
- *The Locked Study*: target play time 7 minutes (the recalibrated estimate).
- Notebook entries may only say what the player has read when they are
learned: `lexvm transcript` shows each new entry with its text where it is
learned, the authoring guide, its checklist and the logic and review
prompts state the rule. *Die letzte Nacht der Reichsmark* 1.1.1 learns six
entries no earlier than their facts are told (»Der Fall Brodersen« named
Tadeusz before Anni did).

### Added

Expand Down
4 changes: 4 additions & 0 deletions docs/authoring/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ deduce something, or *show* a clue to a character to confront them.
## Clues and deductions
- A clue is a piece of knowledge: an object with `clue: true` and `location: nowhere`, acquired with the `learn` effect (reading a document, examining something, a dialogue). Clues sit in the notebook and cannot be dropped or lost.
- Clue names are short and telling (≤ 24 characters: "Torn ticket", "Alibi gap"); the description states the fact.
- A clue says only what the player has read by the time it is learned: the notebook can be opened in the middle of a conversation, so an entry must not name a person, place or fact that a later line introduces. Put the `learn` after the last line the entry sums up (in a dialogue: in the node or option that says it), or cut the entry down. The exception is a document whose entry is the document itself (a letter, a list): there the notebook is where it is read.
- Deductions combine two clues: a rule `on: { verb: use, object: clue_a, with: clue_b }` with `when: { not: { has: clue_c } }` that `learn`s the conclusion `clue_c` (rules are tried in both orders). Only ask for deductions a player can reasonably see; answer plausible wrong combinations gently.
- Players tap a clue and choose "Combine with …" ("Kombinieren mit …"), which sends `use`; typed, "combine X with Y" / "kombiniere X mit Y" / "vergleiche X mit Y" work. If the story depends on deductions, teach combining once early (a line of inner voice or the first hint step).
- Interrogations and confrontations use clues as evidence (see dialogue).
Expand Down Expand Up @@ -317,6 +318,7 @@ anyway. The LLM prompts ask the model to go through the same list.
12. **Invisible verbs.** Every pack verb is declared under `verbs:` and listed in the `verbs` of each object it applies to.
13. **One key per condition and effect.** `{ set: a, score: 1 }` is two effects; two conditions go in a list or `all: […]`.
14. **Score.** Each point is awarded once; `maxScore` equals the walkthrough's total.
15. **Notebook entries ahead of the story.** Every clue description states only what the player has read when its `learn` runs. A dialogue that `learn`s a summary in an early node and says the rest later gives the game away; move the `learn` to the node that says the last fact.
<!-- prompt:end checklist -->

## 15. Reviewing a pack (human or generated)
Expand All @@ -331,6 +333,8 @@ you. Before you publish, play it on a phone and ask:
- Read the transcript (`lexvm transcript <pack>`) from start to end: could a
reader retell what happened, who wanted what, and why the player went where
they went? Is there a moment where something happens without a reason?
- Does any notebook entry run ahead of the story? The transcript shows each
entry where it is learned; it may only say what the text above it has said.
- Does the text read well on a small screen, in the chosen narrative voice,
with consistent quotes? Does the rhythm vary, or is it a chain of fragments?
- Are there plausible actions that get a bland default answer where a custom
Expand Down
5 changes: 4 additions & 1 deletion docs/authoring/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ words when narrative: fewer puzzles, more story.
Verification proves a pack can be won; it cannot tell whether a reader can
follow it. `lexvm transcript <pack>` replays the walkthrough and prints
everything the player reads along it as Markdown (room titles as headings,
commands as quotes; `--out <file>` writes it to a file). Read it from start to
commands as quotes, each new notebook entry with its text where it is learned;
`--out <file>` writes it to a file). The entries are there because the player
can read them at that moment: an entry that names something the transcript
has not shown yet is ahead of the story. Read it from start to
end, or have it reviewed:

```sh
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { clean, err, formatDiagnostic } from "../term.ts";
export const TRANSCRIPT_HELP = `Usage: lexvm transcript <packDir|file.yaml|file.lexpack.json> [options]

Replay the pack's walkthrough and print everything a player reads along it,
as Markdown: room titles as headings, the player's commands as quotes. This is
as Markdown: room titles as headings, the player's commands as quotes, new
notebook entries with their text where they are learned. This is
the text to read (or give to an editor) when reviewing the story: can a reader
follow what happens, and why?

Expand Down
48 changes: 40 additions & 8 deletions packages/engine/src/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,50 @@
* The walkthrough as a reader sees it: the whole game text of one winning
* play, in order, as Markdown. It is the artifact for reviewing the story
* (authoring guide, "Story and scenes"): verification proves that a pack can
* be won, the transcript shows whether it can be followed.
* be won, the transcript shows whether it can be followed. New notebook
* entries are shown where they are learned, with their text, because the
* player can read them there: an entry must not be ahead of the story.
*/

import { parseCanonical } from "./commands.ts";
import { newGame, step } from "./runtime.ts";
import type { Pack } from "./schema.ts";
import type { OutputBlock } from "./types.ts";
import { INVENTORY, type Pack } from "./schema.ts";
import { objectDescription } from "./text.ts";
import type { GameState, OutputBlock } from "./types.ts";

export interface Transcript {
/** Markdown: room titles as headings, the player's commands as quotes, system lines left out. */
/** Markdown: room titles as headings, the player's commands as quotes, new notebook entries with their text, other system lines left out. */
markdown: string;
/** Accepted walkthrough steps. */
steps: number;
/** Every step accepted and a winning ending reached. */
ok: boolean;
}

function blocksToMarkdown(blocks: OutputBlock[], out: string[]): void {
/** Clues that are in the notebook in `after` but were not in `before`. */
function newClues(pack: Pack, before: GameState | null, after: GameState): Set<string> {
const known = (st: GameState | null, id: string) => {
const os = st?.objects[id];
return os !== undefined && os.location === INVENTORY && !os.hidden;
};
const ids = new Set<string>();
for (const [id, def] of Object.entries(pack.objects))
if (def.clue && known(after, id) && !known(before, id)) ids.add(id);
return ids;
}

/**
* Render the blocks of one step. A system block naming a clue learned in this
* step becomes a notebook line with the clue's text (resolved against the state
* after the step); every other system block is left out.
*/
function blocksToMarkdown(
pack: Pack,
state: GameState,
learned: Set<string>,
blocks: OutputBlock[],
out: string[],
): void {
let prev: OutputBlock["kind"] | null = null;
for (const block of blocks) {
const text = block.spans
Expand All @@ -34,8 +60,14 @@ function blocksToMarkdown(blocks: OutputBlock[], out: string[]): void {
case "room-title":
out.push(`## ${text}`);
break;
case "system":
case "system": {
const id = block.spans.find((s) => s.ref !== undefined && learned.has(s.ref))?.ref;
if (id === undefined) break;
learned.delete(id);
const name = pack.objects[id]?.name ?? id;
out.push(`*Notebook: ${name}.* ${objectDescription(pack, state, id).join(" ")}`.trim());
break;
}
case "ending":
out.push(prev === "ending" ? text : `### ${text}`);
break;
Expand All @@ -51,7 +83,7 @@ export function walkthroughTranscript(pack: Pack): Transcript {
const out: string[] = [`# ${pack.title}`];
if (pack.subtitle !== undefined) out.push(`*${pack.subtitle}*`);
const game = newGame(pack);
blocksToMarkdown(game.output, out);
blocksToMarkdown(pack, game.state, newClues(pack, null, game.state), game.output, out);
let state = game.state;
let steps = 0;
let failed = false;
Expand All @@ -67,7 +99,7 @@ export function walkthroughTranscript(pack: Pack): Transcript {
break;
}
steps++;
blocksToMarkdown(result.output, out);
blocksToMarkdown(pack, result.state, newClues(pack, state, result.state), result.output, out);
state = result.state;
}
const ok = !failed && state.ended !== null && pack.endings[state.ended]?.win === true;
Expand Down
12 changes: 11 additions & 1 deletion packages/engine/test/transcript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { walkthroughTranscript } from "../src/transcript.ts";
import { loadLockedStudy } from "./fixtures/runtime/helpers.ts";

describe("walkthroughTranscript", () => {
it("renders the whole winning play as Markdown, without system lines", () => {
it("renders the whole winning play as Markdown, without system lines but with new notebook entries", () => {
const pack = loadLockedStudy();
const t = walkthroughTranscript(pack);
expect(t.ok).toBe(true);
Expand All @@ -13,6 +13,16 @@ describe("walkthroughTranscript", () => {
expect(t.markdown).toMatch(/\n> \S/);
expect(t.markdown).toMatch(/\n### /);
expect(t.markdown).not.toMatch(/\n\(/);
expect(t.markdown).toContain(
"*Notebook: Late reading.* Graves says your uncle was reading in the library late last night.",
);
});

it("shows each new notebook entry once, after the text that came before its learn", () => {
const t = walkthroughTranscript(loadLockedStudy());
const entry = t.markdown.indexOf("*Notebook: The password.*");
expect(entry).toBeGreaterThan(0);
expect(t.markdown.indexOf("*Notebook: The password.*", entry + 1)).toBe(-1);
});

it("stops at the first rejected step and says so", () => {
Expand Down
36 changes: 36 additions & 0 deletions packs/letzte-nacht-der-reichsmark/design/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,39 @@ compiled pack before and after, with every text field, name, synonym and
hint step removed, is identical: the revision changes no mechanics. Both
tap-walkthrough end-to-end tests pass. `lexvm transcript` prints the text a
player reads along the walkthrough (about 5,800 words, before about 3,000).

## Notebook entries ahead of the story

A player opened the notebook during Anni's opening conversation and read
»Freund: Tadeusz am Zollkanal« two nodes before Anni names him. The cause
was in the design from the start: world.md wrote each clue's text as a
summary of its whole source, cast.md placed the `learn` in an early node of
that source, and the merge of `an_polizei` into `an_jakob` moved it earlier
still. No stage owned the timing of a clue against its text, and the
transcript, which the review reads, showed no notebook entries.

The rule now in the authoring guide: a clue says only what the player has
read when its `learn` runs; the exception is an entry that is the text of a
document. Reading the transcript, which now shows every entry where it is
learned, found five more entries ahead of the story:

| Clue | Ahead of the story | Change |
|---|---|---|
| `clue_auftrag` | Tadeusz and the Zollkanal (`an_bezahlung`) | `learn` moved from `an_jakob` to the end of `an_bezahlung` |
| `clue_asmussen` | his denial, the Ruine, the 500 Reichsmark (`a_w_geld`) | `learn` moved from `a_w_start` to option `a_w_ablehnen` |
| `clue_zaehlheft` | the register and its owner (`t_elise`) | `learn` moved from `t_heft` to `t_elise`; the point stays in `t_heft` |
| `clue_schweigegeld` | that Anni paid Voss with it (`ah_warum`) | `learn` moved from `ah_kuvert` to `ah_warum`; the point stays in `ah_kuvert` |
| `clue_gestaendnis` | where Jakob lies (`k_wo`) | `learn` moved from `k_gestaendnis` to `k_wo`; the points stay in `k_gestaendnis` |
| `clue_schluessel` | »Nissenhütte«, before anyone says where the Brodersens live | text: »bei den Brodersens zu Hause« |

Each `learn` moved within a forced sequence: the nodes in between offer one
option and a dialogue accepts only `choose`, so no state outside the
conversation changes. Left as they are: `clue_persilschein`,
`clue_anweisung`, `clue_loeschliste` and the card fields of `clue_asmussen`
(the entry is the document), and the lock in `clue_zweitschluessel`
(Voss's own observation of what the player has just seen). Version 1.1.1.

### Verification

`lexvm check`: 0 errors, 0 warnings; walkthrough 74 steps, 25/25;
exploration complete, 6,869 states (unchanged), 0 dead ends.
Loading
Loading