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
+17
View File
@@ -50,3 +50,20 @@ class Bias(unittest.TestCase):
if __name__ == "__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")