Skip to content

fix(lost_void): 按六级优先级模型修复放弃组拦截与刷新时机 - #2649

Open
kawayiYokami wants to merge 6 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/lost_void-priority-abandon-group
Open

fix(lost_void): 按六级优先级模型修复放弃组拦截与刷新时机#2649
kawayiYokami wants to merge 6 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/lost_void-priority-abandon-group

Conversation

@kawayiYokami

@kawayiYokami kawayiYokami commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

遇到的问题

迷失之地邦布商店里,协战武备选了「击破」,优先级里也有「击破」,商店货架上有 [异常·击破] 藏品,但脚本不买,直接点了刷新。

日志只显示「识别藏品 → 返回状态 按钮-刷新-可用」,中间为什么没买完全不可见。

根因(三层)

  1. 放弃组错误否决优先级get_artifact_by_priority 匹配阶段有个检查——规则分类命中动态放弃组且规则为纯分类(无空格)时,整条规则跳过。放弃组由 append_agent_type_priority 生成:队伍里没有击破类型角色 → 把「击破」写进放弃组。而协战武备属性(击破)是第四个位置,根本不参与这个检查——于是协战自己选的属性,被放弃组当成「没人用的类型」记下了。商店里即使有击破藏品,规则被跳过 → priority_list 为空 → 刷新。
  2. 优先级层级混乱:原代码把「动态优先级 + 战斗组」合并成第一优先级(final_priority_list_1 = dynamic + artifact_priority_in_battle),且 artifact_priority_in_battle 的 getter 初始 copy() 了配置第一优先级——用户配置和战斗组混成一级。
  3. 放弃组兜底从未生效:补位阶段用精确 in 匹配放弃组,但放弃组存的是代理人类型值(「击破」),藏品分类是「异常·击破」——永远匹配不上,放弃组的兜底排序实际是空转。

解决思路

按用户确认的六级优先级模型统一:

级别 来源
1 dynamic_priority_list(动态)
2 artifact_priority(配置一)
3 artifact_priority_2(配置二)
4 artifact_priority_in_battle(战斗组)
5 其他(非优先级)补位
6 放弃组 最后补位
  • 删除匹配阶段的放弃组拦截:有优先级命中就买,放弃组只在兜底补位排序时生效
  • 战斗组 getter 不再 copy 配置一,只承载协战武备属性
  • 补位阶段改用归一化匹配(_is_category_match),「异常·击破」↔「击破」能正确命中
  • 刷新放开时机:到达第 3 轮(refresh_times >= buy_only_priority_2 - 1)放开 3~6 级,三次刷新内只选 1、2 级
  • 参数映射全局唯一:consider_priority_1→放行 1、2 级,consider_priority_2→放行 3、4 级,consider_not_in_priority→放行 5、6 级

实测结果

已实测(测试者反馈):效果很好很流畅

  • 修复前:商店有击破藏品却不买,直接刷新
  • 修复后:按优先级正常购买,三次刷新内严格只选前两级,超过后逐级放开
  • 全量测试:迷失之地相关 121 个测试通过,ruff 无新增告警

预期日志

规则只在第 1 轮和放行状态变化轮打印,每轮结果一目了然:

[INFO] 邦布商店 第1轮 | 规则 | 第2级(配置一)=蜜瓜,简 第4级(战斗组)=击破,维琳娜 放弃组=击破
[INFO] 优先级决策 | 候选=2(主选=2 次选=0) 需选=1 | 放行=...
[INFO] 邦布商店 第1轮 | 结果 | 购买 [异常·击破]溶剂弹射枪
[INFO] 邦布商店 第2轮 | 结果 | 未选中可购买藏品 下一步=刷新
[INFO] 邦布商店 第3轮 | 规则 | ...(状态变了才再打一次)
[INFO] 邦布商店 第3轮 | 结果 | 购买 xxx

debug 级保留匹配明细(按级别汇总,不逐条刷屏)。

测试

测试仓配对提交:zzz-od-testtest_get_artifact_by_priority.py 新增 3 个用例:

  • 优先级命中且分类在放弃组 → 仍购买
  • 放弃组只作用于兜底补位阶段
  • 配置一(第 2 级)优先于战斗组(第 4 级)

本 PR 由 fairy(绝区零的 AI)撰写,欢迎 @joshcai 实测体验。


测试仓配对 PR:OneDragon-Anything/zzz-od-test#43

Summary by CodeRabbit

  • 改进

    • 优化藏品分类识别,完整保留分类文本并统一归一化处理。
    • 优化藏品优先级选择,按六级规则依次匹配,并支持动态放弃组补位。
    • 统一战斗中的优先级放行规则,避免误选常规及战斗优先级藏品。
  • 配置

    • 合并购买设置为“x次内只买高优先级”。
    • 更新相关示例配置及默认放行次数。
  • 日志

    • 新增优先级命中、候选补位、购买结果及最终选择状态日志。

- 优先级顺序统一为:动态 > 配置一 > 配置二 > 战斗组 > 其他 > 放弃组
- 删除匹配阶段放弃组拦截,放弃组只作用于兜底补位排序
- 战斗组 getter 不再复制配置一,只承载协战武备属性
- 补位阶段放弃组改用归一化匹配,修复异常·击破匹配不上的问题
- 邦布商店第3、4级按 buy_only_priority_2 放开,三次刷新内只选前两级
- 新增状态机日志:info 按候选/级别匹配/主选组/次选组/结果打点
- 刷新放开时机修正为到达第3轮即放开(refresh_times >= buy_only_priority_2 - 1)
- 规则日志只在第1轮和放行状态变化轮打印, 不再逐轮刷屏
- 匹配明细改为按级别汇总的debug日志, 不再逐条规则输出
- 邦布商店结果日志带轮次: 购买/未选中下一步动作一目了然
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e62b41a2-5e21-4a91-8595-b7e88dd4ffd2

📥 Commits

Reviewing files that changed from the base of the PR and between e297a7c and 389ad8e.

📒 Files selected for processing (1)
  • src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py

📝 Walkthrough

Walkthrough

本次变更重构 Lost Void 藏品的六级优先级选择流程,并同步调整配置界面、商店放行规则、优先级日志和动态放弃组保护逻辑。

Changes

Lost Void 藏品优先级

Layer / File(s) Summary
构建六级优先级模型
src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py, src/zzz_od/application/hollow_zero/lost_void/lost_void_challenge_config.py, src/zzz_od/gui/view/hollow_zero/lost_void_challenge_config_interface.py, config/lost_void_challenge/*.sample.yml
运行时战斗优先级初始化为空列表。配置界面合并两个购买设置。示例配置移除 buy_only_priority_1,并将 buy_only_priority_2 默认值调整为 3。上下文保留完整 OCR 分类文本,并构建六级选择规则。
逐级匹配与最终选择
src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py
候选按优先级逐级匹配。动态放弃组使用分类归一化匹配,并作为最后补位。流程记录规则命中、候选为空、规则未命中和最终选择结果。
商店筛选与放弃组保护
src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_bangboo_store.py, src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py
商店统一使用 buy_only_priority_2 - 1 控制配置二和非优先级藏品放行。商店新增规则、刷新和购买结果日志。动态放弃组同时保护普通及战斗优先级藏品分类。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LostVoidChallengeConfigInterface
  participant LostVoidChallengeConfig
  participant LostVoidContext
  participant BangbooStore
  LostVoidChallengeConfigInterface->>LostVoidChallengeConfig: 更新 buy_only_priority_2
  LostVoidChallengeConfig->>LostVoidContext: 提供运行时优先级配置
  LostVoidContext->>LostVoidContext: 逐级匹配并选择藏品
  LostVoidContext-->>BangbooStore: 提供当前优先级规则
  BangbooStore->>BangbooStore: 按刷新次数筛选可购买藏品
  BangbooStore-->>BangbooStore: 记录筛选和购买结果
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 57.14% 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.

@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: 2

🤖 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_context.py`:
- Around line 720-750: 修正 `priority_levels` 为空时的强制补位判断:改为检查
`dynamic_priority_list`、`challenge_config.artifact_priority`、`challenge_config.artifact_priority_2`
和 `challenge_config.artifact_priority_in_battle` 四个原始配置列表是否全部为空,只有全部为空时才将
`consider_not_in_priority` 设为 True;不要依据受
`consider_priority_1`/`consider_priority_2` 门控后的 `priority_levels` 判断。

In
`@src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_bangboo_store.py`:
- Around line 100-110: 统一处理已废弃的 buy_only_priority_1 配置:要么从
lost_void_challenge_config_interface.py 及相关配置定义中移除该设置及其 UI
入口,要么在空铁商店购买选择逻辑中恢复其业务作用,确保用户调整该配置实际影响优先级判断;保留现有 buy_only_priority_2 的处理不变。
🪄 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 Plus

Run ID: 4efeb56c-0ab0-42f9-af08-429ccb4c5ea9

📥 Commits

Reviewing files that changed from the base of the PR and between ae00153 and 1588d6d.

📒 Files selected for processing (4)
  • src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py
  • src/zzz_od/application/hollow_zero/lost_void/lost_void_challenge_config.py
  • src/zzz_od/application/hollow_zero/lost_void/operation/interact/lost_void_bangboo_store.py
  • src/zzz_od/application/hollow_zero/lost_void/operation/lost_void_run_level.py

- 强制补位改看四个原始配置列表是否全空,不再依据门控后的 priority_levels
  (门控可能因轮次放行限制挡住有内容的配置,导致前几轮误开补位)
- 删除已废弃的 buy_only_priority_1 配置与 UI 入口
- UI 合并为单个「x次内只买高优先级」配置,同步清理 sample 模板
@kawayiYokami

Copy link
Copy Markdown
Contributor Author

已按 review 修复,提交 993ceec

  1. 强制补位判断修正(lost_void_context.py):不再依据门控后的 priority_levels 判断是否强制补位,改为检查 dynamic_priority_list / artifact_priority / artifact_priority_2 / artifact_priority_in_battle 四个原始配置列表是否全部为空,只有全空才打开 consider_not_in_priority。此前门控(如邦布商店前两轮 consider_priority_2=False)可能挡住有内容的配置,导致 priority_levels 为空而误开补位,前几轮就直接买非优先级藏品。

  2. 废弃配置清理(lost_void_challenge_config.py + lost_void_challenge_config_interface.py + sample 模板):删除已无业务作用的 buy_only_priority_1 配置定义、UI 入口与 sample 模板条目;UI 合并为单个「x次内只买高优先级」配置(复用 buy_only_priority_2 字段),刷新边界逻辑不变。

验证:迷失之地 118 测试通过(3 skipped),ruff 仅既有 % 格式化告警(非本次改动)。

@kawayiYokami

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

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/context/lost_void_context.py (1)

820-826: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

保留不含 : 的 OCR 分类完整文本。

_create_artifact_from_ocr_text 在分类不含 : 时取前两个字符;若 OCR 返回 [异常·击破]...artifact.category 会变成 异常,与动态放弃组的 击破 无法通过归一化匹配命中。对 raw_category 应先完整保留分类文本,再在匹配侧归一化处理。

🤖 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/context/lost_void_context.py`
around lines 820 - 826, Update _create_artifact_from_ocr_text so raw_category
values without ":" retain the complete OCR category text instead of truncating
to the first two characters; keep normalization in _is_category_match and
preserve the existing matching behavior for colon-delimited categories.
🤖 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.

Outside diff comments:
In `@src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py`:
- Around line 820-826: Update _create_artifact_from_ocr_text so raw_category
values without ":" retain the complete OCR category text instead of truncating
to the first two characters; keep normalization in _is_category_match and
preserve the existing matching behavior for colon-delimited categories.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c0453e09-688d-4c24-8e55-ce296a9a940e

📥 Commits

Reviewing files that changed from the base of the PR and between 1588d6d and 993ceec.

📒 Files selected for processing (6)
  • config/lost_void_challenge/parameter_template.sample.yml
  • config/lost_void_challenge/异常·击破.sample.yml
  • config/lost_void_challenge/默认-成就模式.sample.yml
  • src/zzz_od/application/hollow_zero/lost_void/context/lost_void_context.py
  • src/zzz_od/application/hollow_zero/lost_void/lost_void_challenge_config.py
  • src/zzz_od/gui/view/hollow_zero/lost_void_challenge_config_interface.py
💤 Files with no reviewable changes (3)
  • config/lost_void_challenge/默认-成就模式.sample.yml
  • config/lost_void_challenge/异常·击破.sample.yml
  • src/zzz_od/application/hollow_zero/lost_void/lost_void_challenge_config.py

- sample 模板 buy_only_priority_2 从 1 改回 3(1 代入公式会第 1 轮全放开,约束失效)
- 同步修正注释:到达第 x 轮(已刷新 x-1 次)后放开第 3~6 级
- 成就-空洞金融大亨/绝境 sample 的死键 buy_only_priority 统一为 buy_only_priority_2: 3
- 删除无绑定且引用不存在属性的死代码 _on_buy_only_priority_changed
- 修正六级模型注释:主选组整体优先于次选组,级别序组内生效
@kawayiYokami

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

_create_artifact_from_ocr_text 对无冒号分类取前两字,会把「异常·击破」
截成「异常」、「射吸式焊炬」截成「射吸」,与数据侧完整分类不一致,
多字分类时放弃组/优先级规则匹配不上。改为保留完整分类文本,由
_is_category_match 归一化处理。
@kawayiYokami

Copy link
Copy Markdown
Contributor Author

已修复 diff 外评论(OCR 分类截断),提交 389ad8e

问题验证:_create_artifact_from_ocr_text 对无冒号分类取 raw_category[:2],会把「异常·击破」截成「异常」、「射吸式焊炬」截成「射吸」。实测「异常」vs 放弃组「击破」碰巧能匹配(击破归一化为异常击破,异常是其子串),但换「异常·强攻」截成「异常」、放弃组「强攻」就匹配不上——多字分类信息丢失是真实缺陷,与数据侧 yml 完整分类不一致。

修复:无冒号时保留完整分类文本,由 _is_category_match 归一化处理;冒号分隔(如「击破: 叩击」)逻辑不变。

验证:迷失之地 118 测试通过,ruff 无告警。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-branch 合入 test 分支

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants