Game-rule checks for runs answered through "Report a run"
CI / test (pull_request) Successful in 2m0s
CI / test (pull_request) Successful in 2m0s
Reported and Reddit-comment runs now get the checks the community form gets in core/atlas/coding.py, as data_flags (the run is kept): - first dragon outside the documented pool for the company/direction - a bond or burn by a dragon the encounter does not have (new encounter_colours table in core/spec/form.yaml; Orange/Brown after the two Greens allowed, as a Green's rescue) - a Green on a valley run - a cadet outcome off its scream path, fight answers or a post-fight path on a run that did not help, a second fight move without assessing - died before the hour, yet reached the tree/valley or an encounter planner/policy.yaml drop_flagged: flagged runs of sources read from free text (reddit comment) stay out of the route model; provenance notes do not count as flags. No effect today: the source is not in `sources` yet. On the first 82 scraped runs: 6 flagged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -191,11 +191,63 @@ def answers_row(run_id, source, date, answers, flags=None):
|
||||
row["saw_blue_meadow"] = True
|
||||
if row["outcome"] == "Bonded" and not row["outcome_color"]:
|
||||
flags.append("bonded, colour not given")
|
||||
flags += rule_flags(row)
|
||||
encounter_columns(row)
|
||||
row["data_flags"] = "; ".join(flags)
|
||||
return row
|
||||
|
||||
|
||||
# the scream answer each cadet outcome follows (a run cannot end the encounter on another path)
|
||||
CADET_PATH = {
|
||||
"Killed the bullies yourself": "Investigate & help", "Squadmate's revenge": "Investigate & help",
|
||||
"Left bullies to the dragons": "Investigate & help", "DIED in combat": "Investigate & help",
|
||||
"Tourniquet": "Ignore the scream", "Left injured cadet": "Ignore the scream", "Took their weapons": "Ignore the scream",
|
||||
"Left them to it": "Investigate & leave",
|
||||
}
|
||||
REACHED = ("Tree", "Valley")
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def _form_rules():
|
||||
from atlas import spec as atlas_spec
|
||||
f = atlas_spec.form()
|
||||
return f["sighting_pool"], {k: set(v) for k, v in f["encounter_colours"].items()}
|
||||
|
||||
|
||||
def rule_flags(row):
|
||||
"""The game's own rules, for runs answered through "Report a run": the checks core/atlas/coding.py makes on
|
||||
the community form (first-dragon pools, Greens in the valley) plus the encounter's dragons and the cadet path.
|
||||
Each broken rule is a flag; the run is kept."""
|
||||
pools, enc_colours = _form_rules()
|
||||
flags = []
|
||||
company, direction, first = row["company"], row["direction"], row["first_sighting"]
|
||||
if company in pools and direction in pools[company] and first in COLOURS:
|
||||
pool = list(pools[company][direction]) + (list(pools["Alone"][direction]) if row["left_squadmates"] is True else [])
|
||||
if first not in pool:
|
||||
flags.append(f"first sighting {first} not in documented pool for {company}/{direction}")
|
||||
colour, branch = row["outcome_color"], row["branch"]
|
||||
if row["outcome"] in ("Bonded", "Incinerated") and colour:
|
||||
if branch in enc_colours and colour not in enc_colours[branch]:
|
||||
flags.append(f"{colour} at the {branch} encounter, which has only {'/'.join(sorted(enc_colours[branch]))}")
|
||||
if row["hour"] == "Valley" and colour == "Green":
|
||||
flags.append("Green recorded on a Valley run (no Greens in the valley)")
|
||||
scream, res = row["scream"], row["resolution"]
|
||||
if scream in ("Investigate & help", "Ignore the scream", "Investigate & leave"):
|
||||
if res in CADET_PATH and CADET_PATH[res] != scream:
|
||||
flags.append(f"cadet outcome {res!r} does not follow {scream!r}")
|
||||
if scream != "Investigate & help" and (row["combat_first"] not in (None, "(not recorded)")
|
||||
or row["combat_second"] not in (None, "(not recorded)")):
|
||||
flags.append("fight answers on a run that did not help")
|
||||
if scream != "Investigate & help" and row["post_path"] in ("Forest", "West", "East"):
|
||||
flags.append("a path after the fight on a run without a fight")
|
||||
if row["combat_second"] not in (None, "(not recorded)") and row["combat_first"] != "Assess the situation":
|
||||
flags.append("a second fight move without pausing to assess")
|
||||
died_early = (scream or "").startswith("DIED") or (res or "").startswith("DIED")
|
||||
if died_early and (row["hour"] in REACHED or row["outcome"] in ("Bonded", "Incinerated")):
|
||||
flags.append("died before the hour, yet reached the tree, the valley or a bonding encounter")
|
||||
return flags
|
||||
|
||||
|
||||
def _norm(text):
|
||||
from .transform.bot import normalize
|
||||
return normalize(text)
|
||||
|
||||
Reference in New Issue
Block a user