Skip to content

fix: 优化迷失之地无详情通用选择的决策 - #2469

Merged
ShadowLemoon merged 2 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/lost-void-common-choice-fallback
Jul 11, 2026
Merged

fix: 优化迷失之地无详情通用选择的决策#2469
ShadowLemoon merged 2 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/lost-void-common-choice-fallback

Conversation

@kawayiYokami

@kawayiYokami kawayiYokami commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

问题

迷失之地通用选择统一后,无详情答题的正确答案没有再作为最终兜底参与决策,且相关决策日志不够整齐。

修复

  • 为无详情答题正确答案增加 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.py

Summary by CodeRabbit

  • New Features

    • 在藏品选择流程中新增了自动补选兜底,目标数量不足时会继续尝试补齐,提升选择成功率。
  • Bug Fixes

    • 优化了选择失败后的回退处理,减少因识别不完整导致的漏选问题。
    • 改进了标题与数量识别的稳定性,提升了整体选择流程的可靠性。

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db29f0d0-2bb3-4941-a8f4-8a8b6ebfcc20

📥 Commits

Reviewing files that changed from the base of the PR and between 564e7b0 and 8c4ed1d.

📒 Files selected for processing (2)
  • 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.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py

📝 Walkthrough

Walkthrough

本PR为迷失之地藏品选择流程新增"答题兜底"补选逻辑,在常规层选择未达目标数量时尝试点击无详情候选补足数量;同时重构多处选择决策与OCR识别相关日志文案,并将LostVoidArtifact的template_id类型改为str | None。

Changes

答题兜底选择策略

Layer / File(s) Summary
类型注解调整
src/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.py
template_id参数与字段类型由Optional[str]改为str | None,移除对应typing导入。
导入调整与选择概览日志
src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py
清理未使用的Optionalgt导入,更新导入格式;选择概览日志改为结构化"选择决策 | 概览"格式。
答题兜底方法实现与接入
src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py
新增try_fill_by_answer_fallback方法,在常规层选择无候选时循环截图识别并点击无详情候选补足数量;choose_artifactselect_by_layers接入该兜底分支;has_priority_rule简化为直接返回布尔表达式。
其余兜底路径与OCR识别调整
src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_choose_common.py
重写盲点兜底两阶段日志与失败收口;更新try_fill_by_can_choose成功/失败日志文案;调整OCR结果遍历方式;重构可选/已选识别日志及标题判定分支合并与日志文案。

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: 是否达到目标数量
Loading

Possibly related PRs

Suggested reviewers: Usagi-wusaqi

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.48% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题与本次变更一致,准确概括了迷失之地无详情通用选择决策与兜底逻辑的优化。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kawayiYokami kawayiYokami changed the title fix: improve lost void common choice fallback fix: 优化迷失之地无详情通用选择的决策 Jul 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_stuckCLASS_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

📥 Commits

Reviewing files that changed from the base of the PR and between 350ec4c and 69f73ed.

📒 Files selected for processing (4)
  • assets/game_data/hollow_zero/lost_void/lost_void_artifact_data.yml
  • 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.py
  • src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_move_by_det.py

Comment thread src/zzz_od/application/hollow_zero/lost_void/context/lost_void_artifact.py Outdated
@kawayiYokami
kawayiYokami force-pushed the fix/lost-void-common-choice-fallback branch from 69f73ed to 564e7b0 Compare July 9, 2026 12:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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_fallbacktry_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

📥 Commits

Reviewing files that changed from the base of the PR and between 69f73ed and 564e7b0.

📒 Files selected for processing (3)
  • assets/game_data/hollow_zero/lost_void/lost_void_artifact_data.yml
  • 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.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

@ShadowLemoon
ShadowLemoon merged commit 0213600 into OneDragon-Anything:main Jul 11, 2026
8 checks passed
@kawayiYokami
kawayiYokami deleted the fix/lost-void-common-choice-fallback branch July 11, 2026 16:33
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants