diff --git a/data/public/pdf_encounters.json b/data/public/pdf_encounters.json new file mode 100644 index 0000000..2ab7e13 --- /dev/null +++ b/data/public/pdf_encounters.json @@ -0,0 +1,737 @@ +{ + "_about": "The answers inside each bonding encounter, transcribed by hand from the community route PDF (see source). Data, not the flowchart: each option's answer (say), the guide's printed rate (pct), whether it is on the guide's recommended dark-tile path (best), whether the guide marks it untested or unconfirmed (unconfirmed), and what follows (then) or how it ends (end); roll marks a step the guide calls an unknown chance or decision. route_encounters: which encounters each bonding encounter of the route model shows. Edit this file when the PDF changes (the daily check opens a pull request on the bot's repo when it does).", + "version": 1, + "source": { + "title": "Threshing Options (community route PDF)", + "authors": [ + "u/ClumsyBadger", + "u/Old_Regular3018", + "u/Smart_Trifle_2099" + ], + "version": "2026-11-16", + "link": "https://drive.google.com/file/d/17o72ehHsSPW4UdsKF-sXTxMLEuinWeEg/view", + "note": "Percentages are the guide's, from documented runs; options off the recommended path often rest on fewer than three records." + }, + "encounters": { + "valley-Red": { + "title": "The valley Red", + "scene": "You're moved by an instinctual feeling that this...", + "options": [ + { + "say": "Is your dragon", + "best": true, + "then": [ + { + "say": "You're sure", + "best": true, + "then": [ + { + "say": "Continue approach", + "best": true, + "then": [ + { + "say": "Touch its talon", + "best": true, + "pct": "93%", + "end": "Bonded" + }, + { + "say": "Run to mount its foreleg", + "end": "Bonded" + } + ] + }, + { + "say": "Exit gracefully", + "end": "That was close (on to the meadow)" + } + ] + }, + { + "say": "On second thought…", + "end": "That was close (on to the meadow)" + } + ] + }, + { + "say": "Is not your dragon, leave", + "end": "That was close (on to the meadow)" + } + ] + }, + "tree-Red": { + "title": "The Red below the tree", + "scene": "A red dragon prowls ten feet beneath you.", + "warning": "The guide gives a 98% chance of dying if you engage this dragon.", + "options": [ + { + "say": "Jump on its back, or jump to land by its tail", + "then": [ + { + "roll": "Some unknown chance or decision roll" + }, + { + "say": "Hold the Red's gaze", + "then": [ + { + "say": "Jump off and hope", + "end": "Incinerated" + }, + { + "say": "Drop to your stomach", + "then": [ + { + "say": "Hang tight", + "end": "Incinerated" + }, + { + "say": "Crawl to the seat", + "pct": "2%", + "end": "Bonded" + } + ] + } + ] + }, + { + "say": "Lower your eyes", + "end": "Incinerated" + } + ] + }, + { + "say": "Wait and pursue the Green", + "end": "On to the two Greens" + } + ] + }, + "tree-Greens": { + "title": "The two Greens", + "scene": "You enter a clearing with two Green dragons.", + "options": [ + { + "say": "Turn to the right dragon", + "best": true, + "then": [ + { + "say": "Glance to the left dragon", + "end": "Incinerated" + }, + { + "say": "Don't move a muscle", + "best": true, + "then": [ + { + "say": "Stay still", + "best": true, + "then": [ + { + "say": "Decapitation isn't scary", + "best": true, + "then": [ + { + "say": "You respect their nature", + "best": true, + "end": "Bonded (Right Green)" + }, + { + "say": "You don't know", + "end": "Incinerated" + }, + { + "say": "Greens have the best magic", + "best": true, + "end": "Bonded (Left Green)" + }, + { + "say": "Intellect match", + "best": true, + "end": "A Brown saves you: Bonded (Brown)" + } + ] + }, + { + "say": "Sidestep out of its mouth", + "end": "Incinerated" + } + ] + }, + { + "say": "Sidestep out of its mouth", + "end": "Incinerated" + } + ] + } + ] + }, + { + "say": "Turn to the left dragon", + "best": true, + "then": [ + { + "say": "Glance to the right dragon", + "end": "Incinerated" + }, + { + "say": "Don't move a muscle", + "best": true, + "then": [ + { + "say": "Hold your ground", + "best": true, + "then": [ + { + "say": "You always overextend", + "best": true, + "end": "Bonded (Right Green)" + }, + { + "say": "You lack flaws", + "end": "Incinerated" + }, + { + "say": "You struggle with temper", + "best": true, + "end": "Bonded (Left Green)" + }, + { + "say": "You're always right", + "best": true, + "end": "An Orange saves you: Bonded (Orange)" + } + ] + }, + { + "say": "Step back", + "end": "Incinerated" + } + ] + } + ] + }, + { + "say": "Stay neutral", + "end": "Incinerated" + } + ] + }, + "meadow-Orange": { + "title": "The meadow Orange", + "scene": "You approach the Orange dragon.", + "options": [ + { + "say": "Absolutely sure, Orange", + "best": true, + "pct": "90%", + "then": [ + { + "say": "Roar right back at it", + "best": true, + "pct": "69%", + "then": [ + { + "say": "Flee", + "end": "Incinerated" + }, + { + "say": "Attempt to mount", + "best": true, + "end": "Bonded" + }, + { + "roll": "Possibly an unknown decision or chance mechanic (20%)" + }, + { + "say": "Hit the ground", + "best": true, + "then": [ + { + "say": "Run to mount its foreleg", + "best": true, + "end": "Bonded" + }, + { + "say": "Look it in the eye", + "then": [ + { + "say": "Run to mount", + "end": "Bonded" + }, + { + "say": "Maintain eye contact", + "end": "Incinerated" + } + ] + } + ] + }, + { + "say": "Run at the claw", + "then": [ + { + "say": "Hold tight for balance", + "end": "Incinerated" + }, + { + "say": "Climb with strength", + "end": "Bonded" + } + ] + } + ] + }, + { + "say": "Run, this was a mistake", + "end": "Incinerated" + } + ] + }, + { + "say": "On second thought…", + "pct": "10%", + "end": "Incinerated" + } + ] + }, + "meadow-Brown": { + "title": "The meadow Brown", + "scene": "You approach the Brown dragon.", + "options": [ + { + "say": "Run after the Brown", + "best": true, + "then": [ + { + "say": "On second thought…", + "end": "Incinerated" + }, + { + "say": "Your heart is sure", + "best": true, + "then": [ + { + "say": "Shout at it to stop", + "pct": "50%", + "then": [ + { + "say": "Apologise immediately", + "pct": "50%", + "end": "Incinerated" + }, + { + "say": "Await judgment, or pray", + "pct": "90%", + "then": [ + { + "say": "Mud fight!", + "then": [ + { + "say": "Wipe off the mud", + "pct": "90%", + "then": [ + { + "say": "The dragon speaks", + "then": [ + { + "say": "Defend the kingdom", + "end": "Death 50/50" + }, + { + "say": "Defend the powerless", + "end": "Bonded" + }, + { + "say": "Seek revenge", + "end": "Incinerated" + } + ] + } + ] + }, + { + "say": "Throw mud at the dragon", + "pct": "60%", + "end": "Bonded" + }, + { + "say": "Find a better dragon", + "end": "Not recorded" + } + ] + } + ] + } + ] + }, + { + "say": "Indecisively chase it", + "end": "Incinerated" + }, + { + "say": "Mount the Brown's tail", + "best": true, + "then": [ + { + "say": "Throw your weight", + "best": true, + "then": [ + { + "say": "You'll charm it", + "best": true, + "end": "Bonded" + }, + { + "say": "Hope for a clean death", + "end": "Incinerated" + }, + { + "say": "It's already talking to you", + "end": "Bonded" + } + ] + }, + { + "say": "Wait for a better angle", + "end": "Incinerated" + } + ] + } + ] + } + ] + }, + { + "say": "Turn to the Orange", + "end": "Incinerated" + } + ] + }, + "meadow-Blue": { + "title": "The meadow Blue", + "scene": "You approach the Blue dragon.", + "options": [ + { + "say": "Change to Orange", + "pct": "?", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Change to Brown", + "pct": "?", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Absolutely, Blue Dragon", + "best": true, + "pct": "90%", + "then": [ + { + "say": "Hold glare and advance", + "best": true, + "pct": "80%", + "then": [ + { + "say": "Do nothing", + "best": true, + "pct": "83%", + "then": [ + { + "say": "Lower your eyes", + "pct": "?", + "unconfirmed": true, + "end": "Incinerated" + }, + { + "say": "Help the cadet", + "pct": "0%", + "end": "Incinerated" + }, + { + "say": "Hold glare and watch", + "best": true, + "pct": "80%", + "then": [ + { + "say": "Straighten your spine", + "best": true, + "pct": "82%", + "then": [ + { + "say": "Hold steady", + "pct": "0%", + "unconfirmed": true, + "end": "Incinerated" + }, + { + "say": "Launch yourself right", + "best": true, + "pct": "85%", + "then": [ + { + "say": "You already know", + "pct": "?", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Bring down an empire", + "best": true, + "pct": "80%", + "then": [ + { + "say": "Seize the chance to mount", + "pct": "50%", + "end": "Incinerated" + }, + { + "say": "Move slowly forward", + "best": true, + "pct": "80%", + "end": "Bonded" + }, + { + "say": "Hold still", + "pct": "50%", + "end": "Incinerated" + } + ] + }, + { + "say": "I want revenge", + "pct": "?", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Defend the helpless", + "pct": "?", + "unconfirmed": true, + "end": "Not tested" + } + ] + } + ] + }, + { + "say": "Speak first", + "pct": "20%", + "end": "Incinerated" + }, + { + "say": "Do nothing", + "pct": "?", + "end": "Incinerated" + } + ] + } + ] + }, + { + "say": "Intervene and help", + "pct": "?", + "end": "Incinerated" + } + ] + }, + { + "say": "Lower gaze, halt advance", + "pct": "0%", + "end": "Incinerated" + }, + { + "say": "Lower gaze, advance", + "pct": "0%", + "end": "Incinerated" + } + ] + } + ] + }, + "shadow": { + "title": "The shadow", + "scene": "You've seen a shadow, where will it lead...", + "options": [ + { + "say": "A green sounds good", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Stay the course", + "best": true, + "then": [ + { + "say": "Well this is intriguing", + "best": true, + "then": [ + { + "say": "Curiosity sated, retreat", + "then": [ + { + "say": "Find that Green", + "end": "On to the two Greens" + }, + { + "say": "Go towards the valley", + "unconfirmed": true, + "end": "Not tested" + } + ] + }, + { + "say": "Freeze and lower your eyes", + "best": true, + "then": [ + { + "say": "Warn the cadet", + "end": "Incinerated" + }, + { + "say": "Hold still", + "best": true, + "then": [ + { + "say": "Aid the cadet", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "Hold position", + "best": true, + "then": [ + { + "say": "Approach the Blue", + "then": [ + { + "say": "On second thought…", + "unconfirmed": true, + "end": "Not tested" + }, + { + "say": "You're sure", + "unconfirmed": true, + "end": "Incinerated?" + } + ] + }, + { + "say": "Await judgement", + "best": true, + "then": [ + { + "say": "Help the cadet", + "best": true, + "then": [ + { + "say": "Use your dagger", + "best": true, + "then": [ + { + "say": "Head south and hope", + "best": true, + "end": "On to the Black" + } + ] + }, + { + "say": "Take them to cold water", + "end": "Head back for the Greens, or explore other dragons" + }, + { + "say": "Clean their uniform", + "end": "Head back for the Greens, or explore other dragons" + } + ] + }, + { + "say": "Leave to find your dragon", + "end": "Head back for the Greens, or explore other dragons" + } + ] + }, + { + "say": "Run towards the other cadet", + "unconfirmed": true, + "end": "Not tested" + } + ] + }, + { + "say": "Last chance to escape", + "end": "Head back for the Greens, or explore other dragons" + } + ] + }, + { + "say": "Leave while it's distracted", + "end": "Head back for the Greens, or explore other dragons" + } + ] + } + ] + }, + { + "say": "Too big, you're out", + "end": "Head back for the Greens, or explore other dragons" + } + ] + } + ] + }, + "black": { + "title": "The Black", + "scene": "A branch snaps behind you...", + "note": "Lowering your eyes has frequently ended in incineration; what follows it is unconfirmed.", + "options": [ + { + "say": "Ignore it, keep walking", + "end": "Incinerated" + }, + { + "say": "Turn to face the threat", + "best": true, + "then": [ + { + "say": "Lower your eyes", + "end": "Incinerated" + }, + { + "say": "Hold its gaze", + "best": true, + "end": "Bonded" + } + ] + } + ] + } + }, + "route_encounters": { + "valley-Red": [ + "valley-Red" + ], + "tree-Red": [ + "tree-Red" + ], + "tree-Greens": [ + "tree-Greens" + ], + "meadow-Orange": [ + "meadow-Orange" + ], + "meadow-Brown": [ + "meadow-Brown" + ], + "meadow-Blue": [ + "meadow-Blue" + ], + "shadow-Blue": [ + "shadow" + ], + "shadow-Black": [ + "shadow", + "black" + ] + } +} diff --git a/site/atlas/explorer.js b/site/atlas/explorer.js index e6a4502..2938c7a 100644 --- a/site/atlas/explorer.js +++ b/site/atlas/explorer.js @@ -753,6 +753,92 @@ ${trafficToggle()}`; } + /** Inside the bonding encounter: the answers the bot gave, screen by screen, on its best logged way to bond this + * colour (data/tree.json, analysis/tree/build_tree.py), with what every other answer did. Only shown when the bot's + * way goes through the same encounter as the route; the community form does not record these answers. */ + const TREE_SIDE = (enc) => (/^(valley|meadow)-/.test(enc) ? "valley" : "tree"); + /** The community route PDF's answers for an encounter (data/pdf_encounters.json): its recommended (dark-tile) answers + * as numbered steps toward this dragon, then the whole tree. */ + // the goal inside one encounter: a bond with this colour, or (an encounter that leads on, like the shadow before + // the Black) the way on to the next one + const isGoal = (end, colour, onward) => onward ? new RegExp(`^On to the ${onward}`).test(end || "") + : /^Bonded|Bonded \(/.test(end || "") && (!/\(/.test(end) || new RegExp(colour).test(end)); + function leadsTo(o, colour, onward) { + if (o.end) return isGoal(o.end, colour, onward); + return (o.then || []).some((c) => !c.roll && leadsTo(c, colour, onward)); + } + function guidePath(options, colour, onward) { + const steps = []; + let opts = options; + while (opts && opts.length) { + const live = opts.filter((o) => !o.roll); + const pick = live.find((o) => o.best && leadsTo(o, colour, onward)) || live.find((o) => leadsTo(o, colour, onward)); + if (!pick) break; + const roll = opts.find((o) => o.roll); + steps.push({ pick, others: live.filter((o) => o !== pick), roll: roll ? roll.roll : null }); + if (pick.end) break; + opts = pick.then; + } + return steps; + } + const endOf = (o) => (o.end ? o.end : "continues"); + function treeList(options) { + return ``; + } + function guideAnswers(enc) { + const g = st.guide; + if (!g) return ""; + const keys = (g.route_encounters || {})[enc] || []; + if (!keys.length) return ""; + const src = g.source || {}; + const blocks = keys.map((k, ki) => { + const E = g.encounters[k]; + if (!E) return ""; + const next = keys[ki + 1] ? (g.encounters[keys[ki + 1]] || {}).title || "" : ""; + const steps = guidePath(E.options, st.colour, next ? next.replace(/^The /, "") : null); + const rows = steps.map((s, i) => `
  • ${i + 1}
    ${esc(s.pick.say)}${s.roll ? `The guide notes: ${esc(s.roll)}.` : ""} + ${s.pick.pct ? `the guide's rate: ${esc(s.pick.pct)}` : ""}${s.pick.unconfirmed ? " · unconfirmed" : ""}${s.pick.end ? `${s.pick.pct ? " · " : ""}${esc(s.pick.end)}` : ""} + ${s.others.length ? `
    Other answers here
      ${s.others.map((o) => `
    • ${esc(o.say)}${o.pct ? ` ${esc(o.pct)}` : ""} → ${esc(endOf(o))}
    • `).join("")}
    ` : ""}
  • `).join(""); + return `

    ${esc(E.title)}: ${esc(E.scene)}${E.warning ? ` ${esc(E.warning)}` : ""}

    + ${rows ? `
      ${rows}
    ` : `

    The guide shows no way to bond a ${st.colour} here.

    `} + ${E.note ? `

    ${esc(E.note)}

    ` : ""} +
    Every answer in the guide's tree${treeList(E.options)}
    `; + }).join(""); + return `
    Inside the encounter: the community guide's answers${blocks} +

    From the community route PDF by ${esc((src.authors || []).join(", "))} (${esc(src.version || "")} version), transcribed as data. ${esc(src.note || "")}

    `; + } + + function encounterAnswers(enc) { + return guideAnswers(enc) + botAnswers(enc); + } + function botAnswers(enc) { + const t = st.tree; + if (!t) return '

    Loading the answers inside the encounter…

    '; + const best = (t.best || {})[st.colour]; + const picks = best && best.picks && best.picks.length ? best.picks : null; + const hourAt = picks ? picks.findIndex((p) => (t.screens[p.screen] || {}).stage === "THORN_WALK") : -1; + const side = hourAt >= 0 && /valley/i.test(picks[hourAt].text) ? "valley" : "tree"; + const viaShadow = picks && picks.some((p) => /shadow/i.test(p.text) && !/descend/i.test(p.text)); + const fits = picks && hourAt >= 0 && side === TREE_SIDE(enc) && (enc.startsWith("shadow-") ? viaShadow : !viaShadow || side === "valley"); + if (!fits) return `

    The DragonKind bot hasn't bonded a ${st.colour} through ${esc(ENC_NAME[enc] || enc)} yet, so it can't confirm these answers. (The community form records only how the encounter ended, not the answers given.)

    `; + const died = (o) => (o.to && o.to.DIED ? o.to.DIED.n : 0); + const rows = picks.slice(hourAt + 1).map((p, i) => { + const sc = t.screens[p.screen] || { options: {} }; + const me = sc.options[p.option] || { n: p.n, to: {} }; + const lived = me.n - died(me); + const others = Object.entries(sc.options).filter(([k]) => k !== p.option).map(([, o]) => + `
  • ${esc(o.text)} ${o.n ? `died ${died(o)} of ${o.n}` : "untested"}
  • `).join(""); + return `
  • ${i + 1}
    ${esc(p.text)} + ${me.n ? `got through ${lived} of ${me.n} times` : ""}${me.kind === "fixed" && me.n ? " · always the same so far" : me.kind === "dice" ? " · a roll" : ""} + ${others ? `
    Other answers here
      ${others}
    ` : ""}
  • `; + }).join(""); + const end = Object.keys((t.screens[picks[picks.length - 1].screen] || { options: {} }).options[picks[picks.length - 1].option]?.to || {}).find((k) => k.startsWith("BONDED")); + return `
    What the DragonKind bot did: the answers that bonded +
      ${rows}
    +

    ${end ? `Bonded a ${end.split(":")[1]}. ` : ""}From the bot's own runs (it logs every screen it sees), so the counts are small; untested answers may also work.

    `; + } + function panelRoutes(routes) { const best = Math.max(1e-12, ...routes.map((r) => r.value.x)); const T = model().targets[st.colour], b = T[st.objective]; @@ -772,7 +858,8 @@ const open = st.expanded === s.var; const opts = open ? `
    ${Object.entries(s.options).sort((a, c) => c[1].pX - a[1].pX).map(([v, val]) => ``).join("")}
    ` : ""; - return `
  • ${opts}
  • `; + const inside = open && s.var === "encounter" ? encounterAnswers(focus.enc) : ""; + return `
  • ${opts}${inside}
  • `; }).join(""); const risks = focus.steps.filter((s) => s.risk && s.risk.p > 0.0005).map((s) => `${s.risk.label.toLowerCase()} ${pct(s.risk.p)}`); const lb = st.policy.samples.lowBias.targets[st.colour].thisAttempt; @@ -926,6 +1013,9 @@ function init() { render(); + // the screen tree (the answers inside each encounter), for the "Bonding encounter" step + fetch("data/tree.json").then((r) => r.json()).then((t) => { st.tree = t; if (st.expanded === "encounter") render(); }).catch(() => { st.tree = { best: {}, screens: {} }; }); + fetch("data/pdf_encounters.json").then((r) => r.json()).then((g) => { st.guide = g; if (st.expanded === "encounter") render(); }).catch(() => {}); fetch("data/policy.json").then((r) => r.json()).then((p) => { st.policy = p; S.useGame(p.samples.all); // the game (and where each colour can be bonded) comes with the route model diff --git a/site/atlas/index.html b/site/atlas/index.html index 0e14c44..5dcab9d 100644 --- a/site/atlas/index.html +++ b/site/atlas/index.html @@ -346,6 +346,20 @@ footer { border-top-color: var(--line); } .ex-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: var(--step--1); color: var(--muted); } .ex-kind { display: inline-flex; align-items: center; gap: 6px; } .ex-kind svg { width: 34px; height: 8px; } +.ex-inside { margin: 10px 0 4px; padding: 10px 12px; border-left: 2px solid var(--c, var(--accent)); background: color-mix(in srgb, var(--bg) 70%, transparent); border-radius: 0 8px 8px 0; } +.ex-inside ol { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 8px; } +.ex-inside ol > li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; } +.ex-inside .n { font-family: var(--font-display); color: var(--muted); text-align: right; } +.ex-inside b { display: block; font-weight: 600; } +.ex-inside small { color: var(--muted); } +.ex-inside details summary { cursor: pointer; font-size: var(--step--1); color: var(--muted); } +.ex-inside ul { margin: 4px 0 0 16px; padding: 0; font-size: var(--step--1); } +.ex-inside + .ex-inside { margin-top: 8px; } +.ex-inside .ex-roll { display: block; font-style: italic; } +.ex-fulltree ul { list-style: disc; } +.ex-fulltree li.best { font-weight: 600; } +.ex-fulltree li.pale { opacity: 0.7; font-style: italic; } +.ex-fulltree li.roll { list-style: none; } .ex-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; } .ex-head svg { width: 64px; height: 52px; } .ex-head h2 { color: var(--c); } diff --git a/site/build.js b/site/build.js index 2518af2..e4d310b 100644 --- a/site/build.js +++ b/site/build.js @@ -27,7 +27,7 @@ for (const f of fs.readdirSync(path.join(root, "site/atlas"))) copy(`site/atlas/ copy("core/graph.js", "graph.js"); copy("core/solver.js", "solver.js"); // The numbers the page shows (all computed in Python) and the published data -for (const f of ["stats.json", "register.json", "graph.json", "policy.json", "black.json", "tree.json", "experiments.json"]) copy(`data/public/${f}`, `data/${f}`); +for (const f of ["stats.json", "register.json", "graph.json", "policy.json", "black.json", "tree.json", "experiments.json", "pdf_encounters.json"]) copy(`data/public/${f}`, `data/${f}`); copy("data/public/runs_clean.csv", "data/runs_clean.csv"); for (const f of ["croissant.json", "dictionary.yaml"]) copy(`data/${f}`, `data/${f}`); // Source files shown in the page's "view the code" panel