镜牢决策补强: 确认重试回退、快感合成闸门与英文 OCR 别名
- 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:
@@ -1,5 +1,6 @@
|
||||
"""Controller lifecycle and battle regressions using mocked MCP only."""
|
||||
import contextlib
|
||||
import copy
|
||||
import ctypes
|
||||
import io
|
||||
import json
|
||||
@@ -154,6 +155,21 @@ class AgentRuntimeTest(unittest.TestCase):
|
||||
self.assertTrue(result['stopped'])
|
||||
bridge.call.assert_not_called()
|
||||
|
||||
def test_changing_modal_ocr_still_falls_back_from_enter_and_bounds_retries(self):
|
||||
bridge = mock.Mock()
|
||||
frames = iter(['skill description A', 'skill description B', 'skill description C', 'skill description D'])
|
||||
bridge.call.side_effect = lambda tool, args=None: (
|
||||
{'ok': True, 'items': [{'text': next(frames), 'score': 1}]} if tool == 'get_state' else {'ok': True})
|
||||
options = {'wait': {'action': {'tool': 'wait', 'args': {}}, 'description': 'wait'},
|
||||
'requires_analysis': {'action': {'tool': 'requires_analysis', 'args': {}}, 'description': 'analysis'},
|
||||
'buy_swap': {'description': 'validated skill payment',
|
||||
'action': {'tool': 'keypress', 'args': {'key': 'enter'}},
|
||||
'fallback_action': {'tool': 'click', 'args': {'x': 790, 'y': 548}}}}
|
||||
with mock.patch.object(agent, 'candidates', side_effect=lambda *args: copy.deepcopy(options)):
|
||||
self.run_agent(bridge, extra_args=('--steps', '4'))
|
||||
inputs = [call.args[0] for call in bridge.call.call_args_list if call.args[0] != 'get_state']
|
||||
self.assertEqual(inputs, ['keypress', 'click', 'click'])
|
||||
|
||||
def test_close_error_still_releases_controller_mutex(self):
|
||||
bridge = mock.Mock()
|
||||
bridge.call.return_value = {'ok': True, 'items': []}
|
||||
|
||||
@@ -77,6 +77,14 @@ class SceneRegressionTest(unittest.TestCase):
|
||||
options['event_2']={'description':'当前事件选项:按下按钮;结果:选择后获得破裂饰品'}
|
||||
self.assertEqual(agent.fixed_fallback(options),'event_2')
|
||||
|
||||
@mock.patch.object(agent,'button_enabled',return_value=True)
|
||||
def test_due_thrill_fusion_prevents_leaving_before_bounded_check(self,_enabled):
|
||||
state={'symbol_upgraded':True,'floor':3,'thrill_fusion_due':True,'items':[
|
||||
{'text':t,'x':100,'y':100,'w':100,'h':40} for t in ('商店','刷新','离开')]}
|
||||
self.assertEqual(set(agent.candidates(state,refresh_used=4)), {'wait','requires_analysis'})
|
||||
state['thrill_fusion_due']=False
|
||||
self.assertTrue(any(k.startswith('button_') for k in agent.candidates(state,refresh_used=4)))
|
||||
|
||||
def test_sinner_very_high_precedes_high_and_generic_gold(self):
|
||||
options={'sinner_1':{'description':'预计成功率高'},
|
||||
'sinner_2':{'description':'预计成功率极高'},
|
||||
|
||||
@@ -87,6 +87,41 @@ class EnglishMirrorBoundaryTest(unittest.TestCase):
|
||||
self.assertNotEqual(agent.scene_fingerprint(observation('00:00:43:02')),
|
||||
agent.scene_fingerprint(observation('00:00:43:02', 'Commence')))
|
||||
|
||||
def test_result_story_ocr_changes_do_not_reset_continue_fallback(self):
|
||||
def observation(story, clock, button='Continue'):
|
||||
return normalize({'items': [{'text': text, 'score': score} for text, score in
|
||||
[('Result', .99), (button, .99), (story, .95), (clock, .98)]]})
|
||||
first = observation('You lookaway and continue on your path.', '00:00:10:02')
|
||||
second = observation('You look away and continue on your path.', '00:00:10:16')
|
||||
self.assertEqual(agent.scene_fingerprint(first), agent.scene_fingerprint(second))
|
||||
self.assertNotEqual(agent.scene_fingerprint(first),
|
||||
agent.scene_fingerprint(observation('same', '00:00:10:16', 'Battle!')))
|
||||
|
||||
def test_english_layer_cards_are_not_single_gift_observation(self):
|
||||
state = {'screen': {'w': 1278, 'h': 731}, 'items': [
|
||||
{'text': text, 'x': x, 'y': y, 'w': 90, 'h': 25, 'score': .99}
|
||||
for text, x, y in [('Acquire E.G.O Gift', 250, 159), ('Mounting Trials', 250, 425),
|
||||
('DefenseLevel +1, MaxHP+7.5%', 250, 491),
|
||||
('Select', 1080, 572), ('0/2', 1160, 569), ('Refuse Gift', 900, 572)]]}
|
||||
normalize(state)
|
||||
self.assertIn('防御等级 +1, 体力上限+7.5%', [item['text'] for item in state['items']])
|
||||
with mock.patch.object(agent, 'button_enabled', return_value=True):
|
||||
options = agent.candidates(state)
|
||||
self.assertTrue(any(key.startswith('hardship_') for key in options))
|
||||
self.assertNotIn('decline_extra_observation', options)
|
||||
self.assertNotIn('hardship_confirm', options)
|
||||
state['items'][-2]['text'] = '选择2/2'
|
||||
with mock.patch.object(agent, 'button_enabled', return_value=True):
|
||||
options = agent.candidates(state)
|
||||
self.assertEqual(set(options), {'requires_analysis', 'wait', 'hardship_confirm'})
|
||||
|
||||
def test_split_win_rate_button_starts_battle_loop_without_wave_label(self):
|
||||
state = normalize({'screen': {'w': 1278, 'h': 731}, 'items': [
|
||||
{'text': text, 'x': 993, 'y': y, 'w': 30, 'h': 16, 'score': .97}
|
||||
for text, y in [('Win', 542), ('Bate', 554)]]})
|
||||
self.assertTrue(agent.battle_is_visible(state))
|
||||
self.assertIn('battle', agent.candidates(state))
|
||||
|
||||
def test_commence_and_split_sinner_header_reach_judgement_boundary(self):
|
||||
state = {'screen': {'w': 1920, 'h': 1080}, 'items': [
|
||||
{'text': text, 'x': 1200, 'y': y, 'w': 200, 'h': 40, 'score': 1}
|
||||
|
||||
Reference in New Issue
Block a user