Goblins Farm
HomeWikiMechanicsTroop targeting and AI
Troop Targeting and AI: Why Your Troops Do That

Troop Targeting and AI: Why Your Troops Do That

Mechanics

CombatCore mechanic

Updated: 18 September 2026 · By the Goblins Farm team

Clash of Clans troops are not clever. They follow a small set of rules with total consistency, and almost every attack that fails does so because the attacker expected intelligence where there was only a rule. Learn the rules and you stop being surprised.

Rule one: nearest target

Unless a troop has a preferred target, it walks toward whatever building is closest to it and attacks that. Not the most dangerous building. Not the building you want it to attack. The closest one.

This is why deployment position is the most important decision in an attack. A troop dropped at the corner of a base will attack the corner. A troop dropped next to a wall with a storage on the other side will, more often than not, walk around the wall to reach a building that is easier to get to, because it is looking for a path to the nearest target and the wall is not on the way.

Everything else in this page is an exception to this rule.

Rule two: preferred targets

Some troops ignore nearest-target logic and instead seek out one category of building, walking past everything else to reach it, taking damage the entire way. These are the units that make or break attacks:

The critical corollary: once every building of a troop's preferred type is destroyed, it reverts to plain nearest-target behaviour. Giants that have flattened every defence will happily wander off to punch a builder's hut on the far side of the map while the timer runs out. This single behaviour is responsible for an enormous number of failed 99% attacks.

Air versus ground

The other hard division is movement type. Ground troops walk, are stopped by walls, and can be hit by every defence except pure anti-air. Air troops fly in a straight line over walls, buildings and traps, and can only be hit by defences that target air.

Two practical consequences. First, walls are worth nothing against air; a base with beautiful compartments and one Air Defence is a free win for Dragons. Second, air attacks are far more predictable, because you have removed pathing from the equation entirely, which is exactly why they are the standard recommendation for newer players.

A handful of troops sit in between: some ground units jump walls, some travel underground, and some switch behaviour when damaged. Those exceptions are noted on each unit's own page.

What defends actively

Most of the base is passive: buildings sit still and shoot whatever comes near. Three things are not passive, and they will come to you.

The pattern for all three is the same: pull them out to somewhere harmless, kill them there, then attack the base you actually wanted to attack. An attack that walks into a defending Castle with the main army is an attack that has already gone wrong.

Using the rules on purpose

Once you accept that troops are simple, you can steer them:

Frequently asked

Why do my Giants ignore the nearby cannon?

They are not ignoring it, they are pathing to the nearest defence they can actually reach. If a wall blocks the direct route, the game routes them around it toward whichever defence has a walkable path, which is frequently not the one you had in mind. Break the wall, or deploy where the route you want is the shortest one.

Do troops attack walls?

Only when a wall blocks the path to their target and going around would take significantly longer, or when the troop is a Wall Breaker, which targets walls deliberately. Most ground troops prefer to walk around, which is why wall compartments funnel attacks rather than stopping them.

What happens when all the defences are destroyed?

Troops with a defence preference revert to normal nearest-target behaviour and start attacking whatever building is closest, including huts and decorations at the far edge of the map. This is a common cause of failed attacks that end at 99 per cent with the timer expired.