Skip to content

Commit e7904b0

Browse files
committed
提高角色识别精度
1 parent cadf9d0 commit e7904b0

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/char/BaseChar.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Role(StrEnum):
3939
class BaseChar:
4040
"""角色基类,定义了游戏角色的通用属性和行为。"""
4141

42-
def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_name=None):
42+
def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_name=None, confidence=1):
4343
"""初始化角色基础属性。
4444
4545
Args:
@@ -68,13 +68,14 @@ def __init__(self, task, index, res_cd=20, echo_cd=20, liberation_cd=25, char_na
6868
self._liberation_available = False
6969
self._resonance_available = False
7070
self._echo_available = False
71-
self.logger = Logger.get_logger(self.name)
7271
self.full_ring_area = 0
7372
self.last_perform = 0
7473
self.current_con = 0
7574
self.has_tool_box = False
7675
self.intro_motion_freeze_duration = 0.9
7776
self.last_outro_time = -1
77+
self.confidence = confidence
78+
self.logger = Logger.get_logger(self.name)
7879

7980
def skip_combat_check(self):
8081
"""是否在某些操作中跳过战斗状态检查。
@@ -97,7 +98,7 @@ def name(self):
9798
Returns:
9899
str: 角色类名字符串。
99100
"""
100-
return self.__class__.__name__
101+
return f"{self.__class__.__name__}"
101102

102103
def __eq__(self, other):
103104
"""比较两个角色对象是否相同 (基于名称和索引)。"""
@@ -783,9 +784,9 @@ def check_outro(self):
783784
time = char.last_switch_time
784785
outro = char.char_name
785786
self.logger.info(f'erned outro from {outro}')
786-
return outro
787-
788-
# def count_rectangle_forte(self, left=0.42, right=0.57):
787+
return outro
788+
789+
# def count_rectangle_forte(self, left=0.42, right=0.57):
789790
# """计算矩形共鸣回路充能格数 (已注释)。"""
790791
# # Perform image cropping once, as it's independent of saturation ranges
791792
# cropped_image_base = self.task.box_of_screen(left, 0.927, right, 0.931).crop_frame(self.task.frame)

src/char/CharFactory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,18 @@ def get_char_by_pos(task, box, index, old_char):
7272
name = "unknown"
7373
char = None
7474
if old_char and old_char.char_name in char_names:
75-
char = task.find_one(old_char.char_name, box=box, threshold=0.6)
75+
char = task.find_one(old_char.char_name, box=box, threshold=0.8)
7676
if char:
7777
return old_char
7878

7979
if not char:
80-
char = task.find_best_match_in_box(box, char_names, threshold=0.6)
80+
char = task.find_best_match_in_box(box, char_names, threshold=0.8)
8181
if char:
8282
info = char_dict.get(char.name)
8383
name = char.name
8484
cls = info.get('cls')
8585
return cls(task, index, info.get('res_cd'), info.get('echo_cd'), info.get('liberation_cd') or 25,
86-
char_name=name)
86+
char_name=name, confidence=char.confidence)
8787
task.log_info(f'could not find char {index} {info} {highest_confidence}')
8888
if old_char:
8989
return old_char

src/task/BaseCombatTask.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ def load_chars(self):
513513
char.is_current_char = False
514514
self.combat_start = time.time()
515515

516-
# self.log_info(f'load chars success {self.chars}')
516+
# self.log_info(f'load chars success {self.chars} {[obj.confidence for obj in self.chars]}')
517517

518518
@staticmethod
519519
def should_update(the_char, old_char):

0 commit comments

Comments
 (0)