Skip to content

PathingBehavior stuck in recalc loop when terrain changes make path impossible #20

Description

@RiaDev1

Description

When the bot is following a path and the environment changes (blocks placed/destroyed by other players, mobs, or natural events), the path becomes invalid. PathingBehavior correctly cancels the invalid path and recalculates — but the new path may hit the SAME obstacle, creating a recalc loop where the bot continuously re-paths without making progress.

Root Cause

In PathingBehavior.tickPath():

if (current.failed() || current.finished()) {
    current = null;
    if (goal == null || goal.isInGoal(ctx.playerFeet())) {
        // ... goal reached
        return;
    }
    // ...
    synchronized (pathCalcLock) {
        if (inProgress != null) {
            queuePathEvent(PathEvent.PATH_FINISHED_NEXT_STILL_CALCULATING);
            return;
        }
        queuePathEvent(PathEvent.CALC_STARTED);
        findPathInNewThread(expectedSegmentStart, true, context);
    }
    return;
}

findPathInNewThread starts a fresh path calculation from expectedSegmentStart, but there's no cooldown or backoff between recalculations. If the pathfinder repeatedly produces the same broken path, the bot enters a tight loop of: current.failed() → recalculation → same path → failure.

Expected Behavior

  1. Implement exponential backoff: wait longer between each consecutive path recalculation
  2. Track the number of consecutive path failures and escalate (e.g. fall back to explore mode after N failures)
  3. When path fails at the same position repeatedly, mark that position as temporarily avoided

Suggested Fix

Add a consecutivePathFailures counter and a backoff timer in PathingBehavior. After ~5 consecutive failures from the same position, switch to explore/wander mode instead of re-pathing.

Related

  • shredder/src/main/java/baritone/behavior/PathingBehavior.java
  • PathExecutor.failed() — triggers the recalc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions