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
return v
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":
v["help"] = True
v["fight"] = FIGHT_OF.get(r.get("combat_first"))
@@ -129,13 +133,19 @@ def prepare_run(r):
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 = {
"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,
"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,
"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"),
"meadow": lambda v: v.get("meadow"),
}
@@ -389,6 +399,9 @@ class Params:
return self.memo[mk]
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
ck = (node, tuple(state.get(k) for k in CHANCE[node]["context"]))
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("|");
function chance(node, state) {
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;
for (let L = 0; L <= sp.context.length; 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
# 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,
# 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:
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
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 }
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: [] }
meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] }