From 5b1814b5c2cb6a0605f9a52a89565d4683b39c7f Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sat, 4 Nov 2023 10:07:08 +0800 Subject: [PATCH 01/19] =?UTF-8?q?UI=E6=9C=80=E5=A4=A7=E7=BB=84=E4=BA=BA?= =?UTF-8?q?=E6=95=B0=E6=94=B9=E7=94=A8=E6=95=B0=E5=AD=97=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/pages/Plan.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/pages/Plan.vue b/ui/src/pages/Plan.vue index f479ae1a7..a72fab47b 100644 --- a/ui/src/pages/Plan.vue +++ b/ui/src/pages/Plan.vue @@ -108,10 +108,10 @@ async function save() { - 最大组人数
请查阅文档
+ 最大组人数
请查阅文档
- + From bcaa3444d768508d74777a85fc946417b5469850 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sat, 4 Nov 2023 19:05:54 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=8B=BC=E5=86=99=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_schedule.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 14f218093..f4b4e37b3 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -1582,7 +1582,7 @@ def switch_arrange_order(self, index: int, asc="false") -> None: self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) - def scan_agant(self, agent: list[str], error_count=0, max_agent_count=-1): + def scan_agent(self, agent: list[str], error_count=0, max_agent_count=-1): try: # 识别干员 self.recog.update() @@ -1606,7 +1606,7 @@ def scan_agant(self, agent: list[str], error_count=0, max_agent_count=-1): if error_count < 3: logger.exception(e) self.sleep(3) - return self.scan_agant(agent, error_count, max_agent_count) + return self.scan_agent(agent, error_count, max_agent_count) else: raise e @@ -1696,7 +1696,7 @@ def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: pre_order = [3, 'true'] if not fast_mode: self.tap((self.recog.w * 0.38, self.recog.h * 0.95), interval=0.5) - changed, ret = self.scan_agant(agent) + changed, ret = self.scan_agent(agent) if changed: selected.extend(changed) if len(agent) == 0: break @@ -1719,7 +1719,7 @@ def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: pre_order = arrange_type first_time = False - changed, ret = self.scan_agant(agent) + changed, ret = self.scan_agent(agent) if changed: selected.extend(changed) # 如果找到了 @@ -1754,7 +1754,7 @@ def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: free_list.extend([_name for _name in agent_list if _name not in self.op_data.operators.keys()]) free_list = list(set(free_list) - set(self.op_data.config.free_blacklist)) while free_num: - selected_name, ret = self.scan_agant(free_list, max_agent_count=free_num) + selected_name, ret = self.scan_agent(free_list, max_agent_count=free_num) selected.extend(selected_name) free_num -= len(selected_name) while len(selected_name) > 0: From e61fbdc0643267a6c4820539b9069c3f363856b2 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 10:01:14 +0800 Subject: [PATCH 03/19] =?UTF-8?q?Maa=20Python=E6=A8=A1=E5=9D=97=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=A4=B1=E8=B4=A5=E6=97=B6=E6=98=BE=E7=A4=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_schedule.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 7a4229ec5..2e2dac4c6 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -2224,9 +2224,14 @@ def initialize_maa(self): if asst_path not in sys.path: sys.path.append(asst_path) global Message - from asst.asst import Asst - from asst.utils import Message, Version, InstanceOptionType - from asst.updater import Updater + + try: + from asst.asst import Asst + from asst.utils import Message, InstanceOptionType + logger.info("Maa Python模块导入成功") + except Exception as e: + logger.error(f'Maa Python模块导入失败:{str(e)}') + raise Exception("Maa Python模块导入失败") try: logger.debug(f'开始更新Maa活动关卡导航……') @@ -2236,7 +2241,7 @@ def initialize_maa(self): with open(ota_tasks_path, 'w', encoding='utf-8') as f: with urllib.request.urlopen(ota_tasks_url) as u: f.write(u.read().decode('utf-8')) - logger.info(f'Maa活动关卡导航更新成功!') + logger.info(f'Maa活动关卡导航更新成功') except Exception as e: logger.error(f'Maa活动关卡导航更新失败:{str(e)}') From c5a5bb62241d5b6b3d18300ebce5cf44bd8aa9ce Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 10:24:50 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E2=80=9C=E9=82=AE=E4=BB=B6=E2=80=9D?= =?UTF-8?q?=E6=94=B9=E5=90=8D=E2=80=9C=E9=A2=86=E5=8F=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/mail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/solvers/mail.py b/arknights_mower/solvers/mail.py index 1cf817030..5a1999807 100644 --- a/arknights_mower/solvers/mail.py +++ b/arknights_mower/solvers/mail.py @@ -16,7 +16,7 @@ def run(self) -> None: # if it touched self.touched = False - logger.info('Start: 邮件') + logger.info('Start: 领取邮件') super().run() def transition(self) -> bool: From d40c12f678bbe6a77cce8ee855df5784a4e707a7 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 10:25:03 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E6=8F=90=E9=AB=98=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E4=B8=AD=E6=A3=80=E6=B5=8B=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/utils/recognize.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arknights_mower/utils/recognize.py b/arknights_mower/utils/recognize.py index 1721938a1..fe10999ab 100644 --- a/arknights_mower/utils/recognize.py +++ b/arknights_mower/utils/recognize.py @@ -64,7 +64,7 @@ def get_scene(self) -> int: """ get the current scene in the game """ if self.scene != Scene.UNDEFINED: return self.scene - if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.1) is not None: + if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.15) is not None: self.scene = Scene.CONNECTING elif self.find('index_nav', thres=250, scope=((0, 0), (100+self.w//4, self.h//10))) is not None: self.scene = Scene.INDEX @@ -244,7 +244,7 @@ def get_scene(self) -> int: def get_infra_scene(self)-> int: if self.scene != Scene.UNDEFINED: return self.scene - if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.1) is not None: + if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.15) is not None: self.scene = Scene.CONNECTING elif self.find('double_confirm') is not None: if self.find('network_check') is not None: From ce447f1dbb41cba28172ba6f6cbc6f57274dc0fc Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 10:26:56 +0800 Subject: [PATCH 06/19] =?UTF-8?q?Maa=E5=AF=BC=E8=88=AA=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E9=81=BF=E5=85=8D=E7=A0=B4=E5=9D=8F?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=B8=AD=E7=9A=84tasks.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_schedule.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index d03b51d2e..92f908ab2 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -2238,9 +2238,10 @@ def initialize_maa(self): ota_tasks_url = 'https://ota.maa.plus/MaaAssistantArknights/api/resource/tasks.json' ota_tasks_path = path / 'cache' / 'resource' / 'tasks.json' ota_tasks_path.parent.mkdir(parents=True, exist_ok=True) + with urllib.request.urlopen(ota_tasks_url) as u: + res = u.read().decode('utf-8') with open(ota_tasks_path, 'w', encoding='utf-8') as f: - with urllib.request.urlopen(ota_tasks_url) as u: - f.write(u.read().decode('utf-8')) + f.write(res) logger.info(f'Maa活动关卡导航更新成功') except Exception as e: logger.error(f'Maa活动关卡导航更新失败:{str(e)}') From 9fcfe8d47ecd2050f422a613b21157d6d04035f6 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 10:36:59 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E5=8F=91=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/__init__.py b/arknights_mower/__init__.py index 1e73d26da..577b3c93d 100644 --- a/arknights_mower/__init__.py +++ b/arknights_mower/__init__.py @@ -15,4 +15,4 @@ __cli__ = not (__pyinstall__ and not sys.argv[1:]) __system__ = platform.system().lower() -__version__ = 'v3.5.0-alpha-17' +__version__ = 'v3.5.0-alpha-18' From 61c9375da8c667e37f1d8bda9b74f3c61434faf5 Mon Sep 17 00:00:00 2001 From: Shawnsdaddy Date: Sat, 4 Nov 2023 23:00:42 -0700 Subject: [PATCH 08/19] =?UTF-8?q?diy=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/utils/paddleocr.py | 21 --------------------- diy.py | 13 +++++-------- 2 files changed, 5 insertions(+), 29 deletions(-) delete mode 100644 arknights_mower/utils/paddleocr.py diff --git a/arknights_mower/utils/paddleocr.py b/arknights_mower/utils/paddleocr.py deleted file mode 100644 index c129e21a5..000000000 --- a/arknights_mower/utils/paddleocr.py +++ /dev/null @@ -1,21 +0,0 @@ -from .path import get_path - -ocr = None - -def initialize_ocr(): - global ocr - if not ocr: - from paddleocr import PaddleOCR - - det_model_dir = get_path("@app/tmp/paddle/det/ch", space='') - rec_model_dir = get_path("@app/tmp/paddle/rec/ch", space='') - cls_model_dir = get_path("@app/tmp/paddle/cls", space='') - ocr = PaddleOCR( - enable_mkldnn=False, - use_angle_cls=False, - cls=False, - show_log=False, - det_model_dir=str(det_model_dir), - rec_model_dir=str(rec_model_dir), - cls_model_dir=str(cls_model_dir), - ) diff --git a/diy.py b/diy.py index 659be14ac..9277f566e 100644 --- a/diy.py +++ b/diy.py @@ -3,18 +3,15 @@ import atexit import json import os - from arknights_mower.solvers.base_schedule import BaseSchedulerSolver from arknights_mower.strategy import Solver from arknights_mower.utils.device import Device from arknights_mower.utils.email import task_template from arknights_mower.utils.log import logger, init_fhlr -from arknights_mower.utils import config -from arknights_mower.utils.logic_expression import LogicExpression +from arknights_mower.utils import config, rapidocr from arknights_mower.utils.simulator import restart_simulator from arknights_mower.utils.plan import Plan, PlanConfig, Room -import arknights_mower.utils.paddleocr - +from arknights_mower.utils.logic_expression import LogicExpression # 下面不能删除 from arknights_mower.utils.operators import Operators, Operator, Dormitory from arknights_mower.utils.scheduler_task import SchedulerTask,TaskTypes @@ -380,7 +377,7 @@ def simulate(): continue base_scheduler.run() reconnect_tries = 0 - except ConnectionError or ConnectionAbortedError or AttributeError as e: + except (ConnectionError, ConnectionAbortedError, AttributeError) as e: reconnect_tries += 1 if reconnect_tries < reconnect_max_tries: logger.warning(f'连接端口断开....正在重连....') @@ -389,7 +386,7 @@ def simulate(): try: base_scheduler = inialize([], base_scheduler) break - except RuntimeError or ConnectionError or ConnectionAbortedError as ce: + except (ConnectionError, ConnectionAbortedError, AttributeError) as ce: logger.error(ce) restart_simulator(simulator) continue @@ -411,5 +408,5 @@ def simulate(): # debuglog() atexit.register(save_state) savelog() -arknights_mower.utils.paddleocr.initialize_ocr() +rapidocr.initialize_ocr() simulate() From c760e48cb42dfe33781951758f94c9a5952d0f72 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 5 Nov 2023 16:43:51 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E5=8F=91=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/__init__.py b/arknights_mower/__init__.py index 577b3c93d..57ebfc94a 100644 --- a/arknights_mower/__init__.py +++ b/arknights_mower/__init__.py @@ -15,4 +15,4 @@ __cli__ = not (__pyinstall__ and not sys.argv[1:]) __system__ = platform.system().lower() -__version__ = 'v3.5.0-alpha-18' +__version__ = 'v3.5.0-alpha-19' From fc3bc3f196713bd1e63f71ce7d27667d95ceb981 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 10:25:13 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E5=A4=8D=E6=B4=BBbase=5Fconstruct.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 326 +++++++++++----------- 1 file changed, 168 insertions(+), 158 deletions(-) diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index 2a3b2e151..6dbd1ebc3 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -13,6 +13,9 @@ from ..utils.solver import BaseSolver +import copy + + class ArrangeOrder(Enum): STATUS = 1 SKILL = 2 @@ -20,10 +23,10 @@ class ArrangeOrder(Enum): TRUST = 4 arrange_order_res = { - ArrangeOrder.STATUS: ('arrange_status', 0.1), - ArrangeOrder.SKILL: ('arrange_skill', 0.35), - ArrangeOrder.FEELING: ('arrange_feeling', 0.65), - ArrangeOrder.TRUST: ('arrange_trust', 0.9), + ArrangeOrder.STATUS: (1560 / 2496, 96 / 1404), + ArrangeOrder.SKILL: (1720 / 2496, 96 / 1404), + ArrangeOrder.FEELING: (1880 / 2496, 96 / 1404), + ArrangeOrder.TRUST: (2050 / 2496, 96 / 1404), } @@ -404,171 +407,178 @@ def drone(self, room: str): self.back(interval=2, rebuild=False) self.back(interval=2) - def get_arrange_order(self) -> ArrangeOrder: - best_score, best_order = 0, None - for order in ArrangeOrder: - score = self.recog.score(arrange_order_res[order][0]) - if score is not None and score[0] > best_score: - best_score, best_order = score[0], order - # if best_score < 0.6: - # raise RecognizeError - logger.debug((best_score, best_order)) - return best_order - - def switch_arrange_order(self, order: ArrangeOrder) -> None: - self.tap_element(arrange_order_res[order][0], x_rate=arrange_order_res[order][1], judge=False) - - def arrange_order(self, order: ArrangeOrder) -> None: - if self.get_arrange_order() != order: - self.switch_arrange_order(order) - - def choose_agent(self, agent: list[str], skip_free: int = 0, order: ArrangeOrder = None) -> None: - """ - :param order: ArrangeOrder, 选择干员时右上角的排序功能 - """ - logger.info(f'安排干员:{agent}') - logger.debug(f'skip_free: {skip_free}') - h, w = self.recog.h, self.recog.w - first_time = True - - # 在 agent 中 'Free' 表示任意空闲干员 - free_num = agent.count('Free') - agent = set(agent) - set(['Free']) - - # 安排指定干员 - if len(agent): - if not first_time: - # 滑动到最左边 - self.sleep(interval=0.5, rebuild=False) - for _ in range(9): - self.swipe_only((w//2, h//2), (w//2, 0), interval=0.5) - self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False) + def switch_arrange_order(self, index: int, asc="false") -> None: + self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) + # 点个不需要的 + if index < 4: + self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index + 1)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) + else: + self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index - 1)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) + # 切回来 + self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) + # 倒序 + if asc != "false": + self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) + + + def scan_agent(self, agent: list[str], error_count=0, max_agent_count=-1): + try: + # 识别干员 + self.recog.update() + ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下 + # 提取识别出来的干员的名字 + select_name = [] + for y in ret: + name = y[0] + if name in agent: + select_name.append(name) + # self.get_agent_detail((y[1][0])) + self.tap((y[1][0]), interval=0) + agent.remove(name) + # 如果是按照个数选择 Free + if max_agent_count != -1: + if len(select_name) >= max_agent_count: + return select_name, ret + return select_name, ret + except Exception as e: + error_count += 1 + if error_count < 3: + logger.exception(e) + self.sleep(3) + return self.scan_agent(agent, error_count, max_agent_count) else: - # 第一次进入按技能排序 - if order is not None: - self.arrange_order(order) - first_time = False + raise e - checked = set() # 已经识别过的干员 - pre = set() # 上次识别出的干员 - error_count = 0 - - while len(agent): - try: - # 识别干员 - ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下 - except RecognizeError as e: - error_count += 1 - if error_count < 3: - logger.debug(e) - self.sleep(3) - else: - raise e - continue - # 提取识别出来的干员的名字 - agent_name = set([x[0] for x in ret]) - if agent_name == pre: - error_count += 1 - if error_count >= 3: - logger.warning(f'未找到干员:{list(agent)}') - break - else: - pre = agent_name - - # 更新已经识别过的干员 - checked |= agent_name - - # 如果出现了需要的干员则选择 - # 优先安排菲亚梅塔 - if '菲亚梅塔' in agent: - if '菲亚梅塔' in agent_name: - for y in ret: - if y[0] == '菲亚梅塔': - self.tap((y[1][0]), interval=0, rebuild=False) - break - agent.remove('菲亚梅塔') + def swipe_left(self, right_swipe, w, h): + for _ in range(right_swipe): + self.swipe_only((w // 2, h // 2), (w // 2, 0), interval=0.5) + return 0 - # 如果菲亚梅塔是 the only one - if len(agent) == 0: - break - # 否则滑动到最左边 - self.sleep(interval=0.5, rebuild=False) - for _ in range(9): - self.swipe_only((w//2, h//2), (w//2, 0), interval=0.5) - self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False) - - # reset the statuses and cancel the rightward-swiping - checked = set() - pre = set() - error_count = 0 - continue - else: - for y in ret: - name = y[0] - if name in agent_name & agent: - self.tap((y[1][0]), interval=0, rebuild=False) - agent.remove(name) - # for name in agent_name & agent: - # for y in ret: - # if y[0] == name: - # self.tap((y[1][0]), interval=0, rebuild=False) - # break - # agent.remove(name) - - # 如果已经完成选择则退出 - if len(agent) == 0: - break - - st = ret[-2][1][2] # 起点 - ed = ret[0][1][1] # 终点 - self.swipe_noinertia(st, (ed[0]-st[0], 0)) + def get_order(self, name): + return False, [2, "false"] - # 安排空闲干员 - if free_num: - if not first_time: - # 滑动到最左边 - self.sleep(interval=0.5, rebuild=False) - for _ in range(9): - self.swipe_only((w//2, h//2), (w//2, 0), interval=0.5) - self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False) - else: - # 第一次进入按技能排序 - if order is not None: - self.arrange_order(order) - first_time = False + def detail_filter(self, turn_on, type="not_in_dorm"): + logger.info(f'开始 {("打开" if turn_on else "关闭")} {type} 筛选') + self.tap((self.recog.w * 0.95, self.recog.h * 0.05), interval=1) + if type == "not_in_dorm": + not_in_dorm = self.find('arrange_non_check_in', score=0.9) + if turn_on ^ (not_in_dorm is None): + self.tap((self.recog.w * 0.3, self.recog.h * 0.5), interval=0.5) + # 确认 + self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) - error_count = 0 - - while free_num: - try: - # 识别空闲干员 - ret, st, ed = segment.free_agent(self.recog.img) # 返回的顺序是从左往右从上往下 - except RecognizeError as e: - error_count += 1 - if error_count < 3: - logger.debug(e) - self.sleep(3) - else: - raise e - continue - while free_num and len(ret): - if skip_free > 0: - skip_free -= 1 - else: - self.tap(ret[0], interval=0, rebuild=False) - free_num -= 1 - ret = ret[1:] + def choose_agent(self, agents: list[str], room: str) -> None: + """ + :param order: ArrangeOrder, 选择干员时右上角的排序功能 + """ + first_name = '' + max_swipe = 50 + position = [(0.35, 0.35), (0.35, 0.75), (0.45, 0.35), (0.45, 0.75), (0.55, 0.35)] + for idx, n in enumerate(agents): + if n == '': + agents[idx] = 'Free' + agent = copy.deepcopy(agents) + exists = [] + logger.info(f'安排干员 :{agent}') + # 若不是空房间,则清空工作中的干员 + is_dorm = room.startswith("dorm") + h, w = self.recog.h, self.recog.w + first_time = True + # 在 agent 中 'Free' 表示任意空闲干员 + free_num = agent.count('Free') + for i in range(agent.count("Free")): + agent.remove("Free") + index_change = False + pre_order = [2, False] + right_swipe = 0 + retry_count = 0 + # 如果重复进入宿舍则需要排序 + selected = [] + logger.info(f'上次进入房间为:{self.last_room},本次房间为:{room}') + if self.last_room.startswith('dorm') and is_dorm: + self.detail_filter(False) + while len(agent) > 0: + if retry_count > 1: raise Exception(f"到达最大尝试次数 1次") + if right_swipe > max_swipe: + # 到底了则返回再来一次 + for _ in range(right_swipe): + self.swipe_only((w // 2, h // 2), (w // 2, 0), interval=0.5) + right_swipe = 0 + max_swipe = 50 + retry_count += 1 + self.detail_filter(False) + if first_time: + # 清空 + if is_dorm: + self.switch_arrange_order(3, "true") + pre_order = [3, 'true'] + self.tap((self.recog.w * 0.38, self.recog.h * 0.95), interval=0.5) + changed, ret = self.scan_agent(agent) + if changed: + selected.extend(changed) + if len(agent) == 0: break + index_change = True + + # 如果选中了人,则可能需要重新排序 + if index_change or first_time: + # 第一次则调整 + is_custom, arrange_type = self.get_order(agent[0]) + arrange_type = (3, 'true') + # 如果重新排序则滑到最左边 + if pre_order[0] != arrange_type[0] or pre_order[1] != arrange_type[1]: + self.switch_arrange_order(arrange_type[0], arrange_type[1]) + # 滑倒最左边 + self.sleep(interval=0.5, rebuild=True) + right_swipe = self.swipe_left(right_swipe, w, h) + pre_order = arrange_type + first_time = False - # 如果已经完成选择则退出 - if free_num == 0: - break + changed, ret = self.scan_agent(agent) + if changed: + selected.extend(changed) + # 如果找到了 + index_change = True + else: + # 如果没找到 而且右移次数大于5 + if ret[0][0] == first_name and right_swipe > 5: + max_swipe = right_swipe + else: + first_name = ret[0][0] + index_change = False + st = ret[-2][1][2] # 起点 + ed = ret[0][1][1] # 终点 + self.swipe_noinertia(st, (ed[0] - st[0], 0)) + right_swipe += 1 + if len(agent) == 0: break; + # 排序 + if len(agents) != 1: + # 左移 + self.swipe_left(right_swipe, w, h) + self.tap((self.recog.w * arrange_order_res[ArrangeOrder.SKILL][0], + self.recog.h * arrange_order_res[ArrangeOrder.SKILL][1]), interval=0.5, rebuild=False) + not_match = False + exists.extend(selected) + for idx, item in enumerate(agents): + if agents[idx] != exists[idx] or not_match: + not_match = True + p_idx = exists.index(agents[idx]) + self.tap((self.recog.w * position[p_idx][0], self.recog.h * position[p_idx][1]), interval=0, + rebuild=False) + self.tap((self.recog.w * position[p_idx][0], self.recog.h * position[p_idx][1]), interval=0, + rebuild=False) + self.last_room = room + logger.info(f"设置上次房间为{self.last_room}") - self.swipe_noinertia(st, (ed[0]-st[0], 0)) def agent_arrange(self, plan: tp.BasePlan) -> None: """ 基建排班 """ @@ -621,7 +631,7 @@ def agent_arrange(self, plan: tp.BasePlan) -> None: else: default_order = ArrangeOrder.SKILL self.choose_agent( - plan[base_room_list[idx]], skip_free, default_order) + plan[base_room_list[idx]], base_room_list[idx]) except RecognizeError as e: error_count += 1 if error_count >= 3: From 89fad04c006e05dc3b61f6323ec80956a0ba4843 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 11:41:16 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E5=B0=86=E5=9F=BA=E5=BB=BA=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E4=BB=A3=E7=A0=81=E6=8F=90=E5=8F=96=E5=88=B0Mixin?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 84 +--------------- arknights_mower/solvers/base_mixin.py | 113 ++++++++++++++++++++++ arknights_mower/solvers/base_schedule.py | 79 +-------------- 3 files changed, 118 insertions(+), 158 deletions(-) create mode 100644 arknights_mower/solvers/base_mixin.py diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index 6dbd1ebc3..31cd9bb94 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -1,7 +1,5 @@ from __future__ import annotations -from enum import Enum - import numpy as np from ..data import base_room_list @@ -15,22 +13,10 @@ import copy +from arknights_mower.solvers.base_mixin import ArrangeOrder, arrange_order_res, BaseMixin -class ArrangeOrder(Enum): - STATUS = 1 - SKILL = 2 - FEELING = 3 - TRUST = 4 - -arrange_order_res = { - ArrangeOrder.STATUS: (1560 / 2496, 96 / 1404), - ArrangeOrder.SKILL: (1720 / 2496, 96 / 1404), - ArrangeOrder.FEELING: (1880 / 2496, 96 / 1404), - ArrangeOrder.TRUST: (2050 / 2496, 96 / 1404), -} - -class BaseConstructSolver(BaseSolver): +class BaseConstructSolver(BaseSolver, BaseMixin): """ 收集基建的产物:物资、赤金、信赖 """ @@ -45,6 +31,7 @@ def run(self, arrange: dict[str, tp.BasePlan] = None, clue_collect: bool = False :param drone_room: str, 是否使用无人机加速 :param fia_room: str, 是否使用菲亚梅塔恢复心情 """ + self.last_room = "" self.arrange = arrange self.clue_collect = clue_collect self.drone_room = drone_room @@ -408,75 +395,10 @@ def drone(self, room: str): self.back(interval=2) - def switch_arrange_order(self, index: int, asc="false") -> None: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - # 点个不需要的 - if index < 4: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index + 1)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - else: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index - 1)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - # 切回来 - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) - # 倒序 - if asc != "false": - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) - - - def scan_agent(self, agent: list[str], error_count=0, max_agent_count=-1): - try: - # 识别干员 - self.recog.update() - ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下 - # 提取识别出来的干员的名字 - select_name = [] - for y in ret: - name = y[0] - if name in agent: - select_name.append(name) - # self.get_agent_detail((y[1][0])) - self.tap((y[1][0]), interval=0) - agent.remove(name) - # 如果是按照个数选择 Free - if max_agent_count != -1: - if len(select_name) >= max_agent_count: - return select_name, ret - return select_name, ret - except Exception as e: - error_count += 1 - if error_count < 3: - logger.exception(e) - self.sleep(3) - return self.scan_agent(agent, error_count, max_agent_count) - else: - raise e - - - def swipe_left(self, right_swipe, w, h): - for _ in range(right_swipe): - self.swipe_only((w // 2, h // 2), (w // 2, 0), interval=0.5) - return 0 - - def get_order(self, name): return False, [2, "false"] - def detail_filter(self, turn_on, type="not_in_dorm"): - logger.info(f'开始 {("打开" if turn_on else "关闭")} {type} 筛选') - self.tap((self.recog.w * 0.95, self.recog.h * 0.05), interval=1) - if type == "not_in_dorm": - not_in_dorm = self.find('arrange_non_check_in', score=0.9) - if turn_on ^ (not_in_dorm is None): - self.tap((self.recog.w * 0.3, self.recog.h * 0.5), interval=0.5) - # 确认 - self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) - - def choose_agent(self, agents: list[str], room: str) -> None: """ :param order: ArrangeOrder, 选择干员时右上角的排序功能 diff --git a/arknights_mower/solvers/base_mixin.py b/arknights_mower/solvers/base_mixin.py new file mode 100644 index 000000000..47a401bbf --- /dev/null +++ b/arknights_mower/solvers/base_mixin.py @@ -0,0 +1,113 @@ +from __future__ import annotations + +from enum import Enum +from arknights_mower.utils import character_recognize +from arknights_mower.utils.log import logger + + +class ArrangeOrder(Enum): + STATUS = 1 + SKILL = 2 + FEELING = 3 + TRUST = 4 + + +arrange_order_res = { + ArrangeOrder.STATUS: (1560 / 2496, 96 / 1404), + ArrangeOrder.SKILL: (1720 / 2496, 96 / 1404), + ArrangeOrder.FEELING: (1880 / 2496, 96 / 1404), + ArrangeOrder.TRUST: (2050 / 2496, 96 / 1404), +} + + +class BaseMixin: + def switch_arrange_order(self, index: int, asc="false") -> None: + self.tap( + ( + self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1], + ), + interval=0, + rebuild=False, + ) + # 点个不需要的 + if index < 4: + self.tap( + ( + self.recog.w * arrange_order_res[ArrangeOrder(index + 1)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1], + ), + interval=0, + rebuild=False, + ) + else: + self.tap( + ( + self.recog.w * arrange_order_res[ArrangeOrder(index - 1)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1], + ), + interval=0, + rebuild=False, + ) + # 切回来 + self.tap( + ( + self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1], + ), + interval=0.2, + rebuild=True, + ) + # 倒序 + if asc != "false": + self.tap( + ( + self.recog.w * arrange_order_res[ArrangeOrder(index)][0], + self.recog.h * arrange_order_res[ArrangeOrder(index)][1], + ), + interval=0.2, + rebuild=True, + ) + + def scan_agent(self, agent: list[str], error_count=0, max_agent_count=-1): + try: + # 识别干员 + self.recog.update() + ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下 + # 提取识别出来的干员的名字 + select_name = [] + for y in ret: + name = y[0] + if name in agent: + select_name.append(name) + # self.get_agent_detail((y[1][0])) + self.tap((y[1][0]), interval=0) + agent.remove(name) + # 如果是按照个数选择 Free + if max_agent_count != -1: + if len(select_name) >= max_agent_count: + return select_name, ret + return select_name, ret + except Exception as e: + error_count += 1 + if error_count < 3: + logger.exception(e) + self.sleep(3) + return self.scan_agent(agent, error_count, max_agent_count) + else: + raise e + + def swipe_left(self, right_swipe, w, h): + for _ in range(right_swipe): + self.swipe_only((w // 2, h // 2), (w // 2, 0), interval=0.5) + return 0 + + def detail_filter(self, turn_on, type="not_in_dorm"): + logger.info(f'开始 {("打开" if turn_on else "关闭")} {type} 筛选') + self.tap((self.recog.w * 0.95, self.recog.h * 0.05), interval=1) + if type == "not_in_dorm": + not_in_dorm = self.find("arrange_non_check_in", score=0.9) + if turn_on ^ (not_in_dorm is None): + self.tap((self.recog.w * 0.3, self.recog.h * 0.5), interval=0.5) + # 确认 + self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 92f908ab2..81cef14df 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -6,7 +6,6 @@ import sys import pathlib import urllib.request -from enum import Enum from datetime import datetime, timedelta import numpy as np import smtplib @@ -43,26 +42,13 @@ from arknights_mower.utils.email import maa_template - -class ArrangeOrder(Enum): - STATUS = 1 - SKILL = 2 - FEELING = 3 - TRUST = 4 - - -arrange_order_res = { - ArrangeOrder.STATUS: (1560 / 2496, 96 / 1404), - ArrangeOrder.SKILL: (1720 / 2496, 96 / 1404), - ArrangeOrder.FEELING: (1880 / 2496, 96 / 1404), - ArrangeOrder.TRUST: (2050 / 2496, 96 / 1404), -} +from arknights_mower.solvers.base_mixin import ArrangeOrder, arrange_order_res, BaseMixin stage_drop = {} -class BaseSchedulerSolver(BaseSolver): +class BaseSchedulerSolver(BaseSolver, BaseMixin): """ 收集基建的产物:物资、赤金、信赖 """ @@ -1565,68 +1551,12 @@ def get_arrange_order(self) -> ArrangeOrder: logger.debug((best_score, best_order)) return best_order - def switch_arrange_order(self, index: int, asc="false") -> None: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - # 点个不需要的 - if index < 4: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index + 1)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - else: - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index - 1)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0, rebuild=False) - # 切回来 - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) - # 倒序 - if asc != "false": - self.tap((self.recog.w * arrange_order_res[ArrangeOrder(index)][0], - self.recog.h * arrange_order_res[ArrangeOrder(index)][1]), interval=0.2, rebuild=True) - - def scan_agent(self, agent: list[str], error_count=0, max_agent_count=-1): - try: - # 识别干员 - self.recog.update() - ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下 - # 提取识别出来的干员的名字 - select_name = [] - for y in ret: - name = y[0] - if name in agent: - select_name.append(name) - # self.get_agent_detail((y[1][0])) - self.tap((y[1][0]), interval=0) - agent.remove(name) - # 如果是按照个数选择 Free - if max_agent_count != -1: - if len(select_name) >= max_agent_count: - return select_name, ret - return select_name, ret - except Exception as e: - error_count += 1 - if error_count < 3: - logger.exception(e) - self.sleep(3) - return self.scan_agent(agent, error_count, max_agent_count) - else: - raise e - def get_order(self, name): if name in self.op_data.operators: return True, self.op_data.operators[name].arrange_order else: return False, [2, "false"] - def detail_filter(self, turn_on, type="not_in_dorm"): - logger.info(f'开始 {("打开" if turn_on else "关闭")} {type} 筛选') - self.tap((self.recog.w * 0.95, self.recog.h * 0.05), interval=1) - if type == "not_in_dorm": - not_in_dorm = self.find('arrange_non_check_in', score=0.9) - if turn_on ^ (not_in_dorm is None): - self.tap((self.recog.w * 0.3, self.recog.h * 0.5), interval=0.5) - # 确认 - self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) - def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: """ :param order: ArrangeOrder, 选择干员时右上角的排序功能 @@ -1787,11 +1717,6 @@ def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: self.last_room = room logger.info(f"设置上次房间为{self.last_room}") - def swipe_left(self, right_swipe, w, h): - for _ in range(right_swipe): - self.swipe_only((w // 2, h // 2), (w // 2, 0), interval=0.5) - return 0 - def read_accurate_mood(self, img, cord): try: img = img[cord[1]:cord[3], cord[0]:cord[2]] From 372343b1efca691e276b2d753d0ad6b3defc7d12 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 11:51:06 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E5=B0=86enter=5Froom=E7=A7=BB=E8=87=B3Ba?= =?UTF-8?q?seMixin=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 19 ------------- arknights_mower/solvers/base_mixin.py | 33 ++++++++++++++++++++++- arknights_mower/solvers/base_schedule.py | 29 -------------------- 3 files changed, 32 insertions(+), 49 deletions(-) diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index 31cd9bb94..cc5028a48 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -341,25 +341,6 @@ def ori_clue(self): logger.debug(clues) return clues - def enter_room(self, room: str) -> tp.Rectangle: - """ 获取房间的位置并进入 """ - - # 获取基建各个房间的位置 - base_room = segment.base(self.recog.img, self.find('control_central', strict=True)) - - # 将画面外的部分删去 - room = base_room[room] - for i in range(4): - room[i, 0] = max(room[i, 0], 0) - room[i, 0] = min(room[i, 0], self.recog.w) - room[i, 1] = max(room[i, 1], 0) - room[i, 1] = min(room[i, 1], self.recog.h) - - # 点击进入 - self.tap(room[0], interval=3) - while self.find('control_central') is not None: - self.tap(room[0], interval=3) - def drone(self, room: str): logger.info('基建:无人机加速') diff --git a/arknights_mower/solvers/base_mixin.py b/arknights_mower/solvers/base_mixin.py index 47a401bbf..b9dc34ed6 100644 --- a/arknights_mower/solvers/base_mixin.py +++ b/arknights_mower/solvers/base_mixin.py @@ -1,8 +1,10 @@ from __future__ import annotations from enum import Enum -from arknights_mower.utils import character_recognize +from arknights_mower.utils import character_recognize, segment from arknights_mower.utils.log import logger +from arknights_mower.utils import typealias as tp +from arknights_mower.utils.recognize import Scene class ArrangeOrder(Enum): @@ -111,3 +113,32 @@ def detail_filter(self, turn_on, type="not_in_dorm"): self.tap((self.recog.w * 0.3, self.recog.h * 0.5), interval=0.5) # 确认 self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) + + def enter_room(self, room: str) -> tp.Rectangle: + """ 获取房间的位置并进入 """ + success = False + retry = 3 + while not success: + try: + # 获取基建各个房间的位置 + base_room = segment.base(self.recog.img, self.find('control_central', strict=True)) + # 将画面外的部分删去 + _room = base_room[room] + + for i in range(4): + _room[i, 0] = max(_room[i, 0], 0) + _room[i, 0] = min(_room[i, 0], self.recog.w) + _room[i, 1] = max(_room[i, 1], 0) + _room[i, 1] = min(_room[i, 1], self.recog.h) + + # 点击进入 + self.tap(_room[0], interval=3) + while self.find('control_central') is not None: + self.tap(_room[0], interval=3) + success = True + except Exception as e: + retry -= 1 + self.back_to_infrastructure() + self.wait_for_scene(Scene.INFRA_MAIN, "get_infra_scene") + if retry <= 0: + raise e diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 81cef14df..0249f8082 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -1303,35 +1303,6 @@ def ori_clue(self): logger.debug(clues) return clues - def enter_room(self, room: str) -> tp.Rectangle: - """ 获取房间的位置并进入 """ - success = False - retry = 3 - while not success: - try: - # 获取基建各个房间的位置 - base_room = segment.base(self.recog.img, self.find('control_central', strict=True)) - # 将画面外的部分删去 - _room = base_room[room] - - for i in range(4): - _room[i, 0] = max(_room[i, 0], 0) - _room[i, 0] = min(_room[i, 0], self.recog.w) - _room[i, 1] = max(_room[i, 1], 0) - _room[i, 1] = min(_room[i, 1], self.recog.h) - - # 点击进入 - self.tap(_room[0], interval=3) - while self.find('control_central') is not None: - self.tap(_room[0], interval=3) - success = True - except Exception as e: - retry -= 1 - self.back_to_infrastructure() - self.wait_for_scene(Scene.INFRA_MAIN, "get_infra_scene") - if retry <= 0: - raise e - def adjust_order_time(self, accelerate, room): error_count = 0 while scheduling(self.tasks) is not None: From 07354b80a938dbf48866037d03b0be5b26cfb163 Mon Sep 17 00:00:00 2001 From: Shawnsdaddy Date: Sun, 5 Nov 2023 21:57:11 -0800 Subject: [PATCH 13/19] =?UTF-8?q?=E6=96=B0=E5=A2=9Eparty=5Ftime=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B7=83=E8=B7=83=E5=88=87=E7=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_schedule.py | 15 ++- arknights_mower/tests/base_scheduler_tests.py | 104 ++++++++++++++++++ arknights_mower/utils/operators.py | 1 + 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 arknights_mower/tests/base_scheduler_tests.py diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 0249f8082..b827d7b1e 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -71,17 +71,26 @@ def __init__(self, device: Device = None, recog: Recognizer = None) -> None: self.maa_config = {} self.free_clue = None self.credit_fight = None - self.maa_depot_enable = False + self.task_count = 0 self.exit_game_when_idle = False self.simulator = None self.close_simulator_when_idle = False self.refresh_connecting = False self.recruit_config = {} self.skland_config = {} - self.recruit_time = None - self.daily_mission = False + + @property + def party_time(self): + return self._party_time + + @party_time.setter + def party_time(self, value): + self._party_time = value + if self.op_data is not None: + self.op_data.party_time = value + def run(self) -> None: """ :param clue_collect: bool, 是否收取线索 diff --git a/arknights_mower/tests/base_scheduler_tests.py b/arknights_mower/tests/base_scheduler_tests.py new file mode 100644 index 000000000..d34347071 --- /dev/null +++ b/arknights_mower/tests/base_scheduler_tests.py @@ -0,0 +1,104 @@ +import unittest +from datetime import datetime +from unittest.mock import patch, MagicMock +from arknights_mower.solvers.base_schedule import BaseSchedulerSolver +from arknights_mower.utils.logic_expression import LogicExpression +from arknights_mower.utils.plan import Room, PlanConfig, Plan + +with patch.dict('sys.modules', {'RecruitSolver': MagicMock()}): + from ..solvers import RecruitSolver + + +class TestBaseScheduler(unittest.TestCase): + + @patch.object(BaseSchedulerSolver, '__init__', lambda x: None) + def test_backup_plan_solver_Caper(self): + plan_config = {"meeting": [Room("伊内丝", "", ["见行者", "陈"]), + Room("跃跃", "", ["见行者", "陈"])]} + plan_config1 = {"meeting": [Room("伊内丝", "", ["陈", "红"]), + Room("见行者", "", ["陈", "红"])]} + agent_base_config = PlanConfig("稀音", "稀音", "伺夜") + plan = { + # 阶段 1 + "default_plan": Plan(plan_config, agent_base_config), + "backup_plans": [Plan(plan_config1, agent_base_config, + trigger=LogicExpression("op_data.party_time is None", + "and", " True "), + task={'meeting': ['Current', '见行者']})] + } + + solver = BaseSchedulerSolver() + solver.global_plan = plan + solver.initialize_operators() + solver.tasks = [] + with patch.object(BaseSchedulerSolver, 'agent_get_mood') as mock_agent_get_mood: + mock_agent_get_mood.return_value = None + solver.backup_plan_solver() + self.assertEqual(len(solver.tasks), 1) + print(solver.op_data.plan_name) + solver.party_time = datetime.now() + solver.backup_plan_solver() + self.assertEqual(solver.op_data.plan_name, "default_plan") + + @patch.object(BaseSchedulerSolver, '__init__', lambda x: None) + def test_backup_plan_solver_GreyytheLightningbearer(self): + plan_config = {"room_2_3": [Room("雷蛇", "澄闪", ["炎狱炎熔", "格雷伊"])], + "room_1_3": [Room("承曦格雷伊", "自动化", ["炎狱炎熔"])], + "room_2_1": [Room("温蒂", "自动化", ["泡泡"]), + Room("森蚺", "自动化", ["火神"]), + Room("清流", "自动化", ["贝娜"])], + "room_2_2": [Room("澄闪", "澄闪", ["炎狱炎熔", "格雷伊"])], + "central": [Room("阿米娅", "", ["诗怀雅"]), + Room("琴柳", "乌有", ["清道夫"]), + Room("重岳", "乌有", ["杜宾"]), + Room("夕", "乌有", ["玛恩纳"]), + Room("令", "乌有", ["凯尔希"])], + "contact": [Room("桑葚", "乌有", ["絮雨"])], + } + backup_plan1_config = {"central": [Room("阿米娅", "", ["诗怀雅"]), + Room("清道夫", "", ["诗怀雅"]), + Room("杜宾", "", ["泡泡"]), + Room("玛恩纳", "", ["火神"]), + Room("森蚺", "", ["诗怀雅"])], + "room_2_1": [Room("温蒂", "", ["泡泡"]), + Room("掠风", "", ["贝娜"]), + Room("清流", "", ["火神"])], + "room_1_3": [Room("Lancet-2", "", ["承曦格雷伊"])], + "room_2_2": [Room("澄闪", "", ["承曦格雷伊", "格雷伊"])], + "room_2_3": [Room("雷蛇", "", ["承曦格雷伊", "格雷伊"])], + "contact": [Room("絮雨", "", ["桑葚"])], + } + agent_base_config0 = PlanConfig("稀音,黑键,焰尾,伊内丝", "稀音,柏喙,伊内丝", "伺夜,帕拉斯,雷蛇,澄闪,红云,乌有,年,远牙,阿米娅,桑葚,截云,掠风", ling_xi=2, + resting_threshold=0.1, run_order_buffer_time=20) + agent_base_config = PlanConfig("稀音,黑键,焰尾,伊内丝", "稀音,柏喙,伊内丝", "伺夜,帕拉斯,雷蛇,澄闪,红云,乌有,年,远牙,阿米娅,桑葚,截云", ling_xi=2, + free_blacklist="艾丽妮,但书,龙舌兰", run_order_buffer_time=20) + plan = { + # 阶段 1 + "default_plan": Plan(plan_config, agent_base_config), + "backup_plans": [Plan(backup_plan1_config, agent_base_config0, + trigger=LogicExpression("op_data.operators['令'].current_room.startswith('dorm')", + "and", + LogicExpression( + "op_data.operators['温蒂'].current_mood() - op_data.operators['承曦格雷伊'].current_mood()", + ">", "4")), + task={'dormitory_2': ['Current', 'Current', 'Current', 'Current', '承曦格雷伊']})] + } + + solver = BaseSchedulerSolver() + solver.global_plan = plan + solver.initialize_operators() + solver.tasks = [] + with patch.object(BaseSchedulerSolver, 'agent_get_mood') as mock_agent_get_mood: + mock_agent_get_mood.return_value = None + solver.op_data.operators['令'].current_room = 'dorm' + solver.op_data.operators['温蒂'].mood = 12 + solver.op_data.operators['承曦格雷伊'].mood = 7 + solver.backup_plan_solver() + self.assertEqual(len(solver.tasks), 1) + solver.op_data.operators['承曦格雷伊'].mood = 12 + solver.backup_plan_solver() + self.assertEqual(solver.op_data.plan_name, "default_plan") + + +if __name__ == '__main__': + unittest.main() diff --git a/arknights_mower/utils/operators.py b/arknights_mower/utils/operators.py index fa4cd7270..100f646de 100644 --- a/arknights_mower/utils/operators.py +++ b/arknights_mower/utils/operators.py @@ -35,6 +35,7 @@ def __init__(self, plan): self.run_order_rooms = {} self.clues = [] self.current_room_changed_callback = None + self.party_time = None def __repr__(self): return f'Operators(operators={self.operators})' From 7f0d3490ed9f30dbffd234dfd51a78226ffeb079 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 14:58:26 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E5=90=88=E5=B9=B6=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8Cbase=5Fconstruct=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 58 +++++++++- arknights_mower/solvers/base_mixin.py | 123 +++++++++++++++++++++- arknights_mower/solvers/base_schedule.py | 105 ------------------ 3 files changed, 177 insertions(+), 109 deletions(-) diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index cc5028a48..7e8911b19 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -9,8 +9,9 @@ from ..utils.log import logger from ..utils.recognize import RecognizeError, Recognizer, Scene from ..utils.solver import BaseSolver +from arknights_mower.utils.digit_reader import DigitReader - +import time import copy from arknights_mower.solvers.base_mixin import ArrangeOrder, arrange_order_res, BaseMixin @@ -23,6 +24,7 @@ class BaseConstructSolver(BaseSolver, BaseMixin): def __init__(self, device: Device = None, recog: Recognizer = None) -> None: super().__init__(device, recog) + self.digit_reader = DigitReader() def run(self, arrange: dict[str, tp.BasePlan] = None, clue_collect: bool = False, drone_room: str = None, fia_room: str = None) -> None: """ @@ -908,3 +910,57 @@ def fia(self, room: str): # clues['own'][i] = count # return clues + + def get_agent_from_room(self, room, read_time_index=None, length=3): + if read_time_index is None: + read_time_index = [] + error_count = 0 + if room == 'meeting': + time.sleep(3) + self.recog.update() + clue_res = self.read_screen(self.recog.img, limit=10, cord=(645, 977, 755, 1018)) + if clue_res != 11: + self.clue_count = clue_res + logger.info(f'当前拥有线索数量为{self.clue_count}') + while self.find('room_detail') is None: + if error_count > 3: + self.reset_room_time(room) + raise Exception('未成功进入房间') + self.tap((self.recog.w * 0.05, self.recog.h * 0.4), interval=0.5) + error_count += 1 + if length > 3: + self.swipe((self.recog.w * 0.8, self.recog.h * 0.5), (0, self.recog.h * 0.45), duration=500, + interval=1, + rebuild=True) + name_p = [((1460, 160), (1800, 215)), ((1460, 365), (1800, 425)), ((1460, 576), (1800, 633)), + ((1460, 555), (1800, 613)), ((1460, 765), (1800, 823))] + time_p = [((1650, 270, 1780, 305)), ((1650, 480, 1780, 515)), ((1650, 690, 1780, 725)), + ((1650, 668, 1780, 703)), ((1650, 877, 1780, 912))] + mood_p = [((1470, 219, 1780, 221)), ((1470, 428, 1780, 430)), ((1470, 637, 1780, 639)), + ((1470, 615, 1780, 617)), ((1470, 823, 1780, 825))] + result = [] + swiped = False + for i in range(length): + if i >= 3 and not swiped: + self.swipe((self.recog.w * 0.8, self.recog.h * 0.5), (0, -self.recog.h * 0.45), duration=500, + interval=1, rebuild=True) + swiped = True + _name = self.read_screen(self.recog.img[name_p[i][0][1]:name_p[i][1][1], name_p[i][0][0]:name_p[i][1][0]], + type="name") + error_count = 0 + while i >= 3 and _name != '' and ( + next((e for e in result if e['agent'] == _name), None)) is not None: + logger.warning("检测到滑动可能失败") + self.swipe((self.recog.w * 0.8, self.recog.h * 0.5), (0, -self.recog.h * 0.45), duration=500, + interval=1, rebuild=True) + _name = self.read_screen( + self.recog.img[name_p[i][0][1]:name_p[i][1][1], name_p[i][0][0]:name_p[i][1][0]], type="name") + error_count += 1 + if error_count > 1: + raise Exception("超过出错上限") + if room.startswith('dorm'): + extra = self.double_read_time(time_p[i], upperLimit=43200) + else: + extra = self.read_accurate_mood(self.recog.img, cord=mood_p[i]) + result.append({_name: extra}) + return result diff --git a/arknights_mower/solvers/base_mixin.py b/arknights_mower/solvers/base_mixin.py index b9dc34ed6..353546ea4 100644 --- a/arknights_mower/solvers/base_mixin.py +++ b/arknights_mower/solvers/base_mixin.py @@ -1,10 +1,16 @@ from __future__ import annotations +from datetime import timedelta, datetime from enum import Enum + +import cv2 + from arknights_mower.utils import character_recognize, segment from arknights_mower.utils.log import logger from arknights_mower.utils import typealias as tp from arknights_mower.utils.recognize import Scene +from arknights_mower.utils import rapidocr +from arknights_mower.data import agent_list, ocr_error class ArrangeOrder(Enum): @@ -115,13 +121,15 @@ def detail_filter(self, turn_on, type="not_in_dorm"): self.tap((self.recog.w * 0.8, self.recog.h * 0.8), interval=0.5) def enter_room(self, room: str) -> tp.Rectangle: - """ 获取房间的位置并进入 """ + """获取房间的位置并进入""" success = False retry = 3 while not success: try: # 获取基建各个房间的位置 - base_room = segment.base(self.recog.img, self.find('control_central', strict=True)) + base_room = segment.base( + self.recog.img, self.find("control_central", strict=True) + ) # 将画面外的部分删去 _room = base_room[room] @@ -133,7 +141,7 @@ def enter_room(self, room: str) -> tp.Rectangle: # 点击进入 self.tap(_room[0], interval=3) - while self.find('control_central') is not None: + while self.find("control_central") is not None: self.tap(_room[0], interval=3) success = True except Exception as e: @@ -142,3 +150,112 @@ def enter_room(self, room: str) -> tp.Rectangle: self.wait_for_scene(Scene.INFRA_MAIN, "get_infra_scene") if retry <= 0: raise e + + def double_read_time(self, cord, upperLimit=None, use_digit_reader=False): + self.recog.update() + time_in_seconds = self.read_time(cord, upperLimit, use_digit_reader) + if time_in_seconds is None: + return datetime.now() + execute_time = datetime.now() + timedelta(seconds=(time_in_seconds)) + return execute_time + + def read_accurate_mood(self, img, cord): + try: + img = img[cord[1] : cord[3], cord[0] : cord[2]] + # Convert the image to grayscale + gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) + + blurred_image = cv2.GaussianBlur(gray_image, (5, 5), 0) + + # Threshold the image to isolate the progress bar region + contours, hierarchy = cv2.findContours( + blurred_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE + ) + + # Calculate the bounding box of the progress bar + x, y, w, h = cv2.boundingRect(contours[0]) + + # Crop the progress bar region + progress_bar = img[y : y + h, x : x + w] + + # Convert the progress bar to grayscale + gray_pb = cv2.cvtColor(progress_bar, cv2.COLOR_BGR2GRAY) + + # Threshold the progress bar to isolate the gray fill + ret, thresh_pb = cv2.threshold(gray_pb, 137, 255, cv2.THRESH_BINARY) + + # Calculate the ratio of colored pixels to the total number of pixels in the progress bar region + total_pixels = w * h + colored_pixels = cv2.countNonZero(thresh_pb) + return colored_pixels / total_pixels * 24 + + except Exception: + return 24 + + def read_screen(self, img, type="mood", limit=24, cord=None): + if cord is not None: + img = img[cord[1] : cord[3], cord[0] : cord[2]] + try: + ret = rapidocr.engine(img, use_det=False, use_cls=False, use_rec=True)[0] + logger.debug(ret) + if not ret or not ret[0][0]: + if "name" in type: + return character_recognize.agent_name(img, self.recog.h) + raise Exception("识别失败") + ret = ret[0][0] + if "赤金完成" in ret: + raise Exception("读取到赤金收取提示") + elif "心情" in ret: + raise Exception("识别区域错误") + if "mood" in type: + if (f"/{limit}") in ret: + ret = ret.replace(f"/{limit}", "") + if len(ret) > 0: + if "." in ret: + ret = ret.replace(".", "") + return int(ret) + else: + return -1 + elif "time" in type: + if "." in ret: + ret = ret.replace(".", ":") + return ret.strip() + elif "name" in type: + if ret in agent_list: + return ret + if ret in ocr_error: + name = ocr_error[ret] + logger.debug(f"{ret} =====> {name}") + return name + return character_recognize.agent_name(img, self.recog.h) + else: + return ret + except Exception as e: + logger.exception(e) + return limit + 1 + + def read_time(self, cord, upperlimit, error_count=0, use_digit_reader=False): + # 刷新图片 + self.recog.update() + try: + if use_digit_reader: + time_str = self.digit_reader.get_time(self.recog.gray) + else: + time_str = self.read_screen(self.recog.img, type="time", cord=cord) + h, m, s = str(time_str).split(":") + if int(m) > 60 or int(s) > 60: + raise Exception(f"读取错误") + res = int(h) * 3600 + int(m) * 60 + int(s) + if upperlimit is not None and res > upperlimit: + raise Exception(f"超过读取上限") + else: + return res + except: + logger.error("读取失败") + if error_count > 3: + logger.exception(f"读取失败{error_count}次超过上限") + return None + else: + return self.read_time( + cord, upperlimit, error_count + 1, use_digit_reader + ) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 0249f8082..060f07c1b 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -892,80 +892,6 @@ def get_run_roder_time(self, room): self.back(interval=2) return execute_time - def double_read_time(self, cord, upperLimit=None, use_digit_reader=False): - self.recog.update() - time_in_seconds = self.read_time(cord, upperLimit, use_digit_reader) - if time_in_seconds is None: - return datetime.now() - execute_time = datetime.now() + timedelta(seconds=(time_in_seconds)) - return execute_time - - def read_screen(self, img, type="mood", limit=24, cord=None): - if cord is not None: - img = img[cord[1]:cord[3], cord[0]:cord[2]] - try: - ret = rapidocr.engine(img, use_det=False, use_cls=False, use_rec=True)[0] - logger.debug(ret) - if not ret or not ret[0][0]: - if 'name' in type: - return character_recognize.agent_name(img, self.recog.h) - raise Exception("识别失败") - ret = ret[0][0] - if "赤金完成" in ret: - raise Exception("读取到赤金收取提示") - elif "心情" in ret: - raise Exception("识别区域错误") - if 'mood' in type: - if (f"/{limit}") in ret: - ret = ret.replace(f"/{limit}", '') - if len(ret) > 0: - if '.' in ret: - ret = ret.replace(".", "") - return int(ret) - else: - return -1 - elif 'time' in type: - if '.' in ret: - ret = ret.replace(".", ":") - return ret.strip() - elif 'name' in type: - if ret in agent_list: - return ret - if ret in ocr_error: - name = ocr_error[ret] - logger.debug(f"{ret} =====> {name}") - return name - return character_recognize.agent_name(img, self.recog.h) - else: - return ret - except Exception as e: - logger.exception(e) - return limit + 1 - - def read_time(self, cord, upperlimit, error_count=0, use_digit_reader=False): - # 刷新图片 - self.recog.update() - try: - if use_digit_reader: - time_str = self.digit_reader.get_time(self.recog.gray) - else: - time_str = self.read_screen(self.recog.img, type='time', cord=cord) - h, m, s = str(time_str).split(':') - if int(m) > 60 or int(s) > 60: - raise Exception(f"读取错误") - res = int(h) * 3600 + int(m) * 60 + int(s) - if upperlimit is not None and res > upperlimit: - raise Exception(f"超过读取上限") - else: - return res - except: - logger.error("读取失败") - if error_count > 3: - logger.exception(f"读取失败{error_count}次超过上限") - return None - else: - return self.read_time(cord, upperlimit, error_count + 1, use_digit_reader) - def todo_list(self) -> None: """ 处理基建 Todo 列表 """ tapped = False @@ -1688,37 +1614,6 @@ def choose_agent(self, agents: list[str], room: str, fast_mode=True) -> None: self.last_room = room logger.info(f"设置上次房间为{self.last_room}") - def read_accurate_mood(self, img, cord): - try: - img = img[cord[1]:cord[3], cord[0]:cord[2]] - # Convert the image to grayscale - gray_image = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) - - blurred_image = cv2.GaussianBlur(gray_image, (5, 5), 0) - - # Threshold the image to isolate the progress bar region - contours, hierarchy = cv2.findContours(blurred_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) - - # Calculate the bounding box of the progress bar - x, y, w, h = cv2.boundingRect(contours[0]) - - # Crop the progress bar region - progress_bar = img[y:y + h, x:x + w] - - # Convert the progress bar to grayscale - gray_pb = cv2.cvtColor(progress_bar, cv2.COLOR_BGR2GRAY) - - # Threshold the progress bar to isolate the gray fill - ret, thresh_pb = cv2.threshold(gray_pb, 137, 255, cv2.THRESH_BINARY) - - # Calculate the ratio of colored pixels to the total number of pixels in the progress bar region - total_pixels = w * h - colored_pixels = cv2.countNonZero(thresh_pb) - return colored_pixels / total_pixels * 24 - - except Exception: - return 24 - def reset_room_time(self, room): for _operator in self.op_data.operators.keys(): if self.op_data.operators[_operator].room == room: From 68032dd548dc74a6574dd66783ae451ed6ebae35 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 15:18:55 +0800 Subject: [PATCH 15/19] =?UTF-8?q?base=5Fconstruct=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E5=AE=BF=E8=88=8D=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index 7e8911b19..b663055f6 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -948,8 +948,7 @@ def get_agent_from_room(self, room, read_time_index=None, length=3): _name = self.read_screen(self.recog.img[name_p[i][0][1]:name_p[i][1][1], name_p[i][0][0]:name_p[i][1][0]], type="name") error_count = 0 - while i >= 3 and _name != '' and ( - next((e for e in result if e['agent'] == _name), None)) is not None: + while i >= 3 and _name in result: logger.warning("检测到滑动可能失败") self.swipe((self.recog.w * 0.8, self.recog.h * 0.5), (0, -self.recog.h * 0.45), duration=500, interval=1, rebuild=True) @@ -959,7 +958,7 @@ def get_agent_from_room(self, room, read_time_index=None, length=3): if error_count > 1: raise Exception("超过出错上限") if room.startswith('dorm'): - extra = self.double_read_time(time_p[i], upperLimit=43200) + extra = self.read_time(time_p[i], upperlimit=43200, error_count=4) else: extra = self.read_accurate_mood(self.recog.img, cord=mood_p[i]) result.append({_name: extra}) From 084da0e6d6ba4220aedebceb0f920f9f56487db6 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 20:42:24 +0800 Subject: [PATCH 16/19] =?UTF-8?q?base=5Fconstruct=E8=AF=BB=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/solvers/base_construct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/solvers/base_construct.py b/arknights_mower/solvers/base_construct.py index b663055f6..874c07864 100644 --- a/arknights_mower/solvers/base_construct.py +++ b/arknights_mower/solvers/base_construct.py @@ -961,5 +961,5 @@ def get_agent_from_room(self, room, read_time_index=None, length=3): extra = self.read_time(time_p[i], upperlimit=43200, error_count=4) else: extra = self.read_accurate_mood(self.recog.img, cord=mood_p[i]) - result.append({_name: extra}) + result.append((_name, extra)) return result From 998817b604fdb8ec59e400815d99e69803bbe119 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 20:44:34 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=9F=BA=E5=BB=BA=E6=8A=A5=E8=A1=A8=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/__main__.py b/arknights_mower/__main__.py index 49331c756..c1d706dcb 100644 --- a/arknights_mower/__main__.py +++ b/arknights_mower/__main__.py @@ -339,7 +339,7 @@ def simulate(): if sleep_time > 540: if base_scheduler.daily_mission is False: - base_scheduler.daily_mission = base_scheduler.read_report() + # base_scheduler.daily_mission = base_scheduler.read_report() base_scheduler.mail_plan_solver() if base_scheduler.skland_config["skland_enable"] == 1: base_scheduler.skland_plan_solover() From 671281f0a6325496e7d5ade008bacf11c07f6d79 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 20:44:46 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E6=8F=90=E9=AB=98=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=AD=E8=AF=86=E5=88=AB=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/utils/recognize.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arknights_mower/utils/recognize.py b/arknights_mower/utils/recognize.py index fe10999ab..78a552ff8 100644 --- a/arknights_mower/utils/recognize.py +++ b/arknights_mower/utils/recognize.py @@ -64,7 +64,7 @@ def get_scene(self) -> int: """ get the current scene in the game """ if self.scene != Scene.UNDEFINED: return self.scene - if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.15) is not None: + if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.2) is not None: self.scene = Scene.CONNECTING elif self.find('index_nav', thres=250, scope=((0, 0), (100+self.w//4, self.h//10))) is not None: self.scene = Scene.INDEX @@ -244,7 +244,7 @@ def get_scene(self) -> int: def get_infra_scene(self)-> int: if self.scene != Scene.UNDEFINED: return self.scene - if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.15) is not None: + if self.find('connecting', scope=((self.w//2, self.h//10*8), (self.w//4*3, self.h)), score=0.2) is not None: self.scene = Scene.CONNECTING elif self.find('double_confirm') is not None: if self.find('network_check') is not None: From e4633f3f73d5d4d36b0b79c662e392a28ae9b7b5 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 6 Nov 2023 20:45:06 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E5=8F=91=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arknights_mower/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arknights_mower/__init__.py b/arknights_mower/__init__.py index 57ebfc94a..5831b6fbd 100644 --- a/arknights_mower/__init__.py +++ b/arknights_mower/__init__.py @@ -15,4 +15,4 @@ __cli__ = not (__pyinstall__ and not sys.argv[1:]) __system__ = platform.system().lower() -__version__ = 'v3.5.0-alpha-19' +__version__ = 'v3.5.0-alpha-20'