镜牢决策补强: 确认重试回退、快感合成闸门与英文 OCR 别名

Browse Source
- aalc_engine: window_move 下按压保持 0.5s, 避免 Unity 漏点
- jev_mirror_agent: 技能描述抖动时 Enter 未推进改点已核对按钮并限制连续重试;
  结果页指纹忽略剧情与时钟变化; 追加的苦难不再误判为单个饰品场景;
  第 3 层起离开商店前强制做一次有界快感合成检查
- lc_scene_aliases: 补 Mounting Trials / Acquire E.G.O Gift 等标签,
  识别拆分的 Win/Bate 胜率按钮与 Max HP / Defense Level 文本
- tests: 覆盖上述回归点
This commit is contained in:
Codex Agent
2026-10-22 15:44:02 +08:00
parent 05626e95c7
commit 0ddd8650b7
6 changed files with 115 additions and 2 deletions
+36 -1
View File
@@ -46,6 +46,12 @@ def text_items(state):
def scene_fingerprint(state): def scene_fingerprint(state):
"""Ignore changing clocks and counters when checking failed confirmations.""" """Ignore changing clocks and counters when checking failed confirmations."""
texts = [item['text'].replace(' ', '') for item in text_items(state)]
if any(label in texts for label in ('结果', '判定成功', '判定失败')):
# The video changes OCR line breaks/spelling even on a static result.
# Its result header and actual continuation controls define this scene.
return tuple(text for text in texts
if text in ('结果', '判定成功', '判定失败', '继续', '开始战斗', '确认'))
return tuple(item['text'] for item in text_items(state) return tuple(item['text'] for item in text_items(state)
if item.get('score', 0) > .93 if item.get('score', 0) > .93
and not re.fullmatch(r'[0-9:.]+', item['text'].replace(' ', ''))) and not re.fullmatch(r'[0-9:.]+', item['text'].replace(' ', '')))
@@ -238,7 +244,7 @@ def candidates(state, previous_battle=False, refresh_used=0):
} }
return options return options
gift_headers = sum(t == '获得E.G.O饰品' for t in texts) gift_headers = sum(t == '获得E.G.O饰品' for t in texts)
if gift_headers == 1 and '拒绝饰品' in texts and '选择' in texts: if gift_headers == 1 and '拒绝饰品' in texts and '选择' in texts and '追加的苦难' not in combined:
core = any(name in combined for name in ('成捆的符咒','标准负载电池','干巴柴涩鸡胸肉','干松紧致鸡胸肉','快感','雷枝')) core = any(name in combined for name in ('成捆的符咒','标准负载电池','干巴柴涩鸡胸肉','干松紧致鸡胸肉','快感','雷枝'))
if core and '雷枝' not in combined: if core and '雷枝' not in combined:
return options return options
@@ -369,6 +375,8 @@ def candidates(state, previous_battle=False, refresh_used=0):
'action':{'tool':'advance_dialog','args':{'presses':3}}, 'action':{'tool':'advance_dialog','args':{'presses':3}},
'fallback_action':{'tool':'click','args':{'x':item['x']+item['w']//2,'y':item['y']+item['h']//2}}, 'fallback_action':{'tool':'click','args':{'x':item['x']+item['w']//2,'y':item['y']+item['h']//2}},
} }
if 'hardship_confirm' in options:
return {key: options[key] for key in ('requires_analysis', 'wait', 'hardship_confirm')}
return options return options
# Nested confirmation/detail windows override the reward/pack behind them. # Nested confirmation/detail windows override the reward/pack behind them.
modal_question = ('确认' in texts and any('取消' in t for t in texts) modal_question = ('确认' in texts and any('取消' in t for t in texts)
@@ -511,6 +519,9 @@ def candidates(state, previous_battle=False, refresh_used=0):
and 0 < item['y']-sold['y'] < height*.25 for sold in items)] and 0 < item['y']-sold['y'] < height*.25 for sold in items)]
if in_shop and state.get('floor', 1) >= 2 and not state.get('symbol_upgraded', False): if in_shop and state.get('floor', 1) >= 2 and not state.get('symbol_upgraded', False):
return options return options
if in_shop and state.get('thrill_fusion_due'):
options['requires_analysis']['description'] = '本层商店需检查快感合成:保留核心饰品,按普通/特殊商店预览进行有界尝试;检查完成或材料不足后记录本层已处理,再继续技能替换。'
return options
if in_shop: if in_shop:
pending = 'thrill' if state.get('thrill_pending') else 'thunderbranch' if state.get('thunderbranch_pending') else None pending = 'thrill' if state.get('thrill_pending') else 'thunderbranch' if state.get('thunderbranch_pending') else None
if pending: if pending:
@@ -797,6 +808,21 @@ def acquire_single_instance():
return lambda: kernel.CloseHandle(lease) return lambda: kernel.CloseHandle(lease)
def apply_confirmation_retry(options, last_choice, consecutive_attempts):
"""A changing skill description must not hide an unsuccessful Enter."""
option = options.get(last_choice)
if not option or consecutive_attempts < 1 or not option.get('fallback_action'):
return
action = option['action']
if action != {'tool': 'keypress', 'args': {'key': 'enter'}} and action['tool'] != 'advance_dialog':
return
if consecutive_attempts >= 3:
del options[last_choice]
return
option['action'] = option['fallback_action']
option['description'] += ' 上次快捷确认未推进,点击本次已核对的按钮。'
def main(executor_decider=None): def main(executor_decider=None):
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('config', nargs='?', help='Optional Jev JSON config; omit for execution-model handoff') parser.add_argument('config', nargs='?', help='Optional Jev JSON config; omit for execution-model handoff')
@@ -820,6 +846,8 @@ def main(executor_decider=None):
run = None run = None
recent = [] recent = []
repeats = {} repeats = {}
last_choice = None
consecutive_attempts = 0
context_path = RUNTIME_HOME / 'jev_shop_context.json' context_path = RUNTIME_HOME / 'jev_shop_context.json'
stable_since = time.monotonic() stable_since = time.monotonic()
last_fingerprint = None last_fingerprint = None
@@ -866,11 +894,15 @@ def main(executor_decider=None):
state['battery_obtained'] = context.get('battery_obtained', False) state['battery_obtained'] = context.get('battery_obtained', False)
state['thunderbranch_pending'] = context.get('thunderbranch_pending',False) state['thunderbranch_pending'] = context.get('thunderbranch_pending',False)
state['thrill_pending'] = context.get('thrill_obtained',False) and not context.get('thrill_upgraded',False) state['thrill_pending'] = context.get('thrill_obtained',False) and not context.get('thrill_upgraded',False)
state['thrill_fusion_due'] = (context.get('floor', 1) >= 3
and not context.get('thrill_obtained', False)
and context.get('thrill_fusion_checked_floor') != context.get('floor'))
state['claim_requested'] = claim_is_current(run, context) state['claim_requested'] = claim_is_current(run, context)
options = candidates(state, previous_battle, context['refresh_used']) options = candidates(state, previous_battle, context['refresh_used'])
if fingerprint != last_fingerprint: if fingerprint != last_fingerprint:
stable_since = time.monotonic() stable_since = time.monotonic()
last_fingerprint = fingerprint last_fingerprint = fingerprint
repeats.clear()
stable_seconds = round(time.monotonic() - stable_since) stable_seconds = round(time.monotonic() - stable_since)
if stable_seconds > 30: if stable_seconds > 30:
recent.append({'observation':'画面已%d秒没有有效改变,请你判断是否需要主助手排查。' % stable_seconds}) recent.append({'observation':'画面已%d秒没有有效改变,请你判断是否需要主助手排查。' % stable_seconds})
@@ -890,6 +922,7 @@ def main(executor_decider=None):
action_id = json.dumps(options[key]['action'], sort_keys=True) action_id = json.dumps(options[key]['action'], sort_keys=True)
if key not in ('requires_analysis', 'wait', 'battle') and repeats.get((fingerprint, action_id), 0) >= 2: if key not in ('requires_analysis', 'wait', 'battle') and repeats.get((fingerprint, action_id), 0) >= 2:
del options[key] del options[key]
apply_confirmation_retry(options, last_choice, consecutive_attempts)
if len(options) == 2: if len(options) == 2:
unknown_since = unknown_since or time.monotonic() unknown_since = unknown_since or time.monotonic()
else: else:
@@ -964,6 +997,8 @@ def main(executor_decider=None):
repeats[(fingerprint, action_id)] = repeats.get((fingerprint, action_id), 0) + 1 repeats[(fingerprint, action_id)] = repeats.get((fingerprint, action_id), 0) + 1
action_started = time.monotonic() action_started = time.monotonic()
result = execute(bridge, action, deadline=deadline) result = execute(bridge, action, deadline=deadline)
consecutive_attempts = consecutive_attempts + 1 if choice == last_choice else 1
last_choice = choice
record['action_ms'] = round((time.monotonic()-action_started)*1000) record['action_ms'] = round((time.monotonic()-action_started)*1000)
record['finished_at'] = time.strftime('%Y-%m-%dT%H:%M:%S') record['finished_at'] = time.strftime('%Y-%m-%dT%H:%M:%S')
if result.get('stopped'): if result.get('stopped'):
+19
View File
@@ -24,6 +24,8 @@ LABELS = {
'e.g.ogiftsearch':'额外观测', 'eg.dgiftsearch':'额外观测', 'e.g.ogiftsearch':'额外观测', 'eg.dgiftsearch':'额外观测',
'nextfloor':'下一层', 'gotonextfloor':'前往下一层', 'proceedtonextfloor':'前往下一层', 'claim':'领取', 'nextfloor':'下一层', 'gotonextfloor':'前往下一层', 'proceedtonextfloor':'前往下一层', 'claim':'领取',
'additionalhardship':'追加的苦难', 'additionalhardships':'追加的苦难', 'additionalhardship':'追加的苦难', 'additionalhardships':'追加的苦难',
'mountingtrials':'追加的苦难', 'acquiree.g.ogift':'获得E.G.O饰品',
'acquiree.g.ogift!':'获得E.G.O饰品!', 'skilsowned':'当前持有技能',
'obtaine.g.ogift':'获得E.G.O饰品', 'obtaine.g.ogifts':'获得E.G.O饰品', 'obtaine.g.ogift':'获得E.G.O饰品', 'obtaine.g.ogifts':'获得E.G.O饰品',
'claimrewards':'领取奖励', 'explorationcomplete':'探索完成', 'claimrewards':'领取奖励', 'explorationcomplete':'探索完成',
'explorationcompleted':'探索完成', 'dungeoncomplete':'探索完成', 'explorationcompleted':'探索完成', 'dungeoncomplete':'探索完成',
@@ -40,7 +42,17 @@ def normalize(state):
raw = item['text'] raw = item['text']
compact = re.sub(r'\s+', '', raw).lower().lstrip('×x') compact = re.sub(r'\s+', '', raw).lower().lstrip('×x')
compact = compact.replace('e.g.0', 'e.g.o') compact = compact.replace('e.g.0', 'e.g.o')
compact = re.sub(r'fl[o0]{2}r', 'floor', compact)
text = LABELS.get(compact, raw) text = LABELS.get(compact, raw)
screen = state.get('screen', {})
if item.get('x', 0) > screen.get('w', 1920) * .65 and item.get('y', 0) > screen.get('h', 1080) * .5:
if compact in ('winrate', 'damage'):
text = '胜率' if compact == 'winrate' else '伤害'
elif compact == 'win' and any(
re.sub(r'\s+', '', other['text']).lower() in ('rate', 'bate')
and abs(other['x'] - item['x']) < 40
and 0 < other['y'] - item['y'] < 35 for other in source_items):
text = '胜率'
if compact == 'enhance' and any(re.sub(r'\s+', '', other['text']).lower() == 'gifts' if compact == 'enhance' and any(re.sub(r'\s+', '', other['text']).lower() == 'gifts'
and abs(other['x'] - item['x']) < 80 and 0 < other['y'] - item['y'] < 70 and abs(other['x'] - item['x']) < 80 and 0 < other['y'] - item['y'] < 70
for other in source_items): for other in source_items):
@@ -93,6 +105,13 @@ def normalize(state):
('Heathcliff','希斯克利夫'), ('Outis','奥提斯'), ('Gregor','格里高尔'), ('Heathcliff','希斯克利夫'), ('Outis','奥提斯'), ('Gregor','格里高尔'),
('Ryoshu','良秀'), ('Faust','浮士德')]: ('Ryoshu','良秀'), ('Faust','浮士德')]:
text = text.replace(english, chinese) text = text.replace(english, chinese)
text = re.sub(r'Max\s*HP', '体力上限', text, flags=re.I)
text = re.sub(r'Defense\s*Level', '防御等级', text, flags=re.I)
if re.fullmatch(r'\d+/\d+', compact) and any(
re.sub(r'\s+', '', other['text']).lower() in ('select', '选择')
and 0 < item['x'] - other['x'] < 150
and abs(item['y'] - other['y']) < 30 for other in source_items):
text = '选择' + compact
if text != raw: if text != raw:
item['original_text'] = raw item['original_text'] = raw
item['text'] = text item['text'] = text