feat: 迷失之地阵亡重开#2202
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough为战斗与虚空战败界面新增/调整若干屏幕识别区(新增“代理人阵亡”,调整/移除虚空战败按钮);扩展 GPU 同步执行封装并在运行逻辑中替换执行调用;在战斗流程检测到“代理人阵亡”时停止自动战斗并以相应状态失败,复用现有失败/重试节点通知路径。 Changes
Sequence Diagram(s)sequenceDiagram
participant RunLevel as RunLevel (lost_void_run_level)
participant GPUExec as GPU Executor
participant Detector as Template Detector
participant OCR as OCR / AreaChecker
participant Operation as Operation Controller
RunLevel->>GPUExec: execute_function(is_use_gpu, Detector.detect, screen)
GPUExec->>Detector: run detection (模板/区域)
Detector-->>GPUExec: detection result (例如: 代理人阵亡)
GPUExec-->>RunLevel: 返回检测结果
alt 检测到 代理人阵亡
RunLevel->>Operation: stop_auto_battle()
RunLevel->>Operation: notify_status(Operation.STATUS_AGENT_DEAD)
Operation-->>RunLevel: 路由到失败/重试处理
else 未检测到
RunLevel->>GPUExec: execute_function(..., OCR.check_ui_buttons)
GPUExec->>OCR: 识别 UI / OCR 检查
OCR-->>RunLevel: UI 状态结果
RunLevel->>Operation: 按常规逻辑继续或重试
end
Estimated code review effort🎯 4 (复杂) | ⏱️ ~45 分钟 Possibly related PRs
Suggested reviewers
诗
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/one_dragon/utils/gpu_executor.py`:
- Around line 16-22: Add full type annotations to execute_function: annotate
is_use_gpu as bool, make it generic with a TypeVar T, type fn as Callable[...,
T], args/kwargs appropriately typed (e.g., *args: Any, **kwargs: Any) and return
-> T; when is_use_gpu is True, avoid submit(...).result() deadlock by detecting
if current thread is already the GPU worker (e.g., check
threading.current_thread().name or a helper like is_gpu_worker_thread) and in
that case call fn(...) directly, otherwise call submit(fn, *args,
**kwargs).result() as before; keep references to execute_function and submit to
locate the change.
In
`@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py`:
- Around line 698-769: The branch under self.current_frame_in_battle never
updates self.last_check_finish_time, so the "疑似脱战" recheck rate limiter
(self.last_screenshot_time - self.last_check_finish_time >= 0.1) is ineffective
and causes high-frequency detection; fix it by updating
self.last_check_finish_time to the current screenshot timestamp
(self.last_screenshot_time) after performing the recheck logic in the
current_frame_in_battle path (e.g. right after detector/OCR/template checks and
before any return or before incrementing self.not_in_battle_times) so subsequent
iterations correctly respect the 0.1s throttling; refer to symbols
self.current_frame_in_battle, self.last_check_finish_time,
self.last_screenshot_time, self.not_in_battle_times, detector.run,
screen_utils.find_area_in_screen and screen_utils.find_by_ocr to locate where to
insert the update.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4f2db9ef-674c-4bf9-ba8e-4ef098859219
⛔ Files ignored due to path filters (2)
assets/template/battle/agent_dead/mask.pngis excluded by!**/*.pngassets/template/battle/agent_dead/raw.pngis excluded by!**/*.png
📒 Files selected for processing (6)
assets/game_data/screen_info/_od_merged.ymlassets/game_data/screen_info/battle.ymlsrc/one_dragon/base/operation/operation.pysrc/one_dragon/utils/gpu_executor.pysrc/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.pysrc/zzz_od/operation/challenge_mission/restart_in_battle.py
✅ Files skipped from review due to trivial changes (3)
- src/zzz_od/operation/challenge_mission/restart_in_battle.py
- src/one_dragon/base/operation/operation.py
- assets/game_data/screen_info/battle.yml
| if self.current_frame_in_battle: # 当前回到可战斗画面 | ||
| if (not self.last_frame_in_battle # 之前在非战斗画面 | ||
| or self.last_screenshot_time - self.last_det_time >= 0.8 # 0.8秒识别一次 | ||
| or (self.no_in_battle_times > 0 and self.last_screenshot_time - self.last_check_finish_time >= 0.1) # 之前也识别到脱离战斗 0.1秒识别一次 | ||
| or self.last_screenshot_time - self.last_det_time >= 0.8 # 0.8秒识别一次 | ||
| or (self.not_in_battle_times > 0 and self.last_screenshot_time - self.last_check_finish_time >= 0.1) # 之前也识别到脱离战斗 0.1秒识别一次 | ||
| ): | ||
| no_in_battle = False | ||
| not_in_battle = False | ||
| found_next_region_hint = False | ||
|
|
||
| # 尝试识别下层入口 (道中危机 和 终结之役 不需要识别) | ||
| if self.region_type not in [LostVoidRegionType.ELITE, LostVoidRegionType.BOSS]: | ||
| self.last_det_time = self.last_screenshot_time | ||
| try: | ||
| # 为了不随意打断战斗 这里的识别阈值要高一点 | ||
| if self.ctx.model_config.lost_void_det_gpu: | ||
| f = gpu_executor.submit( | ||
| self.detector.run, | ||
| image=self.last_screenshot, | ||
| conf=0.9, | ||
| run_time=self.last_screenshot_time, | ||
| ) | ||
| frame_result: DetectFrameResult = f.result() | ||
| else: | ||
| frame_result = self.detector.run( | ||
| image=self.last_screenshot, | ||
| conf=0.9, | ||
| run_time=self.last_screenshot_time, | ||
| ) | ||
| frame_result: DetectFrameResult = gpu_executor.execute_function( | ||
| self.ctx.model_config.lost_void_det_gpu, | ||
| self.detector.run, | ||
| image=self.last_screenshot, | ||
| conf=0.9, | ||
| run_time=self.last_screenshot_time, | ||
| ) | ||
| with_interact, with_distance, with_entry = self.detector.is_frame_with_all(frame_result) | ||
| if with_interact or with_distance or with_entry: | ||
| no_in_battle = True | ||
| not_in_battle = True | ||
| except Exception as e: | ||
| # 刚开始可能有一段时间识别报错 有可能是一张图同时在两个onnx里面跑 加入第二次截图观察 | ||
| log.error('战斗中识别交互出现异常', exc_info=e) | ||
| return self.round_wait() | ||
|
|
||
| if not no_in_battle: | ||
| if not not_in_battle: | ||
| area = self.ctx.screen_loader.get_area('战斗画面', '代理人阵亡') | ||
| result: FindAreaResultEnum = gpu_executor.execute_function( | ||
| self.ctx.model_config.ocr_gpu, | ||
| screen_utils.find_area_in_screen, | ||
| ctx=self.ctx, | ||
| screen=self.last_screenshot, | ||
| area=area, | ||
| ) | ||
|
|
||
| if result == FindAreaResultEnum.TRUE: | ||
| self.ctx.auto_battle_context.stop_auto_battle() | ||
| return self.round_fail(Operation.STATUS_AGENT_DEAD) | ||
|
|
||
| area = self.ctx.screen_loader.get_area('迷失之地-大世界', '区域-文本提示') | ||
| if self.ctx.model_config.ocr_gpu: | ||
| f = gpu_executor.submit( | ||
| screen_utils.find_by_ocr, | ||
| ctx=self.ctx, | ||
| screen=self.last_screenshot, | ||
| target_cn='前往下一个区域', | ||
| area=area, | ||
| ) | ||
| found = f.result() | ||
| else: | ||
| found = screen_utils.find_by_ocr(self.ctx, self.last_screenshot, target_cn='前往下一个区域', area=area) | ||
| found = gpu_executor.execute_function( | ||
| self.ctx.model_config.ocr_gpu, | ||
| screen_utils.find_by_ocr, | ||
| ctx=self.ctx, | ||
| screen=self.last_screenshot, | ||
| target_cn='前往下一个区域', | ||
| area=area, | ||
| ) | ||
|
|
||
| if found: | ||
| found_next_region_hint = True | ||
| no_in_battle = True | ||
| not_in_battle = True | ||
|
|
||
| # "前往下一个区域" 单次命中即判脱战 | ||
| if found_next_region_hint: | ||
| self.ctx.auto_battle_context.stop_auto_battle() | ||
| self.no_in_battle_times = 0 | ||
| self.not_in_battle_times = 0 | ||
| return self.round_success('识别需移动交互') | ||
|
|
||
| if no_in_battle: | ||
| self.no_in_battle_times += 1 | ||
| if not_in_battle: | ||
| self.not_in_battle_times += 1 | ||
| else: | ||
| self.no_in_battle_times = 0 | ||
| self.not_in_battle_times = 0 | ||
|
|
||
| if self.no_in_battle_times >= 10: | ||
| if self.not_in_battle_times >= 10: | ||
| self.ctx.auto_battle_context.stop_auto_battle() | ||
| return self.round_success('识别需移动交互') | ||
|
|
||
| return self.round_wait(wait_round_time=self.ctx.battle_assistant_config.screenshot_interval) |
There was a problem hiding this comment.
补上这段复检的时间戳刷新,否则会退化成逐帧识别。
这里用 self.last_check_finish_time 想把“疑似脱战”后的复检限流到 0.1 秒一次,但当前 self.current_frame_in_battle 分支里从没更新过这个时间。只要 self.not_in_battle_times > 0 触发过一次,后面的 detector、OCR 以及新增的 代理人阵亡 模板匹配就会在战斗热路径里持续高频执行,容易把识别线程压满并拖慢自动战斗。
建议修复
if self.current_frame_in_battle: # 当前回到可战斗画面
if (not self.last_frame_in_battle # 之前在非战斗画面
or self.last_screenshot_time - self.last_det_time >= 0.8 # 0.8秒识别一次
or (self.not_in_battle_times > 0 and self.last_screenshot_time - self.last_check_finish_time >= 0.1) # 之前也识别到脱离战斗 0.1秒识别一次
):
+ self.last_check_finish_time = self.last_screenshot_time
not_in_battle = False
found_next_region_hint = False🧰 Tools
🪛 Ruff (0.15.11)
[warning] 721-721: Do not catch blind exception: Exception
(BLE001)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py`
around lines 698 - 769, The branch under self.current_frame_in_battle never
updates self.last_check_finish_time, so the "疑似脱战" recheck rate limiter
(self.last_screenshot_time - self.last_check_finish_time >= 0.1) is ineffective
and causes high-frequency detection; fix it by updating
self.last_check_finish_time to the current screenshot timestamp
(self.last_screenshot_time) after performing the recheck logic in the
current_frame_in_battle path (e.g. right after detector/OCR/template checks and
before any return or before incrementing self.not_in_battle_times) so subsequent
iterations correctly respect the 0.1s throttling; refer to symbols
self.current_frame_in_battle, self.last_check_finish_time,
self.last_screenshot_time, self.not_in_battle_times, detector.run,
screen_utils.find_area_in_screen and screen_utils.find_by_ocr to locate where to
insert the update.
✅ Confirmed as addressed by @JoshCai233
There was a problem hiding this comment.
这里只要 self.not_in_battle_times > 0 触发过一次,就会持续检测 not_in_battle, 一旦检测到在战斗中就会使 self.not_in_battle_times = 0
There was a problem hiding this comment.
@JoshCai233,明白了,感谢说明。您说得对:
- 当
not_in_battle_times > 0时,进入快路径后运行 detector / OCR 检测 - 只要本次检测结果显示仍在战斗(
not_in_battle = False),self.not_in_battle_times就会立即归零 - 归零后下一帧的条件变回普通的 0.8 秒节流,不会持续高频运行
虽然 last_check_finish_time 在 current_frame_in_battle 分支里没有更新,导致实际行为是"逐帧检测"而非注释所写的"0.1 秒一次",但由于自我修正机制的存在,高频窗口非常短暂,不会造成持续压力。我撤回之前的担忧。
🧠 Learnings used
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2131
File: src/zzz_od/operation/compendium/notorious_hunt.py:193-194
Timestamp: 2026-03-25T02:47:22.640Z
Learning: 在 `src/zzz_od/operation/compendium/notorious_hunt.py` 的 `decide_notorious_hunt()` 中,OCR 识别到的 `left_times` 只写入 `self.can_run_times`,未同步到 `self.run_record.left_times`。这会导致 `after_battle()` 从旧缓存减 1,使外层 `check_left_times()` 误判还有剩余次数并再进入副本一次。但由于下一次进本时 `decide_notorious_hunt()` 会检测到 `深度追猎-!` 并立即将 `run_record.left_times = 0` 返回 `STATUS_NO_LEFT_TIMES`,实际后果只是多一次外层流程迭代,不会导致多打一场免费周本。作者已确认此为可接受的行为。
Learnt from: JoshCai233
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2014
File: src/zzz_od/operation/enter_game/enter_game.py:401-405
Timestamp: 2026-02-14T05:14:14.326Z
Learning: 在 src/zzz_od/operation/enter_game/enter_game.py 的 after_enter_game 方法中,如果 round_by_click_area('菜单', '返回') 失败,代码会直接返回失败结果而不继续重试。这是有意的设计,用于在「返回」按钮区域无法定位时快速失败,避免无意义的重试。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 0
File: :0-0
Timestamp: 2025-11-24T13:31:33.432Z
Learning: 在 src/zzz_od/application/world_patrol/operation/world_patrol_run_route.py 的脱困逻辑中,_do_unstuck_move 方法使用 self.ctx.auto_battle_context.switch_next() 的目的是切换角色来改变角色站位(利用不同角色体型/站位摆脱卡点),而不是为了战斗。该方法不需要战斗逻辑,不需要知道角色技能、连招等信息,即使 auto_op 未初始化,按键操作也能正常执行。
Learnt from: DoctorReid
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 1626
File: src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py:632-634
Timestamp: 2025-11-05T15:56:58.965Z
Learning: 在 src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py 中,init_auto_op 节点只调用 start_auto_battle(),实际的 auto_op 初始化在父应用 LostVoidApp 的 load_auto_op 节点中完成(通过 ctx.auto_battle_context.init_auto_op 调用)。因此在审查时需要检查完整的节点流程,而不是孤立地分析单个操作类。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2083
File: src/zzz_od/application/commission_assistant/commission_assistant_app.py:376-384
Timestamp: 2026-03-14T15:57:27.675Z
Learning: 在 `src/zzz_od/application/commission_assistant/commission_assistant_app.py` 的 `story_mode` 方法中,`StoryMode.SKIP` 分支在调用 `round_by_ocr_and_click_by_priority` 并检查确认框后,若确认框未检测到则会继续执行 `_do_dialog_click()`。作者确认这不会造成干扰——游戏 UI 保证在该场景下落入 `_do_dialog_click()` 是安全的,无需提前 return 来阻止此行为。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2131
File: src/zzz_od/operation/compendium/notorious_hunt.py:176-207
Timestamp: 2026-03-25T02:17:41.747Z
Learning: 在 `src/zzz_od/operation/compendium/notorious_hunt.py` 的 `decide_notorious_hunt` 方法中,当 `use_charge_power=False` 时,`剩余次数` OCR 区域可以显示 0、1、2、3(对应每周最多 3 次免费挑战次数)。`str_utils.get_positive_digits` 对 0 返回 None(0 不是正整数),会触发 retry 逻辑并最终回退到 `run_record.left_times`;对 1/2/3 则正常返回对应值。游戏 UI 在免费次数耗尽后会切换到显示 `按钮-深度追猎-ON` 或 `按钮-无报酬模式` 状态,这两个分支在 OCR 之前已经提前处理,因此在正常流程下 OCR 读到 0 的概率极低,但不是完全不可能。
Learnt from: kawayiYokami
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 1987
File: src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py:596-602
Timestamp: 2026-02-08T10:46:14.947Z
Learning: 在 src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py 的 after_complete 方法中,_is_matrix_action_text_visible() OCR 检查是所有迷失之地任务的通用回退机制(非仅限矩阵行动),用于在模板匹配失败时通过检测"矩阵行动"文本确认已返回入口页面。所有迷失之地任务(战线肃清/特遣调查/矩阵行动)共享完成次数计数器,因此无需按 mission_name 区分。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2172
File: src/zzz_od/application/charge_plan/charge_plan_app.py:186-191
Timestamp: 2026-04-18T05:56:11.454Z
Learning: 在 `src/zzz_od/operation/compendium/combat_simulation.py` 中,`CombatSimulation.choose_mission()` 在找不到目标副本时应返回 `round_fail(status=STATUS_CHOOSE_FAIL)` 而非 `round_success(status=STATUS_CHOOSE_FAIL)`。前者会让 `challenge_complete()` 的 `previous_node.is_success` 正确为 False,避免 `ChargePlanApp` 需要维护子流程内部失败状态字符串的黑名单。
Learnt from: JoshCai233
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2023
File: src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py:284-288
Timestamp: 2026-02-20T01:04:11.743Z
Learning: 在 src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py 的 matrix_select_agent 方法中,点击"主战"按钮只会将右侧主战编队中的角色移除,不会影响左侧可选代理人列表的显示状态,因此点击后无需调用 self.screenshot() 刷新截图。
Learnt from: JoshCai233
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2084
File: src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py:358-364
Timestamp: 2026-03-10T13:38:59.284Z
Learning: 在 src/zzz_od/application/hollow_zero/lost_void/lost_void_app.py 的 matrix_select_support_agent 方法中,代理人选择界面的角色卡片上,"UP" 徽章位于卡片左上角,而 "60" 等级文字位于卡片左下角。由于 OCR 从上到下扫描,"UP" 一定先于同一张卡的 "60" 出现在 ocr_result_list 中,因此用 `ocr_text.data.lower() in ['up', '60']` 作为单次循环判断条件是安全的,不会出现 "60" 先于 "UP" 被匹配的问题。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2131
File: src/zzz_od/operation/compendium/notorious_hunt.py:179-183
Timestamp: 2026-03-25T02:44:30.659Z
Learning: 在 `src/zzz_od/operation/compendium/notorious_hunt.py` 的 `decide_notorious_hunt` 方法中,`深度追猎-!` 模板(位于区域 (1480, 675, 1525, 720))在免费挑战次数耗尽时始终可见,无论界面处于 `按钮-深度追猎-ON` 状态还是 `按钮-无报酬模式` 状态。因此,只需检测 `深度追猎-!` 即可同时覆盖这两种情况,无需额外分别检测 `按钮-深度追猎-ON` 和 `按钮-无报酬模式`。
Learnt from: kawayiYokami
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 1947
File: src/zzz_od/auto_battle/auto_battle_agent_context.py:298-298
Timestamp: 2026-01-20T17:08:08.138Z
Learning: 在 src/zzz_od/auto_battle/auto_battle_agent_context.py 中,_last_ultimate_time 字段在 init_battle_agent_context() 中不重置是有意为之的。这样可以确保即使跨战斗初始化,终结技也必须保持至少 2 秒的冷却时间,防止终结技释放过于频繁。
Learnt from: kawayiYokami
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 1947
File: config/auto_battle_state_handler/速切模板-仪玄.sample.yml:7-16
Timestamp: 2026-01-20T17:10:25.539Z
Learning: In config/auto_battle_state_handler/速切模板-仪玄.sample.yml, the forced ultimate release branches use intentionally non-complementary conditions (`[仪玄-术法值全满]{1,1} & [仪玄-术法值]{119, 120}` vs `![仪玄-术法值全满]{1,1} & ![仪玄-术法值]{119, 120}`). This defensive design detects state recognition failures: if neither branch matches, it indicates the recognition system has an error, and the forced ultimate is skipped to avoid triggering skills based on incorrect state data.
<!-- </add_learning>
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2131
File: src/zzz_od/operation/compendium/notorious_hunt.py:217-223
Timestamp: 2026-03-25T13:49:15.021Z
Learning: 在 `src/zzz_od/operation/compendium/notorious_hunt.py` 的 `decide_by_use_power()` 中,`深度追猎` 开关的 ON 状态(绿色 "ON",底部显示"下一步"按钮,奖励栏有内容)与 OFF 状态(灰色 "OFF",底部显示"无报酬模式"按钮,奖励栏全为 EMPTY)在视觉上差异极大。因此,当 `深度追猎-!` 存在时,若 `按钮-深度追猎-ON` 模板未匹配,可以安全地判断为 OFF(无报酬模式)状态,不存在漏检风险。直接点击 `按钮-深度追猎-ON` 区域将其开启的逻辑是正确的,无需额外检测 `按钮-无报酬模式` 来确认状态。
Learnt from: JoshCai233
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2150
File: src/zzz_od/application/commission_assistant/commission_assistant_app.py:340-343
Timestamp: 2026-03-29T07:50:35.713Z
Learning: 在 `src/zzz_od/application/commission_assistant/commission_assistant_app.py` 的 `check_story_mode` 方法中,调用 `ctx.ocr_service.get_ocr_result_map` 时故意不传 `crop_first=False`,让其使用默认值 `True`(先裁剪区域再 OCR)。这是有意的性能优化:全屏 OCR 开销过大,裁剪后再识别可以显著减少计算量。其他调用点显式传 `crop_first=False` 是各自的需求,此处不需要保持一致。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 2067
File: src/zzz_od/application/world_patrol/operation/transport_by_3d_map.py:359-361
Timestamp: 2026-03-05T05:01:13.014Z
Learning: 在 OneDragon-Anything/ZenlessZoneZero-OneDragon 仓库中,不要对代码注释中的任何问题(包括全角/半角符号、标点符号、格式、措辞等)提出审查反馈或建议。只关注实质性的逻辑问题、bug 和性能问题。
Learnt from: Usagi-wusaqi
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 0
File: :0-0
Timestamp: 2025-11-02T14:24:09.448Z
Learning: 对于 OneDragon-Anything/ZenlessZoneZero-OneDragon 仓库,用户偏好审查关注实质性问题(逻辑错误、bug、性能问题等),避免花费时间在标点符号和注释格式等细枝末节的建议上。
Learnt from: kawayiYokami
Repo: OneDragon-Anything/ZenlessZoneZero-OneDragon PR: 1931
File: src/one_dragon/base/controller/pc_controller_base.py:64-71
Timestamp: 2026-01-13T18:59:27.574Z
Learning: 当成员使用 property 装饰器将方法变为只读属性时,应通过属性访问而非调用,示例:self.game_win.is_win_active 而非 self.game_win.is_win_active()。在进行代码审查时应检查对带有 property 的成员的访问方式是否正确,并避免用括号调用属性。
There was a problem hiding this comment.
不对, 是不是要把
or (self.not_in_battle_times > 0 and self.last_screenshot_time - self.last_check_finish_time >= 0.1) # 之前也识别到脱离战斗 0.1秒识别一次
改成
or (self.not_in_battle_times > 0 and self.last_screenshot_time - self.last_det_time >= 0.1) # 之前也识别到脱离战斗 0.1秒识别一次
@ShadowLemoon 你也来看看
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py (1)
864-881:⚠️ Potential issue | 🟡 Minor共用
find_target_fail_count计数器,建议明确语义。
处理寻路失败或阵亡现在同时承接处理寻路失败与STATUS_AGENT_DEAD两条失败路径,但仍然共用同一个find_target_fail_count。这意味着一次本层内若先后发生 2 次寻路失败 + 1 次阵亡,第 3 次累加后就直接准备最终退出,而每条路径都未必各自享受到 3 次重试上限。此外该计数器在RestartInBattle成功后也未重置,跨阶段会持续累积。如果这是有意为之(对总失败次数硬限),建议把变量改名为更通用的
restart_count/fail_retry_count;如果希望两类失败各自独立重试,则需要拆分计数器。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py` around lines 864 - 881, handle_find_target_fail currently uses a single attribute find_target_fail_count for both "寻路失败" and "阵亡" paths and never resets it after a successful restart; either rename it to a generic name like restart_count or fail_retry_count across the class (to reflect a global hard limit) or split into two explicit counters (e.g., find_target_fail_count and agent_dead_fail_count) and increment the appropriate one in handle_find_target_fail depending on the incoming failure type, and be sure to reset the relevant counter to 0 when RestartInBattle.execute() returns success so retries don’t leak across phases; update any other code that references find_target_fail_count accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py`:
- Around line 864-881: handle_find_target_fail currently uses a single attribute
find_target_fail_count for both "寻路失败" and "阵亡" paths and never resets it after
a successful restart; either rename it to a generic name like restart_count or
fail_retry_count across the class (to reflect a global hard limit) or split into
two explicit counters (e.g., find_target_fail_count and agent_dead_fail_count)
and increment the appropriate one in handle_find_target_fail depending on the
incoming failure type, and be sure to reset the relevant counter to 0 when
RestartInBattle.execute() returns success so retries don’t leak across phases;
update any other code that references find_target_fail_count accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1ab467c1-c30c-4210-8819-251265613092
📒 Files selected for processing (2)
src/one_dragon/utils/gpu_executor.pysrc/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py
🚧 Files skipped from review as they are similar to previous changes (1)
- src/one_dragon/utils/gpu_executor.py
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/one_dragon/utils/gpu_executor.py`:
- Line 60: The function signature for execute_function is missing a type hint on
the is_use_gpu parameter; update the signature to annotate is_use_gpu as a bool
(e.g., is_use_gpu: bool) so that all parameters follow the project's typing
rules, keeping the rest of the signature (Callable[P, T], ParamSpec usage, and
return type T) unchanged; ensure any internal references to is_use_gpu remain
consistent with the new annotation.
- Around line 41-46: 补全 should_serialize_session 的参数类型并收窄/移除宽泛异常捕获:给参数添加类型注解(例如
session: Any 或更具体的 onnxruntime.InferenceSession 若可用),然后不要使用 except
Exception;要么直接移除 try/except 让 get_providers() 的异常向上抛出,要么只捕获具体异常如
AttributeError(表示 session 没有 get_providers),并在捕获时返回 False;注意调用方 run_session
依赖该返回值,因此选择捕获 AttributeError 或去掉捕获以避免掩盖真实错误。
- Around line 49-52: The run_session function lacks type annotations; add
compliant type hints: annotate session as Any (or the concrete session type used
in this module), output_names as Sequence[str], input_feed as
Optional[Mapping[str, Any]] = None, keep **kwargs as Any, and add an explicit
return type of Any (or Tuple[Any, ...] if multiple outputs are expected). Update
the signature of run_session(session, output_names, input_feed=None, **kwargs)
accordingly and ensure callers (and references like should_serialize_session and
run_sync) still type-check with the new annotations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bdbd66df-10b5-40f7-aa66-05455e4ff701
📒 Files selected for processing (1)
src/one_dragon/utils/gpu_executor.py
31f17c0 to
1a2afe0
Compare
那这样的话检测全员阵亡的界面是不是可以删掉了?