The Story
Where it came from, and why it turned out this way.
OriginChina; modern form settled between the late Northern Song and Southern Song, 11th–12th c.
The name is older than the game
The two characters read as xiangqi appear in pre-Qin texts, but they most likely refer to other board amusements rather than the game played today. The recognizably modern form — palaces, a river, and cannons — took shape roughly between the late Northern Song and the Southern Song. The statesman Sima Guang designed a seven-kingdom chess variant in the 11th century, evidence that game redesign was lively at the time, while the earliest surviving complete rules and recorded games come from the encyclopedic Shilin Guangji of the late Southern Song or early Yuan.
The cannon carries a date stamp
Of the whole chaturanga family, only the Chinese branch grew a cannon, and its movement is unique anywhere in chess: identical to the chariot when not capturing, but requiring exactly one intervening piece to capture. That intuition of firing over an obstacle is generally associated with the age of the trebuchet — the character for the piece was originally written with the stone radical and only acquired the fire radical after gunpowder became common. This is the received account rather than settled fact, but the shift in the written character does track that technological history.
Nail down the defense, let the attack fly
Advisors confined to the palace, elephants unable to cross the river, the general locked in nine squares — these three restrictions look like weaknesses and do the opposite. They permanently bind the defensive pieces to a small area while the attacking pieces roam the whole board. The result is a game markedly faster than international chess, where positions often resolve within twenty moves. Playing on intersections rather than squares, and leaving a blank river across the middle, both further amplify the reach of chariots and cannons.
Why a large chunk of the rules is about repetition
Attacks this fast have a side effect: either player can stall the game with endless checks or endless chases. Xiangqi therefore developed the most detailed repetition adjudication in any board game — perpetual check loses, perpetual chase loses, and the rules must distinguish what counts as chasing from what counts as idling. Other games declare every repetition a draw; xiangqi insists on assigning fault, which is how it writes the obligation to attack directly into its rulebook.
- The Ming-era Juzhong Mi and the Qing-era Meihua Pu are the two most widely circulated classical manuals; the first champions the central cannon, the second the Screen Horses defense, and the disagreement between them is still an opening mainline.
- "Chu River, Han Border" is a later name for the river, borrowed from the Chu–Han contention of the 3rd century BCE; it says nothing about when the game originated.
- Xiangqi engines matured earlier than Go engines: modern programs such as Pikafish now play far beyond the level of the strongest human masters.
Complete Rules
Start with what a turn allows and how the game is won.
- Board
- 9 files × 10 ranks of intersections
- First move
- Red
- Winning conditionyou win by checkmating or stalemating the opposing general. Checkmate means the general is in check and cannot escape it; stalemate means that when it is your opponent's turn, they have no legal move with any piece. Both count as a loss for that side — this differs from chess, where stalemate is a draw.
- How a turn worksRed moves first, then players alternate, and every turn must move one piece — passing is not allowed. Pieces sit on intersections. Landing on an enemy piece captures it and removes it from the board; you may not land on your own piece. Capturing is never compulsory.
- The general moves one step orthogonally and must stay inside the palace — the three-by-three area — and can never move diagonally or leave it. The two generals may not face each other down an open file with no piece between them; any move creating that "flying general" position is illegal and the interface will not offer it.
- The advisor moves one step diagonally and must also stay in the palace, giving it only five reachable points on the whole board. The elephant moves two steps diagonally in a straight line; the intermediate point is its "eye" and blocks the move if any piece occupies it, and the elephant can never cross the river, so each side has exactly seven elephant points.
- The horse moves one step orthogonally then one step diagonally outward. The orthogonal point it starts through is its "leg" and blocks the move if any piece stands there. The leg does not care about color — your own pieces hobble your own horses just as effectively as the enemy's do.
- The chariot moves any distance along ranks and files with no piece in between. The cannon moves exactly like a chariot when not capturing, but to capture it needs exactly one piece — the "screen" — between itself and its target. Zero screens or two or more screens make the capture illegal, and the screen may belong to either side.
- Soldiers move one step straight forward before crossing the river. After crossing they may move forward or one step sideways, and they may never move backward at any time. A soldier that reaches the far edge can only move sideways from then on; xiangqi has no promotion, and the piece is never removed from the board.
- No move may leave your own general under attack or create a flying-general position, and this constraint overrides everything else — the interface will not offer such moves.
- A player in check must respond, and there are only three ways: capture the checking piece, interpose a piece to block it, or move the general to a point that is not attacked. If none of the three is possible, it is checkmate and the game ends immediately.
Your First Game
Use this order of thought to get through a complete game quickly.
- The central cannon opening is the easiest way to start: first move the cannon to the central file to aim at the opponent's central soldier, then develop the knight beside it to protect your own central soldier and support the cannon, then swing the chariot to the file the cannon vacated so it stands on an open line. Three moves later your center, horse, and chariot are all in play.
- Against the central cannon, the safest reply is the Screen Horses defense: bring both horses to the squares beside the central soldier so they defend it together, then develop the chariot to face your opponent's. If you rush the chariot out without the horses, losing the central soldier to the cannon collapses your whole structure at once.
- If you would rather not memorize opening lines, choose the Elephant opening, the Pawn opening, or the Horse opening. None of them commits the cannon early: you set up defense and development first, then choose an attacking direction based on how your opponent replies.
- Run three fixed checks before every move. One: which enemy chariot shares a file or rank with my general with only one movable piece between them? Two: is there exactly one piece between an enemy cannon and my general, because the moment that piece leaves it is check? Three: are my own horses' legs or elephants' eyes blocked by my own pieces?
- Learn the rough exchange values: a chariot is worth about two horses or two cannons; cannon and horse are close (the cannon is slightly better early, the horse slightly better in the endgame); a soldier that has crossed the river is worth far more than one that has not; advisors and elephants are the general's armor, and missing advisors invites chariots while missing elephants invites cannons. The engine uses similar numbers when judging chase targets: chariot 900, cannon 450, horse 400, advisor and elephant 200, soldier 100.
- Learn four basic mating patterns before you think about attacking: the double-chariot mate, where two chariots take turns checking on the back rank; the horse-and-cannon mate, where the horse seals the general's escape and the cannon checks from behind; the "iron bolt" mate, where a central cannon pins the file while a chariot on the back rank freezes the advisors; and the flying-general mate, where you clear the piece between the generals so your own general joins the attack.
Practical Strategy
Move from knowing the rules to playing with a plan.
- The main opening goal is getting your chariots off their starting points as fast as possible. A chariot boxed into a corner by your own horse, cannon, or advisor is effectively a missing piece — before developing it, decide which file or rank it is going to occupy.
- A cannon's power comes entirely from its screen. The central cannon is strong precisely because the opponent's own central soldier serves as a ready-made screen; by the same logic, there are times when leaving an enemy piece alive is worth more than capturing it.
- A horse is only safe on an advanced point defended by a soldier. Horses on the rim, or horses with blocked legs, do almost nothing. Before committing a horse to an attack, verify that its next two destination points will both have free legs.
- Real attacks need several pieces working together. A single chariot on the back rank gets absorbed step by step by advisors, elephants, and horses; you need at least two of chariot, cannon, and horse producing consecutive threats before a genuine mating attack exists.
- When ahead in material, trade off the enemy's counter-attacking chariots and cannons while keeping your own advisors and elephants intact. Only after simplification does an extra soldier or horse reliably convert into a win.
- When behind, do the opposite: avoid simplification, concentrate your pieces on one wing to keep the position complicated, or steer toward a recognized drawn endgame such as a lone chariot against a full complement of advisors and elephants.
- In the endgame, restrict before you attack: shrink the enemy general's usable area to a minimum, and only then calculate the mate. Aimless consecutive checks waste moves and can trigger a perpetual-check loss.
Winning and Special Rules
Details that are easy to miss but can change the result.
- A general that is in check with no capture, block, or escape available is checkmated, and that side loses.
- Stalemate is also a lossif the player to move cannot make a single legal move with any piece — for example every remaining piece is blocked, or any move would create a flying general — that side loses even though the general is not in check. This is completely unlike chess, where the same situation is a draw.
- Repetition adjudication triggers when the current position, including which side is to move, occurs for the third time. The engine takes the segment of moves between the last two occurrences and checks, side by side, whether every move in that segment does the same illegal thing, then decides between a loss and a draw.
- Perpetual check is a loss: if every move one side made within that segment gave check, that side loses.
- Perpetual chase is a loss: if one side gave no check at all in the segment and every one of its moves chased the same enemy piece — the engine follows that piece as it moves — that side loses.
- "Chasing" has a strict definition in this implementation. The chasing attack must come from the piece that just moved, and that piece may not be a general or a soldier, since attacks by generals and soldiers always count as idle. The target may not be a general (that would be check) and may not be a soldier that has not crossed the river. The move must create a new threat, so a target already attacked by another of your pieces before the move does not count. And the target must be unprotected, meaning capturing it leaves your opponent no legal recapture. Perpetual blocking, perpetual offers to trade, and repeatedly chasing a protected piece are therefore all idle and are not penalized.
- When one move chases two or more pieces at once, the engine picks the most valuable one as the chase target using chariot 900, cannon 450, horse 400, advisor and elephant 200, soldier 100. This prevents the target from drifting within the loop and defeating the adjudication.
- If both sides are violating, or neither side is, the result is a draw. Note in particular that a mixed loop — one side checking while the other chases — does not constitute a one-sided violation in this implementation and is scored as a draw.
- The AI is bound by the same rules: if the move chosen by the main engine would make the AI itself lose by perpetual check or perpetual chase, the page substitutes a move from its rule-aware local search and notes the reason in the status hint.
- This implementation has no natural move limit — there is no draw for long stretches without captures. Only the repetition adjudication above can produce a draw or a loss.
Common Mistakes
The traps new players fall into most often.
- Moving the only piece standing between the two generals and creating an illegal flying-general position. The interface will reject the move, but you must see it coming in your calculation, or a carefully planned sequence will suddenly be unplayable.
- Playing the cannon like a chariot. It moves like one only when not capturing; a capture requires exactly one screen, so it cannot take a piece it is adjacent to, nor one with two pieces in between.
- Looking only at where a horse lands and forgetting to check its leg. Your own pieces block your own horses just as effectively as enemy pieces do.
- Assuming a perpetual check by your opponent automatically wins for you. If you are also violating in the same loop, or if your opponent alternates check and chase in a mixed loop, the result is a draw.
- Using soldiers or the general to harass an enemy piece over and over in the hope of a perpetual-chase ruling. Attacks by those pieces count as idle by rule, so repeating them just heads toward a draw.
- Treating a completely immobilized opponent as a mere stalemate stand-off and forgetting that it is an outright loss in xiangqi. In the endgame you should actively squeeze the enemy's mobility rather than rushing to capture material.
