Investigations into Pathfinding

Investigations into Pathfinding

We are always listening to feedback about Age of Empires II: Definitive Edition and are eager to reveal a project we’ve been working to set up for some time.

We hear your concerns about pathfinding and are committed to addressing them. To accomplish this, we have set up a dedicated team to investigate pathing regressions, and we would like YOUR help in our investigation.

Working with a 20+ year old code base can be pretty difficult, and despite modernizing pieces of it, it’s easy for strange and unpredictable bugs to show up. Pathfinding bugs are particularly difficult to reproduce, as its often impossible to produce the exact same conditions seen in a report from our community.

We’re hoping to get your cooperation and participation, and most importantly your recorded games, to get to the bottom of this issue. With a recorded game, our engineering team can debug the behavior 1-1 as it happened in your game. It’s often difficult to exactly reproduce the behavior seen on videos, as so many variables are difficult to discern from a small clip. The level of specific detail we can get from your recorded games is invaluable to our teams and we’d love your cooperation.

While changes and improvements will take some time, we ALL are committed to making the pathfinding in Age of Empires II: Definitive Edition the best it can be.

Thank you for your love of our game, support, patience, and continuous feedback!

To ensure our teams are able to investigate the issues properly, please follow the format below to report an issue:

Time stamp : When did the unintended behavior happen?
What happened : Describe the situation with as much detail as possible?
Intended behavior : What should the units have done?
Recorded game : File or game link (please include recorded games)
Post a clip (optional) : Video clips are always a helpful addition to a recorded game.

Recorded games allow us to debug the behavior 1 to 1 as it happened in your game. It is often impossible to exactly reproduce the behavior seen on videos. If it is a public game, you can provide us a link to the match where we can download your recorded game.

7 Likes

red scout teleporting over palisade wall at around 17:40~

Pathfinding is pretty bad right now in AoE II and is even worse than III’s.
I am more than a III player, so that speaks much!

Any updates on this?

We are working on it. We can’t share a date of any major changes at this point.

1 Like

I’ve noticed a significant issue when melee units charge in formation and then retreat. Upon being recalled, instead of each unit individually turning around and moving back in formation, they first regroup near the center of their last engagement, forming a square. This often results in half the units unintentionally moving behind the enemy line, despite being ordered in the opposite direction. This behavior is highly detrimental and unrealistic.

Expected Behavior:
When a retreat is ordered, each unit should independently turn 180° and form a new formation based on their current positions. The new formation should be structured to minimize sorting distance (i.e., units on the right should not be reassigned to the left) and should reform at least a formation-height distance (preferably twice that) away from the current position. This would make the “Abort Charge” command both visually realistic and tactically effective in minimizing losses.

Looking at Viper’s streaming, maybe you can ask him the savegame.

Edit. Savegame: Match RF/RA - Age of Empires 2 - AoE2 Insights

Player units are being pushed when colliding with Gaia.

Savegame:
MP Replay v101.103.2359.0 @2025.03.01 214313 (1).aoe2record (2.6 MB). At around second 59 by Player 8. Right before the collision, I commanded the Villager to garrison, which caused it to turn 180° toward the Boar.

This behavior is observed not only between Villagers and Boars but also, for example, between Scouts and Sheep. It appears to be an issue with collision avoidance/resolution rather than a pathing problem.

Note I: Although a similar phenomenon occurs in real life, in a technical system like this game the possibilities for refinement are endless. Perhaps you could implement a mechanism where two units determine the collision resolution (e.g., agreeing on whether to rotate clockwise or counter-clockwise).

Note II: I noticed that this particular collision resolution converges to a perfect horizontal line and, if I remember correctly, it can also happen along a perfect vertical line. This might indicate the problematic section of the code.

1 Like

Here is another one.

What Happened:
During gameplay, I observed that my villagers are not taking the direct path to the nearest berry bushes. Instead, they unnecessarily route around my base walls to reach the back of the bushes. In one instance, multiple villagers got stuck at the berry bushes and then all rerouted around the walls, resulting in delays and exposing them to danger. In another case, a single villager, distracted by a passing archer, took an extended detour around the base and ended up getting shot.

Intended Behavior:
Villagers should path directly to the nearest berry bush using the most efficient route. To determine the closest bush, the pathfinding algorithm should evaluate all nearby bushes and select the one with the shortest route.

Recorded Game:
BerryPathing.aoe2record (2.2 MB)

Time Stamps:

  • 14:03
  • 17:54 at P8’s Base

Video Clips:

  • Clip A: Shows multiple villagers getting stuck at the berry bushes before rerouting around the walls.

  • Clip B: Shows a single villager, distracted by a passing archer, taking a longer route around the base and eventually getting shot.

Additional Notes:
This issue significantly affects gameplay by delaying resource gathering and increasing the risk of unit loss. Additionally, this bug also affects thinner woodlines — In other games, I’ve noticed many villagers suddenly chopping from the wrong side of the forest because of this issue.

Time stamp:
Approximately 16:06 in Player 7’s base

What happened:
During a raid with archers, AI-controlled villagers appear to ignore proper pathfinding and directly collide and get stuck with the Lumbercamp building. This behavior is only observed with AI-controlled villagers, as player-controlled villagers seem unaffected. It seems the evasive AI logic isn’t taking pathfinding fully into account—resulting in villagers retreating in a straight line toward their town center and bumping into the building.

Intended behavior:
Villagers should adhere to proper pathfinding rules when retreating. Instead of moving in a straight line, they should navigate around obstacles (like the Lumbercamp) and follow a more tactical retreat path away from enemy units, ensuring that collisions with buildings do not occur.

Recorded game:
AI_Problems.aoe2record (4.8 MB)

Videoclip:

Note:
It could also be that the two villagers are interfering with each other and the lumbercamp corner. This interference is difficult to diagnose without proper debugging tools (such as drawn pathing nodes).