Skip to content

Commit

Permalink
维娜·维多利亚 识别修复 v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawnsdaddy committed Oct 10, 2024
1 parent 74c1913 commit d7636af
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
Binary file modified arknights_mower/models/operator_select.model
Binary file not shown.
Binary file modified arknights_mower/models/recruit.pkl
Binary file not shown.
17 changes: 12 additions & 5 deletions arknights_mower/utils/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,6 @@ def __repr__(self):


class Operator:
time_stamp = None
depletion_rate = 0
workaholic = False
arrange_order = [2, "false"]
refresh_drained = False

def __init__(
self,
Expand Down Expand Up @@ -731,6 +726,9 @@ def __init__(
self.lower_limit = lower_limit
self.depletion_rate = depletion_rate
self.time_stamp = time_stamp
self.workaholic = False
self.arrange_order = [2, "false"]
self.refresh_drained = False

@property
def current_room(self):
Expand Down Expand Up @@ -800,5 +798,14 @@ def current_mood(self):
else:
return self.mood

def predict_exhaust(self):
remaining_mood = self.mood - self.lower_limit # 剩余心情
depletion_rate = self.depletion_rate # 心情掉率,小时单位
# 计算到心情归零所需时间(小时),再加上当前时间戳
if depletion_rate > 0:
return self.time_stamp + timedelta(hours=((remaining_mood / depletion_rate) - 0.5))
else:
return datetime.now()+timedelta(hours=24)

def __repr__(self):
return f"Operator(name='{self.name}', room='{self.room}', index={self.index}, group='{self.group}', replacement={self.replacement}, resting_priority='{self.resting_priority}', current_room='{self.current_room}',exhaust_require={self.exhaust_require},mood={self.mood}, upper_limit={self.upper_limit}, rest_in_full={self.rest_in_full}, current_index={self.current_index}, lower_limit={self.lower_limit}, operator_type='{self.operator_type}',depletion_rate={self.depletion_rate},time_stamp='{self.time_stamp}',refresh_order_room = {self.refresh_order_room})"
35 changes: 27 additions & 8 deletions auto_get_res_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ def 训练选中的干员名的模型(self):
"arknights_mower/fonts/SourceHanSansCN-Medium.otf", 25
)

font26 = ImageFont.truetype(
"arknights_mower/fonts/SourceHanSansCN-Medium.otf", 26
font27 = ImageFont.truetype(
"arknights_mower/fonts/SourceHanSansCN-Medium.otf", 27
)

data = {}
Expand All @@ -504,16 +504,35 @@ def 训练选中的干员名的模型(self):
for idx, operator in enumerate(agent_list):
font = font31
if not operator[0].encode().isalpha():
if "·" in operator:
# 维娜·维多利亚 识别的临时解决办法
font = font26
elif len(operator) == 7:
font = font25
if len(operator) == 7:
if "·" in operator:
# 维娜·维多利亚 识别的临时解决办法
font = font27
else:
font = font25
elif len(operator) == 6:
font = font30
img = Image.new(mode="L", size=(400, 100))
draw = ImageDraw.Draw(img)
draw.text((50, 20), operator, fill=(255,), font=font)
if "·" in operator:
x, y = 50, 20
char_index = {
i: False for i, char in enumerate(operator) if char == "·"
}
for i, char in enumerate(operator):
if i in char_index and not char_index[i]:
x -= 8
char_index[i] = True
if i + 1 not in char_index and char == "·":
char_index[i + 1] = False
draw.text((x, y), char, fill=(255,), font=font) # 绘制每个字符
char_width, char_height = font.getbbox(char)[
2:4
] # getbbox 返回 (x1, y1, x2, y2)
x += char_width
else:
draw.text((50, 20), operator, fill=(255,), font=font)

img = np.array(img, dtype=np.uint8)
img = thres2(img, 140)
dilation = cv2.dilate(img, kernel, iterations=1)
Expand Down

0 comments on commit d7636af

Please sign in to comment.