fix: 优化迷失之地无详情通用选择的决策 - #2469
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough本PR为迷失之地藏品选择流程新增"答题兜底"补选逻辑,在常规层选择未达目标数量时尝试点击无详情候选补足数量;同时重构多处选择决策与OCR识别相关日志文案,并将LostVoidArtifact的template_id类型改为str | None。 Changes答题兜底选择策略
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ChooseArtifact as choose_artifact
participant Layers as select_by_layers
participant Fallback as try_fill_by_answer_fallback
participant Screen as 截图识别
ChooseArtifact->>Layers: 常规层选择
Layers-->>ChooseArtifact: 无候选,需答题兜底
ChooseArtifact->>Fallback: try_fill_by_answer_fallback(target_num)
Fallback->>Screen: 截图并识别候选
Screen-->>Fallback: 候选列表
Fallback->>Fallback: 筛选无详情候选并去重
Fallback->>Screen: 点击候选
Fallback-->>ChooseArtifact: 是否达到目标数量
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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: 1
🧹 Nitpick comments (1)
src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_move_by_det.py (1)
633-635: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value
get_out_of_stuck中CLASS_INTERACT提前返回前,检测结果未被使用。
target_type == CLASS_INTERACT时直接返回STATUS_NEED_DETECT,但上方 lines 629-631 的detect_to_go调用结果frame_result在此分支中完全未被使用。脱困路径触发频率不高,影响较小,但可将该判断上移至检测之前以避免无效计算。♻️ 建议将提前返回移至检测之前
self.screenshot() + if self.target_type == LostVoidDetector.CLASS_INTERACT: + return self.round_success(LostVoidMoveByDet.STATUS_NEED_DETECT) + frame_result = self.ctx.lost_void.detect_to_go( self.last_screenshot, screenshot_time=self.last_screenshot_time, ignore_list=self.ignore_entry_list, ) - if self.target_type == LostVoidDetector.CLASS_INTERACT: - return self.round_success(LostVoidMoveByDet.STATUS_NEED_DETECT) - distance_result = self.ctx.lost_void.detector.get_result_by_x(frame_result, LostVoidDetector.CLASS_DISTANCE)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_move_by_det.py` around lines 633 - 635, In get_out_of_stuck, the CLASS_INTERACT branch in LostVoidMoveByDet is returning STATUS_NEED_DETECT after detect_to_go has already been called, so the detection result is wasted. Move the self.target_type == LostVoidDetector.CLASS_INTERACT check before the detect_to_go/frame_result work so this path exits early without performing unnecessary detection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.py`:
- Line 11: `LostVoidArtifact` 中的 `self.template_id` 类型注解与构造参数不一致;该字段实际允许为
`None`,但当前标注为 `str`。请在该类的初始化逻辑里将 `self.template_id` 的注解改为与 `template_id`
参数一致的可空类型(使用现代 `str | None` 写法),并确保同类中相关成员注解保持一致。
---
Nitpick comments:
In
`@src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_move_by_det.py`:
- Around line 633-635: In get_out_of_stuck, the CLASS_INTERACT branch in
LostVoidMoveByDet is returning STATUS_NEED_DETECT after detect_to_go has already
been called, so the detection result is wasted. Move the self.target_type ==
LostVoidDetector.CLASS_INTERACT check before the detect_to_go/frame_result work
so this path exits early without performing unnecessary detection.
🪄 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: 942b6a35-21f1-4910-9d91-7cb6bf5e994a
📒 Files selected for processing (4)
assets/game_data/hollow_zero/lost_void/lost_void_artifact_data.ymlsrc/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.pysrc/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.pysrc/zzz_od/application/hollow_zero/lost_void/operation/lost_void_move_by_det.py
69f73ed to
564e7b0
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py (1)
201-256: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff
try_fill_by_answer_fallback与try_fill_by_can_choose存在大量重复逻辑,建议抽取公共兜底方法。两者结构几乎一致:
range(12)轮询、截图、get_artifact_pos+get_effective_chosen_count提前返回、按中心点 40px 去重、点击 +fallback_click_count += 1+sleep(0.3)、循环后再复核。差异仅在候选筛选条件与日志文案。重复的 40px 阈值/12 轮次分散在多处,后续易发生不一致。可抽取一个以“筛选谓词 + 日志前缀”为参数的私有方法,两个兜底分别传入各自的过滤逻辑,减少维护面。
♻️ 抽取思路示例
def _fill_by_candidates( self, target_num: int, candidate_filter: Callable[[list[LostVoidArtifactPos]], list[LostVoidArtifactPos]], log_prefix: str, ) -> bool: tried_center_list: list[Point] = [] for _ in range(12): _, current_screen = self.ctx.controller.screenshot() can_choose_list, chosen_list = self.get_artifact_pos(current_screen) chosen_cnt = self.get_effective_chosen_count(current_screen, chosen_list, target_num) if chosen_cnt >= target_num: return True candidate_list = self.sort_candidates(candidate_filter(can_choose_list)) # ...去重、点击、计数(与现有实现一致)... # ...循环后复核... def try_fill_by_answer_fallback(self, target_num: int) -> bool: return self._fill_by_candidates( target_num, lambda items: [i for i in items if i.can_choose and i.artifact.category == '无详情' and i.artifact.is_answer_fallback], '答题兜底', )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py` around lines 201 - 256, `try_fill_by_answer_fallback` duplicates the same retry/screenshot/click/recheck flow already used in `try_fill_by_can_choose`; extract that shared logic into a private helper so only the candidate filter and log prefix differ. Move the repeated 12-iteration loop, 40px center de-duplication, click handling, `fallback_click_count` increment, sleep, and post-loop verification into a common method, and have both fallback methods delegate with their own filtering predicate and message text.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py`:
- Around line 201-256: `try_fill_by_answer_fallback` duplicates the same
retry/screenshot/click/recheck flow already used in `try_fill_by_can_choose`;
extract that shared logic into a private helper so only the candidate filter and
log prefix differ. Move the repeated 12-iteration loop, 40px center
de-duplication, click handling, `fallback_click_count` increment, sleep, and
post-loop verification into a common method, and have both fallback methods
delegate with their own filtering predicate and message text.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bd4fdfa4-a426-4958-9b91-144a0a6f6578
📒 Files selected for processing (3)
assets/game_data/hollow_zero/lost_void/lost_void_artifact_data.ymlsrc/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.pysrc/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py
🚧 Files skipped from review as they are similar to previous changes (2)
- src/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.py
- assets/game_data/hollow_zero/lost_void/lost_void_artifact_data.yml
问题
迷失之地通用选择统一后,无详情答题的正确答案没有再作为最终兜底参与决策,且相关决策日志不够整齐。
修复
is_answer_fallback标记测试
uv run ruff check src/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.py src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.pySummary by CodeRabbit
New Features
Bug Fixes