@team-antioch/sc2-adjutant 0.1.0 → 0.1.1
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 +2 -0
- package/data/blizzard-baseline.json +3061 -0
- package/data/button-hotkeys.json +5722 -0
- package/data/game-assets.json +50909 -0
- package/data/package-entries.json +32361 -2
- package/dist/capture/bank-fixtures.d.ts +13 -0
- package/dist/capture/bank-fixtures.js +35 -0
- package/dist/capture/bank-snapshots.d.ts +95 -0
- package/dist/capture/bank-snapshots.js +302 -0
- package/dist/capture/editor-broker-client.d.ts +27 -4
- package/dist/capture/editor-broker-client.js +3 -3
- package/dist/capture/editor-broker.js +154 -9
- package/dist/capture/effect-tour.d.ts +113 -0
- package/dist/capture/effect-tour.js +283 -0
- package/dist/capture/effect-video.d.ts +74 -0
- package/dist/capture/effect-video.js +173 -0
- package/dist/capture/exemplar-capture.d.ts +4 -0
- package/dist/capture/exemplar-capture.js +4 -1
- package/dist/capture/shots.d.ts +6 -1
- package/dist/capture/shots.js +1 -1
- package/dist/capture/stop-tour.d.ts +3 -1
- package/dist/capture/stop-tour.js +1 -1
- package/dist/capture/style-pack-captures.d.ts +67 -0
- package/dist/capture/style-pack-captures.js +172 -0
- package/dist/catalog/stock-catalog.d.ts +8 -0
- package/dist/catalog/stock-catalog.js +13 -0
- package/dist/cli/capture-exemplars.js +18 -32
- package/dist/cli/effect-tour.d.ts +2 -0
- package/dist/cli/effect-tour.js +378 -0
- package/dist/cli/make-frames.d.ts +1 -0
- package/dist/cli/make-frames.js +21 -0
- package/dist/cli/sound-mix.d.ts +1 -0
- package/dist/cli/sound-mix.js +75 -0
- package/dist/cli/study.js +6 -26
- package/dist/domain/blueprint-trigger.d.ts +355 -3
- package/dist/domain/blueprint-trigger.js +149 -8
- package/dist/domain/library-interface.d.ts +50 -29
- package/dist/domain/library-interface.js +54 -41
- package/dist/domain/mission-blueprint.d.ts +13 -6
- package/dist/domain/mission-blueprint.js +6 -0
- package/dist/domain/mod-blueprint.d.ts +4 -4
- package/dist/host/game-logs.d.ts +63 -0
- package/dist/host/game-logs.js +178 -0
- package/dist/host/game-ownership.d.ts +37 -0
- package/dist/host/game-ownership.js +84 -0
- package/dist/host/game-run-report.d.ts +63 -0
- package/dist/host/game-run-report.js +119 -0
- package/dist/host/known-errors.d.ts +34 -0
- package/dist/host/known-errors.js +73 -0
- package/dist/init/init-workspace.d.ts +3 -1
- package/dist/init/init-workspace.js +10 -1
- package/dist/map/convert-mission-triggers.d.ts +115 -7
- package/dist/map/convert-mission-triggers.js +527 -47
- package/dist/map/editor-changes.d.ts +1 -1
- package/dist/map/editor-form.d.ts +5 -0
- package/dist/map/editor-form.js +72 -0
- package/dist/map/game-packages.d.ts +3 -2
- package/dist/map/game-packages.js +5 -2
- package/dist/map/kept-references.js +47 -1
- package/dist/map/kept-session.js +3 -1
- package/dist/map/outline-diff.d.ts +24 -0
- package/dist/map/outline-diff.js +95 -0
- package/dist/map/outline-trigger.d.ts +7 -0
- package/dist/map/outline-trigger.js +29 -20
- package/dist/map/ownership-plan.d.ts +6 -2
- package/dist/map/ownership-plan.js +1 -1
- package/dist/map/package-output.js +13 -8
- package/dist/map/tune-kept-triggers.d.ts +7 -0
- package/dist/map/tune-kept-triggers.js +33 -6
- package/dist/map/write-blueprint-trigger.d.ts +9 -4
- package/dist/map/write-blueprint-trigger.js +46 -13
- package/dist/map/write-map-package.js +20 -9
- package/dist/mcp/capture-jobs.d.ts +2 -0
- package/dist/mcp/capture-jobs.js +2 -0
- package/dist/mcp/server.d.ts +11 -2
- package/dist/mcp/server.js +17 -4
- package/dist/mcp/tools/bank-report.d.ts +19 -0
- package/dist/mcp/tools/bank-report.js +51 -0
- package/dist/mcp/tools/blueprint.js +18 -14
- package/dist/mcp/tools/capture.d.ts +4 -0
- package/dist/mcp/tools/capture.js +22 -5
- package/dist/mcp/tools/catalog.d.ts +1 -1
- package/dist/mcp/tools/catalog.js +30 -1
- package/dist/mcp/tools/compile.d.ts +1 -1
- package/dist/mcp/tools/compile.js +100 -9
- package/dist/mcp/tools/editor-handoff.d.ts +4 -1
- package/dist/mcp/tools/editor-handoff.js +6 -3
- package/dist/mcp/tools/style-pack.d.ts +11 -0
- package/dist/mcp/tools/style-pack.js +245 -0
- package/dist/mcp/tools/tool-group.d.ts +9 -0
- package/dist/mods/button-hotkeys.d.ts +45 -0
- package/dist/mods/button-hotkeys.js +185 -0
- package/dist/mods/compile-mod.js +19 -5
- package/dist/mods/custom-doodads.d.ts +21 -1
- package/dist/mods/custom-doodads.js +53 -7
- package/dist/mods/data-rules.js +8 -1
- package/dist/mods/effective-entry.d.ts +18 -0
- package/dist/mods/effective-entry.js +52 -0
- package/dist/mods/function-search.js +12 -0
- package/dist/mods/library-xml.d.ts +34 -5
- package/dist/mods/library-xml.js +94 -22
- package/dist/mods/sound-mix.d.ts +92 -0
- package/dist/mods/sound-mix.js +195 -0
- package/dist/plugins/check-workspace.js +22 -3
- package/dist/plugins/plugin-api.d.ts +59 -5
- package/dist/plugins/plugin-api.js +6 -0
- package/dist/plugins/plugin-sdk.d.ts +13 -1
- package/dist/plugins/plugin-sdk.js +16 -1
- package/dist/plugins/plugin-sources.js +1 -0
- package/dist/plugins/registry.d.ts +4 -0
- package/dist/plugins/registry.js +6 -2
- package/dist/plugins/workspace.d.ts +5 -0
- package/dist/plugins/workspace.js +10 -2
- package/dist/study/blizzard-baseline.d.ts +76 -0
- package/dist/study/blizzard-baseline.js +137 -0
- package/dist/study/exemplar-report.d.ts +71 -0
- package/dist/study/exemplar-report.js +163 -0
- package/dist/study/find-places.d.ts +127 -0
- package/dist/study/find-places.js +306 -0
- package/dist/study/load-map-package.d.ts +3 -0
- package/dist/study/load-map-package.js +11 -0
- package/dist/study/map-study.d.ts +1 -0
- package/dist/study/map-study.js +3 -0
- package/dist/study/measure-lighting.d.ts +6 -0
- package/dist/study/measure-lighting.js +1 -1
- package/dist/study/measures.d.ts +225 -0
- package/dist/study/measures.js +366 -0
- package/dist/study/scaffold-style-pack.d.ts +58 -0
- package/dist/study/scaffold-style-pack.js +261 -0
- package/dist/study/study-exemplars.d.ts +67 -0
- package/dist/study/study-exemplars.js +133 -0
- package/dist/triggers/blueprint-triggers.d.ts +71 -11
- package/dist/triggers/blueprint-triggers.js +403 -48
- package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
- package/dist/triggers/kept-trigger-galaxy.js +103 -7
- package/dist/triggers/splice-map-script.d.ts +2 -0
- package/dist/triggers/splice-map-script.js +309 -8
- package/dist/triggers/write-triggers-xml.js +20 -5
- package/dist/ui/frame-path-check.d.ts +43 -4
- package/dist/ui/frame-path-check.js +121 -13
- package/dist/ui/frame-paths.d.ts +21 -1
- package/dist/ui/frame-paths.js +26 -6
- package/dist/ui/toast.d.ts +4 -5
- package/dist/ui/toast.js +6 -10
- package/examples/example-campaign/README.md +27 -0
- package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
- package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
- package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
- package/package.json +3 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// The Blizzard baseline: core's lesson-neutral measures (measures.ts) over every campaign mission of
|
|
2
|
+
// Wings of Liberty, Heart of the Swarm, Legacy of the Void and Nova Covert Ops, so a Style Pack's
|
|
3
|
+
// consistency report can tell a mapper's taste from what every SC2 campaign map does. The
|
|
4
|
+
// maintainer builds it once from the game's storage (scripts/build-blizzard-baseline.mjs); it
|
|
5
|
+
// ships as data/blizzard-baseline.json, with no maps and no frames, and mappers never extract anything.
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { MEASURES } from "./measures.js";
|
|
11
|
+
import { round } from "./stats.js";
|
|
12
|
+
export const BLIZZARD_CAMPAIGNS = ["Wings of Liberty", "Heart of the Swarm", "Legacy of the Void", "Nova Covert Ops"];
|
|
13
|
+
const missions = (campaign, folder, ids) => ids.map((id) => ({ id, campaign, storagePath: `${folder}/${id}.sc2map` }));
|
|
14
|
+
const LIBERTY = "campaigns/liberty.sc2campaign/base.sc2maps/maps/campaign";
|
|
15
|
+
const SWARM = "campaigns/swarm.sc2campaign/base.sc2maps/maps/campaign";
|
|
16
|
+
const VOID = "campaigns/void.sc2campaign/base.sc2maps/maps/campaign/void";
|
|
17
|
+
const NOVA = "mods/novastoryassets.sc2mod";
|
|
18
|
+
/**
|
|
19
|
+
* Every map a campaign mission plays on: the main missions with each branch's alternative and the
|
|
20
|
+
* secret mission, Heart of the Swarm's evolution missions, Legacy of the Void's prologue (Whispers of
|
|
21
|
+
* Oblivion, shipped in the Swarm campaign's folder) and epilogue. Left out: the story rooms between
|
|
22
|
+
* missions, the tutorials, the test map, the Lost Viking arcade and the challenge maps, none of
|
|
23
|
+
* which is a mission's battlefield.
|
|
24
|
+
*/
|
|
25
|
+
export const BLIZZARD_CAMPAIGN_MISSIONS = [
|
|
26
|
+
...missions("Wings of Liberty", LIBERTY, [
|
|
27
|
+
"thanson01", "thanson02", "thanson03a", "thanson03b",
|
|
28
|
+
"thorner01", "thorner02", "thorner03", "thorner04", "thorner05s",
|
|
29
|
+
"traynor01", "traynor02", "traynor03",
|
|
30
|
+
"ttosh01", "ttosh02", "ttosh03a", "ttosh03b",
|
|
31
|
+
"ttychus01", "ttychus02", "ttychus03", "ttychus04", "ttychus05",
|
|
32
|
+
"tvalerian01", "tvalerian02a", "tvalerian02b", "tvalerian03",
|
|
33
|
+
"tzeratul01", "tzeratul02", "tzeratul03", "tzeratul04",
|
|
34
|
+
]),
|
|
35
|
+
...missions("Heart of the Swarm", `${SWARM}/swarm`, [
|
|
36
|
+
"zchar01", "zchar02", "zchar03",
|
|
37
|
+
"zexpedition01", "zexpedition02", "zexpedition03",
|
|
38
|
+
"zhybrid01", "zhybrid02", "zhybrid03",
|
|
39
|
+
"zkorhal01", "zkorhal02", "zkorhal03",
|
|
40
|
+
"zlab01", "zlab02", "zlab03",
|
|
41
|
+
"zspace01", "zspace02",
|
|
42
|
+
"zzerus01", "zzerus02", "zzerus03",
|
|
43
|
+
]),
|
|
44
|
+
...missions("Heart of the Swarm", `${SWARM}/swarm/evolution`, [
|
|
45
|
+
"zevolutionbaneling", "zevolutionhydralisk", "zevolutionmutalisk", "zevolutionroach", "zevolutionswarmhost", "zevolutionultralisk", "zevolutionzergling",
|
|
46
|
+
]),
|
|
47
|
+
...missions("Legacy of the Void", `${SWARM}/voidprologue`, ["voidprologue01", "voidprologue02", "voidprologue03"]),
|
|
48
|
+
...missions("Legacy of the Void", VOID, [
|
|
49
|
+
"paiur01", "paiur02", "paiur03", "paiur04", "paiur05", "paiur06",
|
|
50
|
+
"pkorhal01", "pkorhal02",
|
|
51
|
+
"pmoebius01",
|
|
52
|
+
"ppurifier01", "ppurifier02", "ppurifier03",
|
|
53
|
+
"pshakuras01", "pshakuras02",
|
|
54
|
+
"ptaldarim01", "ptaldarim02",
|
|
55
|
+
"pulnar01", "pulnar02", "pulnar03",
|
|
56
|
+
"sc2epilogue01", "sc2epilogue02", "sc2epilogue03",
|
|
57
|
+
]),
|
|
58
|
+
...missions("Nova Covert Ops", `${NOVA}/base.sc2maps/maps/campaign/nova`, ["nova01", "nova02", "nova03"]),
|
|
59
|
+
...missions("Nova Covert Ops", `${NOVA}/base2.sc2maps/maps/campaign/nova`, ["nova04", "nova05", "nova06"]),
|
|
60
|
+
...missions("Nova Covert Ops", `${NOVA}/base3.sc2maps/maps/campaign/nova`, ["nova07", "nova08", "nova09"]),
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* The spread of `values`, nulls left out; null when none has a value. Unlike a Map Study's
|
|
64
|
+
* quantiles (stats.ts, nearest rank, for reading one map's numbers), the percentiles interpolate:
|
|
65
|
+
* a consistency report compares a mapper's few maps against them, where a step from one map's
|
|
66
|
+
* value to the next would move the edge of the spread.
|
|
67
|
+
*/
|
|
68
|
+
export function measureSpread(values) {
|
|
69
|
+
const sorted = values.filter((v) => v !== null).sort((a, b) => a - b);
|
|
70
|
+
if (!sorted.length)
|
|
71
|
+
return null;
|
|
72
|
+
const at = (q) => {
|
|
73
|
+
const position = q * (sorted.length - 1);
|
|
74
|
+
const below = Math.floor(position);
|
|
75
|
+
const above = Math.min(sorted.length - 1, below + 1);
|
|
76
|
+
return round(sorted[below] + (sorted[above] - sorted[below]) * (position - below));
|
|
77
|
+
};
|
|
78
|
+
const mean = sorted.reduce((a, b) => a + b, 0) / sorted.length;
|
|
79
|
+
return { maps: sorted.length, min: sorted[0], p10: at(0.1), p25: at(0.25), median: at(0.5), p75: at(0.75), p90: at(0.9), max: sorted.at(-1), mean: round(mean) };
|
|
80
|
+
}
|
|
81
|
+
export const BLIZZARD_BASELINE_VERSION = 1;
|
|
82
|
+
/** The baseline over `maps`, each with its measures, naming the missions it couldn't measure. */
|
|
83
|
+
export function buildBlizzardBaseline(maps, unavailable = []) {
|
|
84
|
+
const measures = Object.fromEntries(MEASURES.map(({ id, description }) => {
|
|
85
|
+
const values = maps.map((m) => m.measures[id]);
|
|
86
|
+
return [id, { description, spread: measureSpread(values), maps: Object.fromEntries(maps.map((m, k) => [m.id, values[k]])) }];
|
|
87
|
+
}));
|
|
88
|
+
return {
|
|
89
|
+
baselineVersion: BLIZZARD_BASELINE_VERSION,
|
|
90
|
+
note: "Core's lesson-neutral measures (src/study/measures.ts) over every campaign mission of Wings of Liberty, Heart of the Swarm, Legacy of the Void and Nova Covert Ops: per measure, its spread over the maps with a value and each map's value. Built by scripts/build-blizzard-baseline.mjs; data/README.md says why it ships.",
|
|
91
|
+
maps: maps.map(({ id, campaign, name }) => ({ id, campaign, ...(name ? { name } : {}) })),
|
|
92
|
+
unavailable: [...unavailable],
|
|
93
|
+
measures,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const spreadSchema = z.object({
|
|
97
|
+
maps: z.number().int().positive(),
|
|
98
|
+
min: z.number(),
|
|
99
|
+
p10: z.number(),
|
|
100
|
+
p25: z.number(),
|
|
101
|
+
median: z.number(),
|
|
102
|
+
p75: z.number(),
|
|
103
|
+
p90: z.number(),
|
|
104
|
+
max: z.number(),
|
|
105
|
+
mean: z.number(),
|
|
106
|
+
});
|
|
107
|
+
const baselineSchema = z.object({
|
|
108
|
+
baselineVersion: z.literal(BLIZZARD_BASELINE_VERSION),
|
|
109
|
+
note: z.string(),
|
|
110
|
+
maps: z.array(z.object({ id: z.string(), campaign: z.enum(BLIZZARD_CAMPAIGNS), name: z.string().optional() })),
|
|
111
|
+
unavailable: z.array(z.object({ id: z.string(), campaign: z.enum(BLIZZARD_CAMPAIGNS), reason: z.string() })),
|
|
112
|
+
measures: z.record(z.string(), z.object({ description: z.string(), spread: spreadSchema.nullable(), maps: z.record(z.string(), z.number().nullable()) })),
|
|
113
|
+
});
|
|
114
|
+
export const BLIZZARD_BASELINE_PATH = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../data/blizzard-baseline.json");
|
|
115
|
+
let cached;
|
|
116
|
+
/**
|
|
117
|
+
* The shipped baseline. Refused when its file doesn't parse, or its measures aren't the ones core
|
|
118
|
+
* gives (one missing, or one core no longer has), which means core's measures changed without
|
|
119
|
+
* the maintainer rebuilding it.
|
|
120
|
+
*/
|
|
121
|
+
export function readBlizzardBaseline(file = BLIZZARD_BASELINE_PATH) {
|
|
122
|
+
if (file === BLIZZARD_BASELINE_PATH && cached)
|
|
123
|
+
return cached;
|
|
124
|
+
const parsed = baselineSchema.parse(JSON.parse(readFileSync(file, "utf8")));
|
|
125
|
+
const ids = new Set(MEASURES.map(({ id }) => id));
|
|
126
|
+
const missing = [...ids].filter((id) => !parsed.measures[id]);
|
|
127
|
+
const stale = Object.keys(parsed.measures).filter((id) => !ids.has(id));
|
|
128
|
+
if (missing.length || stale.length) {
|
|
129
|
+
const problems = [missing.length ? `has no ${missing.join(", ")}` : "", stale.length ? `has ${stale.join(", ")}, which core doesn't measure` : ""].filter(Boolean);
|
|
130
|
+
throw new Error(`${file} ${problems.join(" and ")}: rebuild it with scripts/build-blizzard-baseline.mjs`);
|
|
131
|
+
}
|
|
132
|
+
// Its measures are exactly core's, checked above, which is what the schema's string keys can't say.
|
|
133
|
+
const baseline = parsed;
|
|
134
|
+
if (file === BLIZZARD_BASELINE_PATH)
|
|
135
|
+
cached = baseline;
|
|
136
|
+
return baseline;
|
|
137
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ExemplarProvenance } from "../plugins/plugin-api.js";
|
|
2
|
+
import { type Workspace } from "../plugins/workspace.js";
|
|
3
|
+
import { type BlizzardBaseline, type MeasureSpread } from "./blizzard-baseline.js";
|
|
4
|
+
import { type MeasureId } from "./measures.js";
|
|
5
|
+
/** How much a map's evidence weighs, by its provenance: a map its author made most. */
|
|
6
|
+
export declare const PROVENANCE_WEIGHT: Readonly<Record<ExemplarProvenance, number>>;
|
|
7
|
+
/**
|
|
8
|
+
* - distinctive: the maps agree, outside Blizzard's spread
|
|
9
|
+
* - common practice: the maps agree, and Blizzard's maps do the same
|
|
10
|
+
* - question: the maps don't agree
|
|
11
|
+
* - no baseline: the maps agree, but no Blizzard map has a value to compare
|
|
12
|
+
* - too few maps: fewer than two maps have a value
|
|
13
|
+
*/
|
|
14
|
+
export declare const VERDICTS: readonly ["distinctive", "common practice", "question", "no baseline", "too few maps"];
|
|
15
|
+
export type Verdict = (typeof VERDICTS)[number];
|
|
16
|
+
/** One map's value of a measure. */
|
|
17
|
+
export type MapValue = {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly value: number;
|
|
20
|
+
};
|
|
21
|
+
/** Blizzard's spread of a measure, as the report places the maps against it. */
|
|
22
|
+
export type BlizzardSpread = Pick<MeasureSpread, "maps" | "p10" | "p25" | "median" | "p75" | "p90">;
|
|
23
|
+
export type ReportMeasure = {
|
|
24
|
+
readonly id: MeasureId;
|
|
25
|
+
readonly description: string;
|
|
26
|
+
readonly verdict: Verdict;
|
|
27
|
+
/** Where the agreeing maps sit against Blizzard's spread (p10 to p90); absent without agreement and a baseline. */
|
|
28
|
+
readonly side?: "above" | "below" | "within";
|
|
29
|
+
/** The agreeing maps' values (every map's with a value, for a question); null when no map has one. */
|
|
30
|
+
readonly spread: {
|
|
31
|
+
readonly min: number;
|
|
32
|
+
readonly max: number;
|
|
33
|
+
readonly median: number;
|
|
34
|
+
} | null;
|
|
35
|
+
/** The maps in the spread, by id; for a question, the largest group, which falls short of agreeing. */
|
|
36
|
+
readonly agreeing: readonly string[];
|
|
37
|
+
/** The maps with a value outside the spread. */
|
|
38
|
+
readonly outliers: readonly MapValue[];
|
|
39
|
+
/** The maps with nothing to measure (no pit, no props of a kind). */
|
|
40
|
+
readonly unmeasured: readonly string[];
|
|
41
|
+
/** The agreeing maps' provenance weight (made 3, edited 2, approved 1), every map's for a question. */
|
|
42
|
+
readonly evidence: number;
|
|
43
|
+
readonly blizzard: BlizzardSpread | null;
|
|
44
|
+
/** The share of Blizzard's maps below the spread's median (ties counting half); null without a baseline. */
|
|
45
|
+
readonly percentile: number | null;
|
|
46
|
+
};
|
|
47
|
+
export type ExemplarReport = {
|
|
48
|
+
readonly maps: readonly {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly provenance: ExemplarProvenance;
|
|
51
|
+
}[];
|
|
52
|
+
/** The Blizzard maps the baseline measured, and the campaign missions it couldn't. */
|
|
53
|
+
readonly baseline: {
|
|
54
|
+
readonly maps: number;
|
|
55
|
+
readonly unavailable: readonly string[];
|
|
56
|
+
};
|
|
57
|
+
/** Every measure, distinctive first, then common practice, questions, and those it can't place. */
|
|
58
|
+
readonly measures: readonly ReportMeasure[];
|
|
59
|
+
};
|
|
60
|
+
export type ExemplarReportOptions = {
|
|
61
|
+
/** The Exemplar Maps to report on, by id; every one the pack lists when not given. */
|
|
62
|
+
readonly ids?: readonly string[];
|
|
63
|
+
/** The baseline to compare with; the shipped one by default. */
|
|
64
|
+
readonly baseline?: Pick<BlizzardBaseline, "maps" | "unavailable" | "measures">;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The consistency report of the active Style Pack's Exemplar Maps (`ids`, every one when not given),
|
|
68
|
+
* from their Map Studies. Refused, naming them, when a map has no study yet or one from before its
|
|
69
|
+
* measures, and for an id the pack doesn't list.
|
|
70
|
+
*/
|
|
71
|
+
export declare function exemplarReport(workspace: Workspace, { ids, baseline }?: ExemplarReportOptions): Promise<ExemplarReport>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// The consistency report (#28): which habits a Style Pack's Exemplar Maps share, and which of those
|
|
2
|
+
// are the mapper's own rather than what every SC2 campaign map does. It reads each map's Map Study
|
|
3
|
+
// (its lesson-neutral measures, measures.ts), so it needs no source map, and compares them with the
|
|
4
|
+
// Blizzard baseline (blizzard-baseline.ts). It names no pack's lessons: only the maps and Blizzard's.
|
|
5
|
+
//
|
|
6
|
+
// Per measure, the maps agree when the largest group of them (by provenance weight) whose values lie
|
|
7
|
+
// within one Blizzard middle half (p25 to p75; see `tolerance` for a measure without one) of each
|
|
8
|
+
// other holds at least two maps and two thirds of every map's weight, the maps with nothing to
|
|
9
|
+
// measure counted too; the rest are its outliers. Agreement wholly outside Blizzard's spread (p10 to p90)
|
|
10
|
+
// is distinctive; agreement that touches it is common practice; no agreement is a question for the mapper.
|
|
11
|
+
import { readFile } from "node:fs/promises";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { WORKSPACE_FILE } from "../plugins/workspace.js";
|
|
15
|
+
import { readBlizzardBaseline } from "./blizzard-baseline.js";
|
|
16
|
+
import { MAP_STUDY_VERSION } from "./map-study.js";
|
|
17
|
+
import { MEASURES } from "./measures.js";
|
|
18
|
+
import { round } from "./stats.js";
|
|
19
|
+
import { pickExemplars } from "./study-exemplars.js";
|
|
20
|
+
/** How much a map's evidence weighs, by its provenance: a map its author made most. */
|
|
21
|
+
export const PROVENANCE_WEIGHT = { made: 3, edited: 2, approved: 1 };
|
|
22
|
+
/** The share of the maps' weight that must agree on a measure. */
|
|
23
|
+
const AGREEING_WEIGHT = 2 / 3;
|
|
24
|
+
/**
|
|
25
|
+
* - distinctive: the maps agree, outside Blizzard's spread
|
|
26
|
+
* - common practice: the maps agree, and Blizzard's maps do the same
|
|
27
|
+
* - question: the maps don't agree
|
|
28
|
+
* - no baseline: the maps agree, but no Blizzard map has a value to compare
|
|
29
|
+
* - too few maps: fewer than two maps have a value
|
|
30
|
+
*/
|
|
31
|
+
export const VERDICTS = ["distinctive", "common practice", "question", "no baseline", "too few maps"];
|
|
32
|
+
/** As much of a study as the report reads: its version and its measures, any others it holds left alone. */
|
|
33
|
+
const StudyMeasuresSchema = z.object({ mapStudyVersion: z.unknown(), measures: z.record(z.string(), z.unknown()).optional() }).passthrough();
|
|
34
|
+
const isMeasureValue = (v) => v === null || typeof v === "number";
|
|
35
|
+
/** The measures in `exemplar`'s study, or why it has none to report. */
|
|
36
|
+
async function readStudy(exemplar) {
|
|
37
|
+
const file = path.join(exemplar.studyDir, "study.json");
|
|
38
|
+
let text;
|
|
39
|
+
try {
|
|
40
|
+
text = await readFile(file, "utf8");
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error.code === "ENOENT")
|
|
44
|
+
return { id: exemplar.id, missing: "no study" };
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
let json;
|
|
48
|
+
try {
|
|
49
|
+
json = JSON.parse(text);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(`${file} isn't valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
53
|
+
}
|
|
54
|
+
const parsed = StudyMeasuresSchema.safeParse(json);
|
|
55
|
+
if (!parsed.success)
|
|
56
|
+
return { id: exemplar.id, missing: "a study.json that isn't a Map Study" };
|
|
57
|
+
const { mapStudyVersion, measures } = parsed.data;
|
|
58
|
+
if (mapStudyVersion !== MAP_STUDY_VERSION)
|
|
59
|
+
return { id: exemplar.id, missing: `a study of another version (${String(mapStudyVersion)}, not ${MAP_STUDY_VERSION})` };
|
|
60
|
+
if (!measures || MEASURES.some(({ id }) => !isMeasureValue(measures[id])))
|
|
61
|
+
return { id: exemplar.id, missing: "a study from before its measures" };
|
|
62
|
+
return { id: exemplar.id, provenance: exemplar.provenance, measures: Object.fromEntries(MEASURES.map(({ id }) => [id, measures[id]])) };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The consistency report of the active Style Pack's Exemplar Maps (`ids`, every one when not given),
|
|
66
|
+
* from their Map Studies. Refused, naming them, when a map has no study yet or one from before its
|
|
67
|
+
* measures, and for an id the pack doesn't list.
|
|
68
|
+
*/
|
|
69
|
+
export async function exemplarReport(workspace, { ids, baseline = readBlizzardBaseline() } = {}) {
|
|
70
|
+
const pack = workspace.stylePack;
|
|
71
|
+
if (!pack)
|
|
72
|
+
throw new Error(`The Workspace names no Style Pack (stylePack in ${path.join(workspace.root, WORKSPACE_FILE)}), so it has no Exemplar Maps`);
|
|
73
|
+
const listed = workspace.registry.contributions("exemplarMaps").filter((exemplar) => exemplar.plugin === pack);
|
|
74
|
+
if (!listed.length)
|
|
75
|
+
throw new Error(`The Style Pack ${pack} lists no Exemplar Maps to report on: add them to its exemplars.json, then run study_exemplar`);
|
|
76
|
+
const read = await Promise.all(pickExemplars(listed, ids).map(readStudy));
|
|
77
|
+
const unstudied = read.filter((study) => "missing" in study);
|
|
78
|
+
if (unstudied.length) {
|
|
79
|
+
throw new Error(`No Map Study to report on for Exemplar Map ${unstudied.map(({ id, missing }) => `${id} (${missing})`).join(", ")}: run study_exemplar for ${unstudied.length > 1 ? "them" : "it"} first`);
|
|
80
|
+
}
|
|
81
|
+
const studies = read;
|
|
82
|
+
const measures = MEASURES.map(({ id, description }) => reportMeasure(id, description, studies, baseline.measures[id].spread, Object.values(baseline.measures[id].maps)));
|
|
83
|
+
return {
|
|
84
|
+
maps: studies.map(({ id, provenance }) => ({ id, provenance })),
|
|
85
|
+
baseline: { maps: baseline.maps.length, unavailable: baseline.unavailable.map(({ id }) => id) },
|
|
86
|
+
measures: rank(measures),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const sum = (values) => values.reduce((total, v) => total + v.weight, 0);
|
|
90
|
+
const median = (sorted) => {
|
|
91
|
+
const middle = (sorted.length - 1) / 2;
|
|
92
|
+
return (sorted[Math.floor(middle)] + sorted[Math.ceil(middle)]) / 2;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* How far apart values can be and still agree: Blizzard's middle half (p25 to p75), else its middle
|
|
96
|
+
* 80% (p10 to p90), else its whole range, and when every Blizzard map has the same value, a tenth
|
|
97
|
+
* of the largest of the maps' values.
|
|
98
|
+
*/
|
|
99
|
+
function tolerance(blizzard, values) {
|
|
100
|
+
const widths = blizzard ? [blizzard.p75 - blizzard.p25, blizzard.p90 - blizzard.p10, blizzard.max - blizzard.min] : [];
|
|
101
|
+
return widths.find((w) => w > 0) ?? Math.max(...values.map((v) => Math.abs(v.value))) / 10;
|
|
102
|
+
}
|
|
103
|
+
/** The heaviest run of `sorted` values within `width` of its first: by weight, then by maps, then the narrowest. */
|
|
104
|
+
function heaviestRun(sorted, width) {
|
|
105
|
+
let best = [];
|
|
106
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
107
|
+
const run = sorted.slice(i).filter((v) => v.value - sorted[i].value <= width + 1e-9);
|
|
108
|
+
const spanOf = (r) => r.at(-1).value - r[0].value;
|
|
109
|
+
const better = sum(run) - sum(best) || run.length - best.length || (best.length ? spanOf(best) - spanOf(run) : 1);
|
|
110
|
+
if (better > 0)
|
|
111
|
+
best = run;
|
|
112
|
+
}
|
|
113
|
+
return best;
|
|
114
|
+
}
|
|
115
|
+
function reportMeasure(id, description, studies, blizzard, blizzardValues) {
|
|
116
|
+
const values = studies.flatMap((study) => {
|
|
117
|
+
const value = study.measures[id];
|
|
118
|
+
return value === null || value === undefined ? [] : [{ id: study.id, value, weight: PROVENANCE_WEIGHT[study.provenance] }];
|
|
119
|
+
});
|
|
120
|
+
const sorted = [...values].sort((a, b) => a.value - b.value);
|
|
121
|
+
const unmeasured = studies.filter((study) => !values.some((v) => v.id === study.id)).map((study) => study.id);
|
|
122
|
+
const against = blizzard ? { maps: blizzard.maps, p10: blizzard.p10, p25: blizzard.p25, median: blizzard.median, p75: blizzard.p75, p90: blizzard.p90 } : null;
|
|
123
|
+
const base = { id, description, unmeasured, blizzard: against };
|
|
124
|
+
const known = blizzardValues.filter((v) => v !== null);
|
|
125
|
+
/** The run's spread, with the share of Blizzard's maps below its median (taken unrounded, so ties count). */
|
|
126
|
+
const placedOf = (run) => {
|
|
127
|
+
if (!run.length)
|
|
128
|
+
return { spread: null, percentile: null };
|
|
129
|
+
const middle = median(run.map((v) => v.value));
|
|
130
|
+
const percentile = known.length ? round((known.filter((v) => v < middle).length + known.filter((v) => v === middle).length / 2) / known.length, 2) : null;
|
|
131
|
+
return { spread: { min: run[0].value, max: run.at(-1).value, median: round(middle) }, percentile };
|
|
132
|
+
};
|
|
133
|
+
if (sorted.length < 2) {
|
|
134
|
+
return { ...base, verdict: "too few maps", ...placedOf(sorted), agreeing: sorted.map((v) => v.id), outliers: [], evidence: sum(sorted) };
|
|
135
|
+
}
|
|
136
|
+
const run = heaviestRun(sorted, tolerance(blizzard, sorted));
|
|
137
|
+
const outliers = sorted.filter((v) => !run.includes(v)).map(({ id: map, value }) => ({ id: map, value }));
|
|
138
|
+
// Two thirds of every map's weight, the unmeasured too: two maps with a pit don't make a habit of five maps.
|
|
139
|
+
const everyMap = studies.reduce((total, study) => total + PROVENANCE_WEIGHT[study.provenance], 0);
|
|
140
|
+
if (run.length < 2 || sum(run) < AGREEING_WEIGHT * everyMap - 1e-9) {
|
|
141
|
+
return { ...base, verdict: "question", ...placedOf(sorted), agreeing: run.map((v) => v.id), outliers, evidence: sum(sorted) };
|
|
142
|
+
}
|
|
143
|
+
const placed = placedOf(run);
|
|
144
|
+
const spread = placed.spread;
|
|
145
|
+
const percentile = placed.percentile;
|
|
146
|
+
const agreed = { ...base, spread, agreeing: run.map((v) => v.id), outliers, evidence: sum(run), percentile };
|
|
147
|
+
if (!blizzard)
|
|
148
|
+
return { ...agreed, verdict: "no baseline" };
|
|
149
|
+
const side = spread.min > blizzard.p90 ? "above" : spread.max < blizzard.p10 ? "below" : "within";
|
|
150
|
+
return { ...agreed, verdict: side === "within" ? "common practice" : "distinctive", side };
|
|
151
|
+
}
|
|
152
|
+
/** How far the spread sits outside Blizzard's p10 to p90, in Blizzard's own p10-to-p90 widths. */
|
|
153
|
+
function distance(measure) {
|
|
154
|
+
const { spread, blizzard } = measure;
|
|
155
|
+
if (!spread || !blizzard)
|
|
156
|
+
return 0;
|
|
157
|
+
const width = blizzard.p90 - blizzard.p10 || 1;
|
|
158
|
+
return Math.max(spread.min - blizzard.p90, blizzard.p10 - spread.max, 0) / width;
|
|
159
|
+
}
|
|
160
|
+
/** By verdict (VERDICTS' order), then the heaviest evidence, then the farthest from Blizzard's spread, then MEASURES' order. */
|
|
161
|
+
function rank(measures) {
|
|
162
|
+
return [...measures].sort((a, b) => VERDICTS.indexOf(a.verdict) - VERDICTS.indexOf(b.verdict) || b.evidence - a.evidence || distance(b) - distance(a));
|
|
163
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { StudiedDoodad } from "./measure-doodads.js";
|
|
2
|
+
/** A type's motif, from its name: what it is for, whatever its planet; "other" when none matches. */
|
|
3
|
+
export declare const motifOf: (type: string) => string;
|
|
4
|
+
export type PlaceRole = "anchor" | "fill" | "scatter";
|
|
5
|
+
export type RoleEntry = {
|
|
6
|
+
readonly type: string;
|
|
7
|
+
readonly motif: string;
|
|
8
|
+
readonly count: number;
|
|
9
|
+
readonly share: number;
|
|
10
|
+
};
|
|
11
|
+
export type Place = {
|
|
12
|
+
readonly map: string;
|
|
13
|
+
/** Set only by the caller's mood rules. */
|
|
14
|
+
readonly mood?: string;
|
|
15
|
+
readonly center: readonly [number, number];
|
|
16
|
+
readonly size: readonly [number, number];
|
|
17
|
+
/** Members other than point lights. */
|
|
18
|
+
readonly visible: number;
|
|
19
|
+
readonly distinctTypes: number;
|
|
20
|
+
readonly perHundredCells: number;
|
|
21
|
+
/** The median distance from each visible member to its nearest neighbour. */
|
|
22
|
+
readonly spacing: {
|
|
23
|
+
readonly median: number | null;
|
|
24
|
+
};
|
|
25
|
+
/** Each motif's share of the visible members, largest first. */
|
|
26
|
+
readonly motifs: Readonly<Record<string, number>>;
|
|
27
|
+
/** Scatter: a type used 6 or more times, or a decal; anchor: a type used once or twice; the rest is fill. */
|
|
28
|
+
readonly roles: Readonly<Record<PlaceRole, readonly RoleEntry[]>>;
|
|
29
|
+
/** The share of visible members whose yaw is snapped to 45 degrees. */
|
|
30
|
+
readonly yawSnapped45: number | null;
|
|
31
|
+
readonly scale: readonly [number, number] | null;
|
|
32
|
+
readonly manipulations: Readonly<Record<string, number>>;
|
|
33
|
+
readonly lights: {
|
|
34
|
+
readonly count: number;
|
|
35
|
+
readonly colours: Readonly<Record<string, number>>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The frames near the place, when the caller passed its capture stops: paths relative to the
|
|
39
|
+
* `captureDir` given to `readCaptureStops`, always under `<map>/frames/`.
|
|
40
|
+
*/
|
|
41
|
+
readonly frames?: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
/** A Style Pack's mood: a place has it when `test` passes on the place's motif shares. */
|
|
44
|
+
export type MoodRule = {
|
|
45
|
+
readonly name: string;
|
|
46
|
+
readonly test: (motifs: Readonly<Record<string, number>>) => boolean;
|
|
47
|
+
};
|
|
48
|
+
/** One test of a recorded mood: the motifs' shares, added up, are at least `atLeast`. */
|
|
49
|
+
export type MoodCondition = {
|
|
50
|
+
readonly motifs: readonly string[];
|
|
51
|
+
readonly atLeast: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A mood as a Style Pack's mixtures file records it (`moodRules`): a place has it when every
|
|
55
|
+
* condition of any one of `when`'s alternatives holds. With no `when`, every place does, so it
|
|
56
|
+
* belongs last, as the catch-all.
|
|
57
|
+
*/
|
|
58
|
+
export type RecordedMood = {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly when?: readonly (readonly MoodCondition[])[];
|
|
61
|
+
};
|
|
62
|
+
/** The mood rule a recorded mood stands for. */
|
|
63
|
+
export declare function moodRuleOf({ name, when }: RecordedMood): MoodRule;
|
|
64
|
+
export type FindPlacesOptions = {
|
|
65
|
+
/** Checked in order; a place takes the first that passes, and has no mood when none does. */
|
|
66
|
+
readonly moods?: readonly MoodRule[];
|
|
67
|
+
/** The map's capture stops (`readCaptureStops`): each place then lists the frames near it. */
|
|
68
|
+
readonly stops?: CaptureStops;
|
|
69
|
+
};
|
|
70
|
+
/** One stop of a capture tour: frame `n` of `tour`, its camera on (x, y). */
|
|
71
|
+
export type CaptureStop = {
|
|
72
|
+
readonly tour: string;
|
|
73
|
+
readonly n: number;
|
|
74
|
+
readonly x: number;
|
|
75
|
+
readonly y: number;
|
|
76
|
+
};
|
|
77
|
+
/** The stops a map's frames are taken from; `placeTours` when they are place tours, stopping at place centres. */
|
|
78
|
+
export type CaptureStops = {
|
|
79
|
+
readonly stops: readonly CaptureStop[];
|
|
80
|
+
readonly placeTours: boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The stops of one map's tours under `captureDir` (`<captureDir>/<map>/captures/<tour>/stops.txt`,
|
|
84
|
+
* else the same under `frames/`): every place tour when the map has any (a map lit by zone has one
|
|
85
|
+
* per lighting), else its first grid tour. Undefined when the map has no tours.
|
|
86
|
+
*/
|
|
87
|
+
export declare function readCaptureStops(captureDir: string, map: string): CaptureStops | undefined;
|
|
88
|
+
/** The dressed places among one map's doodads (from `studyDoodads`), largest first. */
|
|
89
|
+
export declare function findPlaces(map: string, doodads: readonly StudiedDoodad[], options?: FindPlacesOptions): Place[];
|
|
90
|
+
/** Lower quartile, median and upper quartile. */
|
|
91
|
+
type Quartiles = readonly [number, number, number];
|
|
92
|
+
/** One mood's typical mixture across the places that have it. */
|
|
93
|
+
export type MoodMixture = {
|
|
94
|
+
readonly places: number;
|
|
95
|
+
readonly maps: readonly string[];
|
|
96
|
+
/** Each motif's share quartiles, by median then upper quartile, motifs no place uses left out. */
|
|
97
|
+
readonly motifs: Readonly<Record<string, Quartiles>>;
|
|
98
|
+
readonly visible: Quartiles | null;
|
|
99
|
+
readonly distinctTypes: Quartiles | null;
|
|
100
|
+
readonly anchors: Quartiles | null;
|
|
101
|
+
readonly perHundredCells: Quartiles | null;
|
|
102
|
+
readonly spacing: Quartiles | null;
|
|
103
|
+
readonly yawSnapped45: Quartiles | null;
|
|
104
|
+
readonly lightsPerPlace: Quartiles | null;
|
|
105
|
+
readonly lightColours: Readonly<Record<string, number>>;
|
|
106
|
+
/** Per motif, per map, the types it used for that motif (up to 8, "<type> <count>"). */
|
|
107
|
+
readonly pools: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
|
|
108
|
+
/** Up to six places with frames. */
|
|
109
|
+
readonly examples: readonly {
|
|
110
|
+
readonly map: string;
|
|
111
|
+
readonly center: readonly [number, number];
|
|
112
|
+
readonly frames: readonly string[];
|
|
113
|
+
}[];
|
|
114
|
+
};
|
|
115
|
+
/** A place as the mixtures list it: where, how big, its motifs and its top three types per role. */
|
|
116
|
+
export type PlaceSummary = Pick<Place, "map" | "mood" | "center" | "size" | "visible" | "motifs" | "frames"> & {
|
|
117
|
+
readonly top: readonly string[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A Style Pack's mixtures from its places: per mood, in `moods` order, the typical mixture of the
|
|
121
|
+
* places that have it (a mood with none is left out), and every place in brief.
|
|
122
|
+
*/
|
|
123
|
+
export declare function buildMixtures(places: readonly Place[], moods: readonly string[]): {
|
|
124
|
+
moods: Record<string, MoodMixture>;
|
|
125
|
+
places: PlaceSummary[];
|
|
126
|
+
};
|
|
127
|
+
export {};
|