Is the cannon better used attacking or defending in xiangqi?

These answers restate the rules implemented by our open-source engine, which follows the WXF laws and is regression-tested against the official 110-diagram repetition casebook. Where an answer refers to a specific position, that position lives on the linked reference page, where the build verifies it against the engine before publishing.

Direct answer

Attacking, clearly. A cannon threatens from range, needs only one piece anywhere on its line to work, and can use the opponent's pieces as its screen, which makes it a natural aggressor. Defensively it contributes less than the pieces actually built for the job, advisors and elephants, because it cannot occupy the palace points that matter most.

Why it shines going forward

An attacking cannon draws its screens from whatever is in front of it, often including the defender's own soldiers and elephants, so the defender is frequently supplying the very material the cannon needs. The 馬後炮 mating pattern is built directly on this offensive strength, using a horse as the screen the cannon needs.

Why it is a weaker defender

A cannon guarding your own palace still needs a screen to actually capture anything, and a defender's position is exactly where screens tend to be scarce once material has traded off. Advisors and elephants defend simply by sitting on the points that matter; a cannon has to earn the right with a screen every time.

Related questions

Should I ever keep a cannon purely for defence?

Occasionally, aimed down a file the enemy would like to use, but its main defensive value there is positional pressure, not direct guarding.

Is a defending cannon still worth 4.5?

Close to it early on, but its value there fades faster than an attacking cannon's does, for the same reason screens run out.

Try it on a real board

Reading an answer is one thing; playing it is another. Free, instant, and nothing to install.