I watched a battle replay, and twice in the same battle the Juggernaught AI got stuck in the same way. Here is what happened. The defender had put single layer walls around each cannon. The juggernaught decided to attack the cannon, but had to break through the wall first. My gunners killed the cannon before the juggernaught finished the wall, but the juggernaught kept attacking the wall until it broke. The AI would ideally recognize that the original target was gone and would abandon attacking the wall once the cannon was destroyed.
Troops* will not change targets once they start attacking one (walls for example) unless they are hit with splash damage. If they get hit with a mortar or mine, they will find the new closest/best target when they calculate how they should be walking (usually the same target, but it can change), but they don't compare targets unless they need to start walking somewhere. *except for ones that prioritize defenses, if they're attacked while attacking a non-defense structure
But it would be nice if they didn't (unless I'm defending). When only one troop locks onto a high level wall, that clock can sure run down quickly.
Even though this is a correct statement as the AI currently is programmed. It might be worthwhile to upgrade the AI to take into account the situation OP described. I'm especially frustrated with AI of HG locking onto a wall when he could simply walk around. Anyway, my point is just because the AI is dumb now doesn't mean it shouldn't be corrected. IMO
Yeah, it should be adjusted, it sucks when your HG get caught on a wall. Maybe every time it attacks, it re-evaluates what its attacking? I could see this causing more issues than it fixes though. The current system is at least consistent and makes sense. I wouldn't be surprised if altering it led to more troops running around back and forth between partially destroying many different walls aimlessly in some situations, especially slow troops like jugs, when hg keep destroying the "closest target" from over the wall that they're trying to get to.
@Lynsey [Midoki] perhaps if Midoki shared with us on the forum, what ideally the AI should do, and explain the tweaks you make to correct AI, then we can help report bugs more efficiently. Part of the issue is we aren't sure what is buggy and what isn't.