Skip to content

Record last "line guess" at the end of navigation link with segmentation#10

Open
Egezenn wants to merge 1 commit into
Silkroad-Developer-Community:mainfrom
Egezenn:pathing-line-issue
Open

Record last "line guess" at the end of navigation link with segmentation#10
Egezenn wants to merge 1 commit into
Silkroad-Developer-Community:mainfrom
Egezenn:pathing-line-issue

Conversation

@Egezenn
Copy link
Copy Markdown
Member

@Egezenn Egezenn commented May 7, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

NavigationManager extends navigation caching by storing computed target positions separately. During path calculation, both the semantic-node path and target position are cached. Script generation uses this cached position to emit optimized movement commands with conditional branching: teleport commands when appropriate, or interpolated move segments when distance exceeds 50 units. Filenames now follow a dynamic timestamp format.

Changes

Target-Based Movement Generation

Layer / File(s) Summary
Target Position Caching
Botbases/RSBot.Training/Bot/NavigationManager.cs
Introduces _targetPosition field to cache the computed training-area position, populated during path calculation alongside _activePath.
Script Generation and Movement Commands
Botbases/RSBot.Training/Bot/NavigationManager.cs
GenerateRBSFile reads the cached target position and generates movement commands via AddMoveCommands: interpolates distances >50 into multiple segments, skips negligible (<1) distances, and uses dynamic filename format. Script ends by moving to the cached target position.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through fields of code,
Where paths are cached and targets glow,
Interpolated steps, no more than fifty feet,
Our navigation dance is now complete! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions 'line guess' and 'navigation link with segmentation', but the actual changes focus on caching target positions, interpolating movement segments, and changing filename generation—not recording a 'line guess'. Revise the title to accurately reflect the main changes: caching target positions, interpolating long moves into segments, or changing movement command generation logic.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 `@Botbases/RSBot.Training/Bot/NavigationManager.cs`:
- Around line 259-265: Remove the forced full GC call after storing the new
path: inside the lock that updates _activePath and _targetPosition and clears
_linkage (protected by _linkageLock), delete the GC.Collect() invocation so the
runtime can perform collection naturally; leaving the existing assignment
_linkage = null is sufficient to allow reclamation without pausing the bot
thread.
- Around line 476-487: The generated interpolated waypoints always use
start.Region, so moves that cross regions end up targeting the wrong region;
update the waypoint region when building interpolatedPos in the loop (e.g.
choose end.Region for the final segment or determine the correct region based on
the interpolated coordinates) so the rbsLines.Add string uses the correct region
for each interpolatedPos (refer to Position, start, end, interpolatedPos,
segments, and rbsLines.Add to locate and change the code).
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 48328f4f-546d-4c00-a8ae-913155fe90c9

📥 Commits

Reviewing files that changed from the base of the PR and between 23c1922 and ee7477b.

📒 Files selected for processing (1)
  • Botbases/RSBot.Training/Bot/NavigationManager.cs

Comment on lines 259 to 265
lock (_linkageLock)
{
_activePath = path;
_targetPosition = targetPos;
_linkage = null; // Clear linkage data once path is cached to save memory
}
GC.Collect();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove the forced full GC from path calculation.

GC.Collect() here runs on every successful path build, which can pause the bot thread and usually will not reclaim the linkage graph yet because this method still has live references to it. Clearing _linkage is enough; let the runtime collect naturally.

Suggested change
         lock (_linkageLock)
         {
             _activePath = path;
             _targetPosition = targetPos;
             _linkage = null; // Clear linkage data once path is cached to save memory
         }
-        GC.Collect();
 
         return true;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
lock (_linkageLock)
{
_activePath = path;
_targetPosition = targetPos;
_linkage = null; // Clear linkage data once path is cached to save memory
}
GC.Collect();
lock (_linkageLock)
{
_activePath = path;
_targetPosition = targetPos;
_linkage = null; // Clear linkage data once path is cached to save memory
}
return true;
🤖 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 `@Botbases/RSBot.Training/Bot/NavigationManager.cs` around lines 259 - 265,
Remove the forced full GC call after storing the new path: inside the lock that
updates _activePath and _targetPosition and clears _linkage (protected by
_linkageLock), delete the GC.Collect() invocation so the runtime can perform
collection naturally; leaving the existing assignment _linkage = null is
sufficient to allow reclamation without pausing the bot thread.

Comment on lines +476 to +487
var segments = (int)Math.Ceiling(distance / 50.0);
for (var i = 1; i <= segments; i++)
{
var t = (float)i / segments;
var x = start.X + (end.X - start.X) * t;
var y = start.Y + (end.Y - start.Y) * t;
var z = start.ZOffset + (end.ZOffset - start.ZOffset) * t;

var interpolatedPos = new Position(x, y, start.Region) { ZOffset = z };
rbsLines.Add(
$"move {interpolatedPos.XOffset} {interpolatedPos.YOffset} {interpolatedPos.ZOffset} {interpolatedPos.Region.X} {interpolatedPos.Region.Y}"
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't segment moves across region boundaries.

Line 484 builds every interpolated waypoint with start.Region, so a long move that crosses into another region never emits end.Region. The last generated move still targets the source region, which can make the final hop wrong or unreachable.

Suggested guard
     private static void AddMoveCommands(List<string> rbsLines, Position start, Position end)
     {
         var distance = start.DistanceTo(end);
         if (distance < 1)
             return;
 
+        if (start.Region.X != end.Region.X || start.Region.Y != end.Region.Y)
+        {
+            rbsLines.Add($"move {end.XOffset} {end.YOffset} {end.ZOffset} {end.Region.X} {end.Region.Y}");
+            return;
+        }
+
         if (distance <= 50)
         {
             rbsLines.Add($"move {end.XOffset} {end.YOffset} {end.ZOffset} {end.Region.X} {end.Region.Y}");
             return;
         }
🤖 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 `@Botbases/RSBot.Training/Bot/NavigationManager.cs` around lines 476 - 487, The
generated interpolated waypoints always use start.Region, so moves that cross
regions end up targeting the wrong region; update the waypoint region when
building interpolatedPos in the loop (e.g. choose end.Region for the final
segment or determine the correct region based on the interpolated coordinates)
so the rbsLines.Add string uses the correct region for each interpolatedPos
(refer to Position, start, end, interpolatedPos, segments, and rbsLines.Add to
locate and change the code).

Egezenn added a commit to Silkroad-Developer-Community/ROADMAP that referenced this pull request May 21, 2026
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.

1 participant