fix(policy): reconcile session-owned action memory with game observations
This commit is contained in:
parent
3f243eaeee
commit
bf41945ef9
9 changed files with 405 additions and 362 deletions
|
|
@ -53,11 +53,6 @@ def observation(cards: list, *, enemies=None, energy=1, hp=80, block=0) -> dict:
|
|||
}
|
||||
|
||||
|
||||
def reset_policy() -> None:
|
||||
# Each stored observation is independent. These are not ordered trajectories.
|
||||
brain._reset_screen_guards("audit-reset")
|
||||
|
||||
|
||||
def synthetic_probes() -> dict:
|
||||
report = {}
|
||||
obs = observation([card(0)], enemies=[enemy("E0", 6, 0), enemy("E1", 6, 0)])
|
||||
|
|
@ -94,20 +89,19 @@ def synthetic_probes() -> dict:
|
|||
result = {"propagated": True}
|
||||
report["combat_model_error"] = {**result, "diagnostic": output.getvalue().strip()}
|
||||
|
||||
reset_policy()
|
||||
obs = {
|
||||
"state_type": "card_select",
|
||||
"card_select": {"screen_type": "upgrade", "prompt": "Choose a card to Upgrade.",
|
||||
"cards": [card(5)], "can_confirm": False,
|
||||
"can_cancel": True, "preview_showing": False},
|
||||
}
|
||||
first = brain.decide(obs, None)
|
||||
second = brain.decide(obs, None)
|
||||
context = brain.PolicyContext()
|
||||
first = brain.decide(obs, None, context=context)
|
||||
second = brain.decide(obs, None, context=context)
|
||||
report["selection_without_execution"] = {
|
||||
"first": first.action, "second": second.action, "reason": second.reason,
|
||||
"actual_game_actions": 0,
|
||||
}
|
||||
reset_policy()
|
||||
|
||||
try:
|
||||
answer = jev.JevClient._parse({"answers": {"test": {"type": "noul"}}}, 0)["test"]
|
||||
|
|
@ -138,7 +132,6 @@ def corpus_audit() -> dict:
|
|||
raise ValueError("State path leaves dataset directory")
|
||||
obs = json.loads(gzip.decompress(path.read_bytes()))
|
||||
types[obs.get("state_type")] += 1
|
||||
reset_policy()
|
||||
try:
|
||||
decision = brain.decide(obs, None)
|
||||
actions[decision.action if decision else "no_decision"] += 1
|
||||
|
|
@ -162,7 +155,6 @@ def corpus_audit() -> dict:
|
|||
status_in_deck += 1
|
||||
except Exception as exc:
|
||||
exceptions.append({"path": row["path"], "error": f"{type(exc).__name__}: {exc}"})
|
||||
reset_policy()
|
||||
return {
|
||||
"state_types": dict(types), "combat_phases": dict(phases), "actions": dict(actions),
|
||||
"exceptions": exceptions, "forced_block_when_covered": covered,
|
||||
|
|
@ -171,7 +163,6 @@ def corpus_audit() -> dict:
|
|||
|
||||
|
||||
def main() -> int:
|
||||
reset_policy()
|
||||
report = {"synthetic": synthetic_probes(), "corpus": corpus_audit()}
|
||||
print(json.dumps(report, indent=2, sort_keys=True))
|
||||
# Successful audit execution is not a clean bill of health. Read the report.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue