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:
co-authored by
Claude Opus 5.5
parent
2271fe0976
commit
64fd3af235
+15
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user