Game: the shadow is gated on investigating the scream and helping

- game.yaml: chance events can have `requires` (a gate) and `otherwise`; the shadow
  requires "Investigate the scream" and "Help your squadmate" (the route PDF's Black
  Dragon Gates; spreadsheet: 78 shadows in 4199 gated tree runs, 2 in 646 others)
- model and advisor: a closed gate fixes the roll; runs off the gate are not counted
- form.yaml: "Protect / Help Squadmate" (new answer) -> Protect squadmate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
ekcSchiano
2026-11-10 02:33:07 +00:00
co-authored by Claude Opus 5.5
parent 2271fe0976
commit 64fd3af235
5 changed files with 48 additions and 4 deletions
+15 -2
View File
@@ -73,6 +73,10 @@ def prepare_run(r):
v["sightUnknown"] = True # no answer after the first dragon: whether the rider survived it is not known v["sightUnknown"] = True # no answer after the first dragon: whether the rider survived it is not known
return v return v
res = r["resolution"] res = r["resolution"]
# the choices at the scream, by their names in game.yaml (gates are written with these)
v["scream"] = "Keep walking" if r["scream"] == "Ignore the scream" else "Investigate the scream"
if r["scream"] in ("Investigate & help", "Investigate & leave"):
v["clearing"] = "Help your squadmate" if r["scream"] == "Investigate & help" else "Walk away"
if r["scream"] == "Investigate & help": if r["scream"] == "Investigate & help":
v["help"] = True v["help"] = True
v["fight"] = FIGHT_OF.get(r.get("combat_first")) v["fight"] = FIGHT_OF.get(r.get("combat_first"))
@@ -129,13 +133,19 @@ def prepare_run(r):
return v return v
# what each chance event observed in a prepared run def gate_open(node, state):
"""Whether a gated roll (game.yaml `requires`) can come out any other way than `otherwise`."""
req = CHANCE[node].get("requires") or {}
return all(state.get(k) == v for k, v in req.items())
# what each chance event observed in a prepared run (a gated roll only where its gate was open)
OBSERVE = { OBSERVE = {
"fs": lambda v: v.get("fs"), "fs": lambda v: v.get("fs"),
"dieSight": lambda v: ("die" if v.get("diedSight") else "live") if v.get("fs") and not v.get("sightUnknown") else None, "dieSight": lambda v: ("die" if v.get("diedSight") else "live") if v.get("fs") and not v.get("sightUnknown") else None,
"dieCombat": lambda v: ("die" if v.get("diedCombat") else "live") if v.get("help") else None, "dieCombat": lambda v: ("die" if v.get("diedCombat") else "live") if v.get("help") else None,
"dieHour": lambda v: ("die" if v.get("diedHour") else "live") if v.get("survivedCadets") else None, "dieHour": lambda v: ("die" if v.get("diedHour") else "live") if v.get("survivedCadets") else None,
"shadow": lambda v: None if "shadow" not in v else ("yes" if v["shadow"] else "no"), "shadow": lambda v: None if "shadow" not in v or not gate_open("shadow", v) else ("yes" if v["shadow"] else "no"),
"shadowColour": lambda v: v.get("shadowColour"), "shadowColour": lambda v: v.get("shadowColour"),
"meadow": lambda v: v.get("meadow"), "meadow": lambda v: v.get("meadow"),
} }
@@ -389,6 +399,9 @@ class Params:
return self.memo[mk] return self.memo[mk]
def chance(self, node, state): def chance(self, node, state):
if not gate_open(node, state): # a closed gate: the roll always comes out the same way
other = CHANCE[node]["otherwise"]
return {k: np.full(self.D, 1.0 if k == other else 0.0) for k in CHANCE[node]["outcomes"]}
# once every world has been drawn, the answer depends only on the context values: cache it # once every world has been drawn, the answer depends only on the context values: cache it
ck = (node, tuple(state.get(k) for k in CHANCE[node]["context"])) ck = (node, tuple(state.get(k) for k in CHANCE[node]["context"]))
if self.world is None and ck in self._cache: if self.world is None and ck in self._cache:
+2
View File
@@ -55,6 +55,8 @@
const ctxKey = (s, names) => names.map((k) => (s[k] == null ? "?" : s[k])).join("|"); const ctxKey = (s, names) => names.map((k) => (s[k] == null ? "?" : s[k])).join("|");
function chance(node, state) { function chance(node, state) {
const sp = game.chance[node], cats = sp.outcomes; const sp = game.chance[node], cats = sp.outcomes;
// a closed gate (game.yaml `requires`): the roll always comes out as `otherwise`
if (sp.requires && Object.entries(sp.requires).some(([k, v]) => state[k] !== v)) return Object.fromEntries(cats.map((k) => [k, k === sp.otherwise ? 1 : 0]));
let p = null; let p = null;
for (let L = 0; L <= sp.context.length; L++) { for (let L = 0; L <= sp.context.length; L++) {
const names = sp.context.slice(0, L); const names = sp.context.slice(0, L);
+10 -2
View File
@@ -48,14 +48,22 @@ min_support: 20
# ---------------------------------------------------------------- chance events: the game's rolls # ---------------------------------------------------------------- chance events: the game's rolls
# outcomes: in a fixed order. context: the earlier steps the odds may depend on, most important first; the # outcomes: in a fixed order. context: the earlier steps the odds may depend on, most important first; the
# estimate for a full context is shrunk toward the estimate for a shorter one (hierarchical Dirichlet back-off, # estimate for a full context is shrunk toward the estimate for a shorter one (hierarchical Dirichlet back-off,
# strength learned from the data). # strength learned from the data). requires: earlier choices without which the roll always comes out as
# `otherwise` (a gate); runs that did not make them say nothing about the roll and are not counted.
chance: chance:
fs: { label: First dragon, outcomes: [Red, Brown, Green, Orange], context: [direction, company, left] } fs: { label: First dragon, outcomes: [Red, Brown, Green, Orange], context: [direction, company, left] }
# rolls that can kill you: risk_label names the danger when the advisor reports it # rolls that can kill you: risk_label names the danger when the advisor reports it
dieSight: { label: Survive the first dragon, outcomes: [die, live], context: [fs, direction, company, left, react], risk_label: Killed at the first sighting } dieSight: { label: Survive the first dragon, outcomes: [die, live], context: [fs, direction, company, left, react], risk_label: Killed at the first sighting }
dieCombat: { label: Survive the fight, outcomes: [die, live], context: [fight, dagger, fs, direction], risk_label: Killed in the fight } dieCombat: { label: Survive the fight, outcomes: [die, live], context: [fight, dagger, fs, direction], risk_label: Killed in the fight }
dieHour: { label: Survive the hour, outcomes: [die, live], context: [cadet, post], risk_label: Killed before the hour } dieHour: { label: Survive the hour, outcomes: [die, live], context: [cadet, post], risk_label: Killed before the hour }
shadow: { label: Shadow at the tree, outcomes: ["yes", "no"], context: [cadet, post, fs, direction, company] } shadow:
label: Shadow at the tree
outcomes: ["yes", "no"]
context: [cadet, post, fs, direction, company]
# the "Black Dragon Gates" of the community route PDF (November 2026). The runs agree: in the spreadsheet,
# 78 shadows in 4199 tree runs that investigated and helped, 2 (both form submissions) in 646 that did not.
requires: { scream: Investigate the scream, clearing: Help your squadmate }
otherwise: "no"
shadowColour: { label: Shadow dragon, outcomes: [Black, Blue], context: [] } shadowColour: { label: Shadow dragon, outcomes: [Black, Blue], context: [] }
meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] } meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] }
+4
View File
@@ -165,6 +165,10 @@ Current headline, with the bot's runs and the reporting-bias correction (Novembe
attempt (90% range 0–0.15%: the bot and bulk logs have never seen the shadow in about 700 tree runs), Blue about attempt (90% range 0–0.15%: the bot and bulk logs have never seen the shadow in about 700 tree runs), Blue about
1.8–2.5% per attempt (40–55 attempts), depending on the sample. 1.8–2.5% per attempt (40–55 attempts), depending on the sample.
The shadow is gated: it can only appear on runs that investigated the scream and helped the squadmate (the
"Black Dragon Gates" of the community route PDF, and the runs agree). The model knows this
(`core/spec/game.yaml`, `requires`), so it never sends a Black attempt off the gate.
Form submissions over-report rare sightings: riders report a meadow Blue about 4 times more readily than a meadow Form submissions over-report rare sightings: riders report a meadow Blue about 4 times more readily than a meadow
without one. The model estimates that bias for each kind of source and corrects for it (`planner/policy.yaml`, without one. The model estimates that bias for each kind of source and corrects for it (`planner/policy.yaml`,
`reporting_bias`; the estimates are in `policy.json` under `model.reportingBias`). `reporting_bias`; the estimates are in `policy.json` under `model.reportingBias`).
+17
View File
@@ -50,3 +50,20 @@ class Bias(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
class Gate(unittest.TestCase):
def test_closed_gate_fixes_the_roll_and_is_not_counted(self):
spec = model.CHANCE["shadow"]
self.assertTrue(spec.get("requires"))
state = {"scream": "Keep walking"}
self.assertFalse(model.gate_open("shadow", state))
p = model.Params({"shadow": {"0:": {"yes": 5, "no": 5}}}, "mean").chance("shadow", state)
self.assertEqual((float(p["yes"][0]), float(p["no"][0])), (0.0, 1.0))
# a tree run that ignored the scream says nothing about the shadow
run = meadow_run("bot", "Orange")
run.update(hour="Tree", branch="Descend slowly: two Greens", scream="Ignore the scream")
self.assertIsNone(model.OBSERVE["shadow"](model.prepare_run(run)))
run.update(scream="Investigate & help", resolution="Killed the bullies yourself", post_path="Forest",
combat_first="Assess the situation", combat_second="Engage the smaller cadet")
self.assertEqual(model.OBSERVE["shadow"](model.prepare_run(run)), "no")