fix: 增加模糊匹配,修复寻路节点前移问题#456
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 旨在改进地图节点判定的鲁棒性(增加“模糊匹配/阈值命中”思路以缓解移动过程中节点被过早前推),并在“决战”流程中更可靠地处理“船坞已满”这一战斗结果分支。
Changes:
- 调整
NodeTracker.update_node():引入射线命中阈值与回退选择策略,降低移动过程中的节点误判/前推概率。 - 在决战
_handle_combat()中识别ConditionFlag.DOCK_FULL并直接切换到DecisivePhase.DOCK_FULL,避免依赖战后短暂弹窗检测。 - 章节导航批量点击分支做了小幅代码整理(等价重构)。
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| autowsgr/ui/map/panels/sortie.py | 章节导航批量点击逻辑的小幅重构(保持行为一致)。 |
| autowsgr/ops/decisive/handlers.py | 决战战斗结束后基于战斗结果标志直接路由到 DOCK_FULL 阶段。 |
| autowsgr/combat/node_tracker.py | 节点判定引入射线命中阈值与回退策略,提升移动判定稳定性。 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # 将当前节点也作为候选,避免在移动途中被强制前推 | ||
| candidate_names = list(dict.fromkeys([self._current_node, *current_data.next_nodes])) | ||
|
|
||
| ray_hit_threshold = 0.01 |
There was a problem hiding this comment.
ray_hit_threshold = 0.01 是一个新引入的魔法数,且当前没有说明其单位/来源(节点坐标为 0~1 归一化)。建议将其提升为类常量或配置项(例如按地图/分辨率可调),并在注释中解释为何选择 0.01 以及该阈值对“命中/未命中”的预期影响。
Comment on lines
+480
to
+487
| _log.warning( | ||
| '[NodeTracker] 射线距离未命中阈值 (<{:.4f}),回退到最小射线距离选择', | ||
| ray_hit_threshold, | ||
| ) | ||
| best_node, best_ray_distance, best_euclidean_distance = min( | ||
| candidate_distances, | ||
| key=lambda item: (item[1], item[2]), | ||
| ) |
There was a problem hiding this comment.
这里在候选点都未满足 ray_hit_threshold 时使用 _log.warning,但 update_node() 会在战斗地图轮询中高频调用;如果“未命中阈值”是常态,会导致日志被 warning 淹没并影响排障信噪比。建议改为 debug/info,或增加节流(例如仅每 N 秒/每次节点变化最多记录一次),并把阈值/回退选择的上下文(当前节点、候选列表)放到 debug 里。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.