Game: which dragons each encounter can give; impossible bonds are not counted
A form row recording a Green bonded at the shadow Blue let the "eventually" objective find a route whose only possible bond was that Green (ratio 1, near-zero chance). game.yaml now lists the possible bonds per encounter (own colour; the two Greens also Orange and Brown); anything else is a data-entry error and is not counted. 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
64fd3af235
commit
8f1f0383fe
+8
-2
@@ -158,6 +158,12 @@ def ctx_key(v, names):
|
||||
|
||||
# ---------------------------------------------------------------- 2. counts
|
||||
|
||||
def can_bond(ctx, colour):
|
||||
"""Whether a bond with this colour is possible at this encounter (game.yaml `encounters`)."""
|
||||
e = G["encounters"][ctx]
|
||||
return colour == "burn" or colour == e["colour"] or colour in (e.get("also") or [])
|
||||
|
||||
|
||||
def count_tables(prepared, weights=None):
|
||||
"""Counts for every chance event at every back-off level, plus each encounter's outcomes. weights: per run,
|
||||
{chance event: weight of the outcome it observed} (reporting-bias corrections, core/atlas/bias.py)."""
|
||||
@@ -187,11 +193,11 @@ def count_tables(prepared, weights=None):
|
||||
if not v.get("encCtx"):
|
||||
continue
|
||||
c = enc.setdefault(v["encCtx"], {"outcomes": {}, "seen": {}})
|
||||
if v.get("encOutcome"):
|
||||
if v.get("encOutcome") and can_bond(v["encCtx"], v["encOutcome"]):
|
||||
c["outcomes"][v["encOutcome"]] = c["outcomes"].get(v["encOutcome"], 0) + 1
|
||||
# which colours can ever end a run in this context (from all runs, genuine or not)
|
||||
for v in prepared:
|
||||
if v.get("encCtx") and v.get("encOutcome") and v["encOutcome"] != "burn":
|
||||
if v.get("encCtx") and v.get("encOutcome") and v["encOutcome"] != "burn" and can_bond(v["encCtx"], v["encOutcome"]):
|
||||
enc[v["encCtx"]]["seen"][v["encOutcome"]] = 1
|
||||
return T
|
||||
|
||||
|
||||
+4
-2
@@ -67,11 +67,13 @@ chance:
|
||||
shadowColour: { label: Shadow dragon, outcomes: [Black, Blue], context: [] }
|
||||
meadow: { label: Meadow dragon, outcomes: [Orange, Brown, Blue], context: [cadet, post, fs, direction, company] }
|
||||
|
||||
# Bonding encounters: where each colour can be bonded. tree-Greens can also end in an Orange or Brown rescue.
|
||||
# Bonding encounters: where each colour can be bonded. A run can only bond the encounter's own colour, except at
|
||||
# the two Greens, where an Orange or a Brown can swoop in (`also`). A recorded bond with any other colour is a
|
||||
# data-entry error and is not counted.
|
||||
encounters:
|
||||
valley-Red: { label: The valley Red, colour: Red }
|
||||
tree-Red: { label: The Red below the tree, colour: Red }
|
||||
tree-Greens: { label: The two Greens, colour: Green }
|
||||
tree-Greens: { label: The two Greens, colour: Green, also: [Orange, Brown] }
|
||||
meadow-Orange: { label: The meadow Orange, colour: Orange }
|
||||
meadow-Brown: { label: The meadow Brown, colour: Brown }
|
||||
meadow-Blue: { label: The meadow Blue, colour: Blue }
|
||||
|
||||
@@ -67,3 +67,16 @@ class Gate(unittest.TestCase):
|
||||
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")
|
||||
|
||||
|
||||
class PossibleBonds(unittest.TestCase):
|
||||
def test_impossible_bond_is_not_counted(self):
|
||||
good = meadow_run("reddit spreadsheet", "Orange")
|
||||
good.update(hour="Tree", branch="Shadow (rare)", outcome="Bonded", outcome_color="Black", enc_Black="Bonded!",
|
||||
enc_Orange=None, goal="Black", scream="Investigate & help", resolution="Killed the bullies yourself",
|
||||
post_path="Forest", combat_first="Assess the situation", combat_second="Engage the smaller cadet")
|
||||
bad = dict(good, enc_Black=None, enc_Blue="Incinerated", outcome_color="Green", goal="Any (for fun)")
|
||||
T = model.count_tables([model.prepare_run(good), model.prepare_run(bad)])
|
||||
self.assertEqual(T["encounter"]["shadow-Black"]["outcomes"], {"Black": 1})
|
||||
self.assertEqual(T["encounter"]["shadow-Blue"]["outcomes"], {}) # a Green at the Blue: not counted
|
||||
self.assertTrue(model.can_bond("tree-Greens", "Brown"))
|
||||
|
||||
Reference in New Issue
Block a user