Skip to content

Commit

Permalink
Merge branch 'release/2.0.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Konano committed Feb 28, 2022
2 parents 9be4ba2 + 60df2ad commit 33aba0a
Show file tree
Hide file tree
Showing 15 changed files with 406 additions and 359 deletions.
2 changes: 1 addition & 1 deletion arknights_mower/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
__cli__ = not (__pyinstall__ and not sys.argv[1:])

__system__ = platform.system().lower()
__version__ = '2.0.1'
__version__ = '2.0.2'
112 changes: 0 additions & 112 deletions arknights_mower/data/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,116 +30,4 @@
'Castle3': 'Castle-3',
'Lancet2': 'Lancet-2',
'THRMEX': 'THRM-EX',
'佛影': '傀影',
'使影': '傀影',
'倪影': '傀影',
'影': '傀影',
'愧影': '傀影',
'国克洛丝': '克罗丝',
'家克洛丝': '克罗丝',
'卡湿利安': '卡涅利安',
'6卡缇': '卡缇',
'G卡缇': '卡缇',
'了G卡缇': '卡缇',
'叫米': '古米',
'叶米': '古米',
'叶': '吽',
'哗': '吽',
'耳': '吽',
'6夜刀': '夜刀',
'面夜刀': '夜刀',
'身': '宴',
'唉峨': '嵯峨',
'峡峨': '嵯峨',
'峨': '嵯峨',
'槎峨': '嵯峨',
'爱哦': '嵯峨',
'送哦': '嵯峨',
'送峨': '嵯峨',
'可巡林者': '巡林者',
'巡林': '巡林者',
'幽灵': '幽灵鲨',
'幽灵滥': '幽灵鲨',
'幽灵盗': '幽灵鲨',
'惊': '惊蛰',
'早器': '早露',
'6杜林': '杜林',
'I6杜林': '杜林',
'了G杜林': '杜林',
'桑甚': '桑葚',
'桑衰': '桑葚',
'来': '梓兰',
'粹兰': '梓兰',
'辣刺': '棘刺',
'森': '森蚺',
'森蚪': '森蚺',
'森蛾': '森蚺',
'森螃': '森蚺',
'深': '深靛',
'灰': '灰烬',
'm炎熔': '炎熔',
'n炎熔': '炎熔',
'了元炎熔': '炎熔',
'光恪': '炎熔',
'光烙': '炎熔',
'光焙': '炎熔',
'光熔': '炎熔',
'听炎熔': '炎熔',
'我恪': '炎熔',
'我烙': '炎熔',
'我焙': '炎熔',
'我熔': '炎熔',
'斤炎熔': '炎熔',
'炎恪': '炎熔',
'炎烙': '炎熔',
'炎焙': '炎熔',
'而炎熔': '炎熔',
'石': '燧石',
'狮喝': '狮蝎',
'狮蜴': '狮蝎',
'攻兰莎': '玫兰莎',
'放兰莎': '玫兰莎',
'救兰莎': '玫兰莎',
'欢兰莎': '玫兰莎',
'致兰莎': '玫兰莎',
'琴迎': '琴柳',
'自金': '白金',
'白面': '白面鸮',
'白面男': '白面鸮',
'白面鸭': '白面鸮',
'白面鹑': '白面鸮',
'白面鹗': '白面鸮',
'乐': '砾',
'优乐': '砾',
'既': '砾',
'研': '砾',
'舔': '砾',
'米格各': '米格鲁',
'罗比塔': '罗比菈塔',
'罗比拉塔': '罗比菈塔',
'罗比益塔': '罗比菈塔',
'罗比藏塔': '罗比菈塔',
'5美蓉': '芙蓉',
'G芙蓉': '芙蓉',
'可美蓉': '芙蓉',
'听美蓉': '芙蓉',
'市美蓉': '芙蓉',
'美蓉': '芙蓉',
'.芬': '芬',
'劳': '芬',
'节草': '苇草',
'草': '苇草',
'荣草': '苇草',
'蒂草': '苇草',
'蛇居箱': '蛇屠箱',
'野': '野鬃',
'野景': '野鬃',
'野秦': '野鬃',
'野紧': '野鬃',
'星': '陨星',
'碗星': '陨星',
'限星': '陨星',
'番草': '香草',
'看草': '香草',
'沾': '黑',
}
2 changes: 1 addition & 1 deletion arknights_mower/data/recruit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# recruit database

# TODO: check/update from gamedata
# TODO check/update from gamedata

recruit_database = [
('Lancet-2', 1, ['医疗干员', '远程位', '治疗', '支援机械']),
Expand Down
Binary file modified arknights_mower/fonts/SourceHanSansSC-Bold.otf
Binary file not shown.
Binary file added arknights_mower/resources/agent_on_shift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 75 additions & 18 deletions arknights_mower/solvers/base_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from ..utils import detector, segment
from ..utils import detector, segment, character_recognize
from ..utils import typealias as tp
from ..utils.device import Device
from ..utils.log import logger
Expand Down Expand Up @@ -363,29 +363,43 @@ def drone(self, room: str):

def choose_agent(self, agent: list[str]) -> None:
logger.info(f'安排干员:{agent}')
agent = set(agent)

# 滑动到最左边
h, w = self.recog.h, self.recog.w
for _ in range(9):
self.swipe((w//2, h//2), (w//2, 0), interval=0)
self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False)

checked = set() # 已经识别过的干员
pre = set() # 上次识别出的干员
error_count = 0
while True:
# 在 agent 中 'Free' 表示任意空闲干员
free_num = agent.count('Free')
agent = set(agent) - set(['Free'])

# 安排指定干员
if len(agent):

# 滑动到最左边
for _ in range(9):
self.swipe((w//2, h//2), (w//2, 0), interval=0)
self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False)
checked = set() # 已经识别过的干员
pre = set() # 上次识别出的干员
error_count, restart = 0, False

while len(agent):
try:
# 识别干员
ret = segment.agent(self.recog.img) # 返回的顺序是从左往右从上往下
ret = character_recognize.agent(self.recog.img) # 返回的顺序是从左往右从上往下
except RecognizeError as e:
logger.warning(e)
error_count += 1
if error_count >= 3:
if error_count < 3:
logger.debug(e)
self.sleep(3)
elif not restart:
# 重新滑动到最左边并重置变量
logger.warning(e)
for _ in range(9):
self.swipe((w//2, h//2), (w//2, 0), interval=0)
self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False)
checked = set()
pre = set()
error_count, restart = 0, True
else:
raise e
self.sleep(3)
continue

# 提取识别出来的干员的名字
Expand All @@ -394,7 +408,7 @@ def choose_agent(self, agent: list[str]) -> None:
error_count += 1
if error_count >= 3:
logger.warning(f'未找到干员:{list(agent)}')
return
break
else:
pre = agent_name

Expand All @@ -405,18 +419,61 @@ def choose_agent(self, agent: list[str]) -> None:
for name in agent_name & agent:
for y in ret:
if y[0] == name:
self.tap((y[1][0]), rebuild=False)
self.tap((y[1][0]), interval=0, rebuild=False)
break
agent.remove(name)

# 如果已经完成选择则退出
if len(agent) == 0:
return
break

st = ret[-2][1][2] # 起点
ed = ret[0][1][1] # 终点
self.swipe_noinertia(st, (ed[0]-st[0], 0))

# 安排空闲干员
if free_num:

# 滑动到最左边
for _ in range(9):
self.swipe((w//2, h//2), (w//2, 0), interval=0)
self.swipe((w//2, h//2), (w//2, 0), interval=3, rebuild=False)

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)
elif not restart:
# 重新滑动到最左边并重置变量
logger.warning(e)
h, w = self.recog.h, self.recog.w
for _ in range(9):
self.swipe((w//2, h//2), (w//2, 0), interval=0)
self.swipe((w//2, h//2), (w//2, 0),
interval=3, rebuild=False)
checked = set()
pre = set()
error_count, restart = 0, True
else:
raise e
continue

while free_num and len(ret):
self.tap(ret[0], interval=0, rebuild=False)
free_num -= 1
ret = ret[1:]

# 如果已经完成选择则退出
if free_num == 0:
break

self.swipe_noinertia(st, (ed[0]-st[0], 0))

def agent_arrange(self, plan: tp.BasePlan) -> None:
""" 基建排班 """
logger.info('基建:排班')
Expand Down
Loading

0 comments on commit 33aba0a

Please sign in to comment.