From bad6a5f9bcdc0104d053e71ea59eddb14b204b28 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 28 May 2024 03:56:30 +0800 Subject: [PATCH] Add: Predict is_approaching_total with combat_wave_done --- tasks/combat/combat.py | 2 +- tasks/combat/obtain.py | 8 ++++---- tasks/planner/model.py | 21 +++++++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tasks/combat/combat.py b/tasks/combat/combat.py index a89f52f1d..019d113ff 100644 --- a/tasks/combat/combat.py +++ b/tasks/combat/combat.py @@ -125,7 +125,7 @@ class Combat(CombatInteract, CombatPrepare, CombatState, CombatTeam, CombatSuppo self.interval_reset(COMBAT_PREPARE) self.map_A_timer.reset() if self.appear(COMBAT_PREPARE, interval=2): - if self.obtained_is_full(self.dungeon): + if self.obtained_is_full(self.dungeon, wave_done=self.combat_wave_done): # Update stamina so task can be delayed if both obtained_is_full and stamina exhausted self.combat_get_trailblaze_power() return False diff --git a/tasks/combat/obtain.py b/tasks/combat/obtain.py index ed58c6132..e144c31e3 100644 --- a/tasks/combat/obtain.py +++ b/tasks/combat/obtain.py @@ -246,7 +246,7 @@ class CombatObtain(PlannerMixin): self.planner_write() return items - def obtained_is_full(self, dungeon: DungeonList | None) -> bool: + def obtained_is_full(self, dungeon: DungeonList | None, wave_done=0) -> bool: if dungeon is None: self.obtain_frequent_check = False return False @@ -270,9 +270,9 @@ class CombatObtain(PlannerMixin): return True # obtain_frequent_check - # approaching = row.is_approaching_total() - # logger.attr('is_approaching_total', approaching) - # self.obtain_frequent_check = approaching + approaching = row.is_approaching_total(wave_done) + logger.attr('is_approaching_total', approaching) + self.obtain_frequent_check = approaching return False def _find_may_obtain(self, skip_first_screenshot=True): diff --git a/tasks/planner/model.py b/tasks/planner/model.py index 750c5eb7f..355513af6 100644 --- a/tasks/planner/model.py +++ b/tasks/planner/model.py @@ -147,32 +147,37 @@ class StoredPlannerProxy(BaseModelWithFallback): else: self.value.blue += self.synthesize.purple * 3 - def is_approaching_total(self): + def is_approaching_total(self, wave_done: int = 0): """ + Args: + wave_done: + Returns: bool: True if the future value may >= total after next combat """ + wave_done = max(wave_done, 0) + # Items with a static drop rate will have `AVG * (wave_done + 1) if self.item.dungeon.is_Calyx_Golden_Treasures: - return self.value + 24000 >= self.total + return self.value + 24000 * (wave_done + 12) >= self.total if self.item.dungeon.is_Calyx_Golden_Memories: # purple, blue, green = 5, 1, 0 value = self.value.equivalent_green() total = self.total.equivalent_green() - return value + 48 >= total - if self.item.dungeon.Calyx_Golden_Aether: + return value + 48 * (wave_done + 12) >= total + if self.item.dungeon.is_Calyx_Golden_Aether: # purple, blue, green = 1, 2, 2.5 value = self.value.equivalent_green() total = self.total.equivalent_green() - return value + 17.5 >= total + return value + 17.5 * (wave_done + 12) >= total if self.item.is_ItemAscension: - return self.value + 3 >= self.total + return self.value + 3 * (wave_done + 1) >= self.total if self.item.is_ItemTrace: # purple, blue, green = 0.155, 1, 1.25 value = self.value.equivalent_green() total = self.total.equivalent_green() - return value + 33.87 >= total + return value + 5.645 * (wave_done + 12) >= total if self.item.is_ItemWeekly: - return self.value + 3 >= self.total + return self.value + 3 * (wave_done + 1) >= self.total return False def update_progress(self):