Pabloler21 commited on
Commit
ecdedb7
·
1 Parent(s): 30b25a4

feat: implement should_recall in memory.py, all tests passing

Browse files
Files changed (1) hide show
  1. memory.py +18 -0
memory.py CHANGED
@@ -29,3 +29,21 @@ def apply_update(state: dict, raw_json: str) -> dict:
29
  if mem not in state["treasure"]:
30
  state["treasure"].append(mem)
31
  return state
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  if mem not in state["treasure"]:
30
  state["treasure"].append(mem)
31
  return state
32
+
33
+
34
+ def should_recall(state: dict) -> tuple[bool, str | None]:
35
+ if state["affinity"] < 51:
36
+ return False, None
37
+
38
+ unclaimed = [m for m in state["treasure"] if m not in state["claimed"]]
39
+ if not unclaimed:
40
+ return False, None
41
+
42
+ last = state.get("last_recall_turn")
43
+ if last is None:
44
+ return True, unclaimed[0]
45
+
46
+ if state["turn"] - last >= 3:
47
+ return True, unclaimed[0]
48
+
49
+ return False, None