Skip to content

Commit 77a4dcc

Browse files
andy5995claude
andcommitted
fix: Suppress bestClosedNode oscillation during exploratory retry cooldown
When normal A* exhausts its node budget and triggers an exploratory retry, a short partial path is built toward the goal. Once that path is consumed (typically in 1-2 frames), the next A* call during the cooldown window previously fell through to bestClosedNode, which pointed in a different direction (toward open space), causing visible 1-tile back-and-forth oscillation in congested narrow corridors. Now, when we are still in cooldown for the same destination, we return tsBlocked instead of emitting a bestClosedNode path. The unit waits until the cooldown expires and a fresh exploratory retry fires. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a92d697 commit 77a4dcc

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

source/glest_game/ai/path_finder.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,17 @@ TravelState PathFinder::aStar(Unit *unit, const Vec2i &targetPos, bool inBailout
856856
}
857857

858858
return aStar(unit, targetPos, false, frameIndex, pathFindNodesExploratoryMax, nullptr, 0.25f, true);
859+
} else if (unit->getLastPathfindFailedPos() == finalPos) {
860+
// Still in cooldown for this destination. Using bestClosedNode
861+
// here would give a partial path in the wrong direction (toward
862+
// open space rather than around the obstacle), causing visible
863+
// back-and-forth oscillation. Return tsBlocked so the unit
864+
// waits until the cooldown expires and a fresh exploratory retry
865+
// can fire.
866+
if (frameIndex < 0) {
867+
path->incBlockCount();
868+
}
869+
return tsBlocked;
859870
}
860871
}
861872
} else {

0 commit comments

Comments
 (0)