Skip to content

Refactor/map improvements#39

Open
mCodex wants to merge 21 commits intofeat/v4from
refactor/mapImprovements
Open

Refactor/map improvements#39
mCodex wants to merge 21 commits intofeat/v4from
refactor/mapImprovements

Conversation

@mCodex
Copy link
Owner

@mCodex mCodex commented Mar 13, 2026

This pull request introduces significant improvements to the CaveBot waypoint navigation and walking system, focusing on smoother movement through waypoints, more robust handling of floor changes, and improved stuck detection and recovery logic. The changes implement a "Pure Pursuit" lookahead strategy for walking, refine how the bot handles intentional versus accidental floor changes, and enhance blacklist and rescue logic for unreachable waypoints. Additionally, walking precision and stuck detection have been tuned for better reliability in complex map scenarios.

Waypoint Navigation and Walking Improvements:

  • Implemented Pure Pursuit lookahead in goto actions: the bot now targets a point ahead on the route for smoother, uninterrupted movement, with fallbacks for floor changes and blocked paths. [1] [2]
  • Adjusted walking precision: keyboard step threshold reduced for more precise control near waypoints, and pathfinding now prefers exact directions with better fallback handling. [1] [2]

Stuck Detection and Timeout Adjustments:

  • Increased soft timeout and progress thresholds to accommodate longer, winding paths that may appear close in straight-line distance but take longer to traverse, reducing premature stuck detection. [1] [2] [3]

Floor Change and Recovery Logic:

  • Enhanced floor change handling: distinguishes between intentional and accidental floor transitions, clears blacklists appropriately, and avoids infinite loops on stairways.
  • Improved rescue logic: ensures blacklisted and mismatched-floor waypoints are properly skipped only when they form trailing rescue blocks, supporting both multi-floor and rescue waypoint routes. [1] [2]

Blacklist and Recovery State Management:

  • Reduced the recovery idle timeout to 12 seconds for faster clearing of blacklists when all waypoints are exhausted, and ensured blacklists are cleared on full engine reset. [1] [2] [3]

Other Minor Changes:

  • Added hunt_context to the analytics tools category.
  • Fixed a UI bug in AttackBot.lua for item ID display.

These changes collectively make waypoint navigation smoother, more robust to edge cases, and less likely to get stuck, especially in complex or multi-floor cave routes.

mCodex added 18 commits March 10, 2026 16:51
feat(actions): implement Pure Pursuit lookahead for smoother waypoint navigation
- Replace single-panel text dump with 4-tab layout (Live Monsters,
  Patterns, Combat Stats, Scenario) — 560x500 window
- Fix root cause of Patterns always showing None: inspector now reads
  MonsterAI.Patterns.knownMonsters (in-memory, always populated by
  persist()) as primary source, merging UnifiedStorage for cross-session
  entries. Storage-not-ready no longer silently drops all pattern data.
- Add switchTab() with teal highlight on active button, hides inactive
  panels and scrollbars
- refreshActiveTab() dispatches to the correct tab builder, throttled
  at 2500ms, reset correctly on manual Refresh and tab switch
- EventBus monsterai:state_updated auto-refresh retained
…t mid-route stops

When Pure Pursuit selects a lookahead waypoint, the regression detector was
tracking progress toward the original destPos instead of the actual walk target.
As the player moved past destPos toward the lookahead, curDist increased and
triggered the stuck-detection logic, stopping autoWalk mid-route.

Pass walkTarget (lookahead or destPos when fallback) to setWalkingToWaypoint
so the detector measures movement toward where the walk is actually headed.
… layout

monster_inspector.lua:
- Add 3s schedule-based live update loop (startLiveUpdate/stopLiveUpdate) so
  the window refreshes even when monsterai:state_updated never fires (e.g.
  TargetBot is off or no wave attacks occur)
- Add direct g_map.getSpectatorsInRange fallback in buildLiveTab() so Tab 1
  always shows nearby creatures even when MonsterAI.Tracker is inactive
- Reset lastRefreshMs=0 on manual Refresh click and on window show so the
  2500ms throttle never silently blocks the first visible refresh
- startLiveUpdate on window show, stopLiveUpdate on hide

smart_hunt.otui:
- Replace single-panel HuntAnalyzerWindow with 4-tab layout mirroring
  monster_inspector.otui: Session / Consumption / Loot & Combat / Insights

smart_hunt.lua:
- Add buildSessionTab / buildConsumptionTab / buildLootCombatTab /
  buildInsightsTab extracting content from buildSummary() per tab
- Rewrite showAnalytics() / doLiveUpdate() to drive the new tabbed window
  using haFindChild / haUpdateWidgetRefs / haSwitchTab pattern
- Simplify Monster Insights button to delegate to toggleWindow()
…vent blacklisted waypoints from being processed
…sing for intentional and accidental floor transitions
…n and improve fallback to smoothed direction
Copilot AI review requested due to automatic review settings March 13, 2026 11:38
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2365f29-7342-426d-92dc-8f979549eee9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/mapImprovements
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors and extends navigation/walking and TargetBot analytics/UI to improve smooth waypoint traversal (Pure Pursuit lookahead), make recovery behavior more robust across floor changes, and connect hunt analytics to target priority scoring.

Changes:

  • Added Pure Pursuit lookahead targeting for goto, plus tuned walking precision and stuck/timeout heuristics for winding routes.
  • Refactored MonsterAI TargetBot integration to delegate scoring to PriorityEngine, added HuntContext bridge signal, and revamped Monster Inspector + Hunt Analyzer UIs into tabbed layouts.
  • Improved floor-change handling, blacklist reset semantics, and some UI/runtime safety checks.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
utils/waypoint_navigator.lua Prevents wrap-around route segments when last goto is a floor-change tile to avoid backwards Pure Pursuit aims.
cavebot/actions.lua Uses navigator lookahead target for smoother goto walking with reachability/stair guards.
cavebot/walking.lua Tighter keyboard-step threshold and direction preference for close-range precision.
cavebot/cavebot.lua Adjusted stuck detection/timeout logic; refined floor-change intent handling; updated recovery/blacklist behavior.
targetbot/priority_engine.lua Adds HuntContext-based score component into the unified priority calculation.
targetbot/monster_tbi.lua Large refactor: removes duplicated priority logic and delegates to PriorityEngine; updates danger/debug/EventBus wiring.
core/hunt_context.lua New analytics→priority bridge module producing a cached normalized “hunt signal”.
core/smart_hunt.lua / core/smart_hunt.otui Refactors Hunt Analyzer UI into tabs and exposes metrics for HuntContext.
targetbot/monster_inspector.lua / targetbot/monster_inspector.otui Refactors Monster Inspector into tabbed UI and event-driven/live-refresh flow.
targetbot/monster_patterns.lua Skips persisting empty/unknown monster names.
targetbot/monster_ai.lua Consolidates safe-creature helpers into core helpers; improves projectile source attribution; adds state checksum event gating.
core/AttackBot.lua Guards item-id widget access to avoid nil indexing.
_Loader.lua Adds hunt_context to analytics load category.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +186 to +188
local cfg = TBI._defaultConfig
local pri = PriorityEngine and PriorityEngine.calculate(creature, cfg, nil) or 0
callback(pri)
Comment on lines +110 to +113
threats[#threats+1] = {
name = safeCreatureCall(cr, "getName", "unknown"),
level = tl,
imminent = td and td.wavePredicted or false,
local function findChild(parent, id)
if not parent or not id then return nil end
local ok, w = pcall(function() return parent[id] end)
if ok and w then return w end
print("[CaveBot] Z-change (" .. lastPlayerFloor .. "→" .. playerPos.z .. "): stair at WP" .. (focusedIdx or "?") .. ", advancing via Z-mismatch guard")
else
-- Accidental floor change: reset fully and snap to nearest same-floor WP.
clearWaypointBlacklist()
targets[#targets+1] = { creature = cr, priority = pri, distance = d,
breakdown = bk, id = safeGetId(cr), name = safeCreatureCall(cr, "getName", "unknown") }
if d <= maxRange then
local pri = PriorityEngine.calculate(cr, cfg, nil)
mCodex added 3 commits March 13, 2026 08:58
- Implement oscillation and stuck detection in the goto action to prevent looping without progress.
- Refactor waypoint handling to improve recovery from accidental floor changes and corridor breaches.
- Adjust combat constants for reaffirmation retries and engagement backoff to optimize attack behavior.
- Improve reachability checks for creatures, including dynamic cooldown adjustments based on previous reachability.
- Enhance pathfinding logic to ensure smoother navigation through obstacles and better handling of floor changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants