Tag: chinese

Introduction To The Ancient Game Of Chinese Chess, Or Xiangqi, Version 2, By Peter Donnelly

November 1989

Although it has been several years in the making, the present release of
Xiangqi is very far from being a finished product. It remains woefully
slow, and it doesn’t play a particularly good game. But it has reached a
plateau, and I don’t know if it will ever get any better, so I’m releasing
it into the public domain with one hope: that it will provide an
introduction to an exciting and fast-moving game too little known in the

If you do become interested in xiangqi and want a stronger opponent, I can
recommend a commercial program called Xian, published by Leong Jacobs Inc.,
2729 Lury Lane, Annapolis MD 21401. (Telephone 301-266-3660.) The program
plays an excellent game and is blindingly fast. A graphics adapter is

Xiangi was created using Turbo Pascal, copyright (c) Borland International
1987, 1988, and Turbo Assembler, copyright (c) Borland International 1988.


The Chinese Game of Chess

– Version 2 –

Program and notes
by Peter Donnelly
1301 Ryan Street
Victoria BC Canada V8T 4Y8

* * *

No, it’s not the same as Chinese checkers – which is not an oriental game
at all. Nor is it the same as go. It is an ancient form of chess played by

Xiangqi (pronounced roughly “zhang-chee”, with the “zh” being the sound of
the middle consonant in “leisure”) is in fact closely allied to our
familiar western chess. It is thought that the two games share an ancestor
that developed in India more than a thousand years ago. The Chinese board
is somewhat different from ours, and the pieces, with one exception, are
not exactly like their western counterparts. The game also has its own
flavor; it is much more fast-paced and tactical in nature than western
chess – or, for that matter, the Japanese shogi, to which it is also

Xiangqi is also unlike western chess in its popular appeal; it is played by
all classes. Visitors to San Francisco may see it played in outdoor
gazebos, with the onlookers taking an active part – even to the extent of
reaching in and moving the pieces!

Authentic boards and pieces can be bought cheaply in any North American
Chinatown. You will likely need help identifying the men, which are
distinguished not by shape but by their names printed or stamped in Chinese
on one side.



No graphics card is required. The program adapts itself automatically to
color or monochrome. If you have a hybrid system with a color graphics card
and a monochrome monitor, and find that the display doesn’t seem right, you
can force the program into monochrome mode by putting M or /M on the
command line.

The game can be played with a Logitech or Microsoft mouse, or with the

With no mouse, move the cursor box about the screen with the arrow or
numerical keys. Pick up and put down a piece with Enter or (handier on
old-style keyboards) the grey plus key. Move to the menu either by pressing
F1 before picking up a piece or by moving the cursor off the bottom of the
board. When finished with the menu, just press the up arrow or F1 to return
to the board. To be reminded of how a piece moves, position the cursor over
the piece and press F2; every point where it can move, and every piece it
protects, is marked with an X.

The mouse controls need no explanation. The available options are always
displayed on the screen, where the left and right buttons are indicated
by arrowheads.

On the menu line, “Free” lets you set up the board any way you like. (To
clear the board first, load EMPTY.BD with the “Read” command.) Black’s home
side must always be at the bottom. The program doesn’t check to see that
pieces are placed in legal positions, and it will malfunction if, for
example, you put an elephant on a point it can’t normally visit.

“New” sets up the pieces for a new game, and “Back” takes back your last
move. You can take back a move even after losing the game – answer “Y” at
the “Play again?” prompt and then choose “Back”.

“Save” will save a position (it remembers who is to move) and “Read”
will restore it. Since the program lets you take back only one move, you
should save any crucial positions that you may want to replay.

At the beginning of a game you are always offered the black pieces and the
first move. To take the red pieces instead, choose “Swap”. You can also
change sides during the game with this option. By continuously swapping,
you will see the machine play itself.

Cycle upward through the “Skill” levels with the Enter or plus keys; to
cycle downward, use the minus key. With the mouse, cycle up with the left
button and down with the right. The number of turns ahead the program will
look depends partly on the skill level and partly on the position. There is
no “book” for the opening so to speed things up you should set the level at
1 or 2 for the first few moves. If playing at a low level, increase skill
if you reach an endgame with only a few pieces on each side.

Click on the musical note to toggle the sound on and off.

Finally, strike Ctrl-Q while the machine is thinking if you change your
mind about your move. To avoid wasting time, the machine checks the
keyboard only at intervals during its search, so at higher skill levels
this command may not take effect immediately.



Players move and capture as in chess. Win is by checkmate or stalemate:
that is, a player loses if he cannot make a move without exposing his
general, or king, to capture.

The program announces “I lose” when it sees that you can force a mate
within the next few moves.


There are 90 points of play, arranged in 10 ranks or rows and 9 files or
columns. The board has some special features: the two castles, which are
nine-point squares defined by a large X, and the river, which separates the
two halves of the board. These features affect some of the pieces.


General One point along a rank or file; may not leave the castle.
Guard One point along a diagonal within the castle. Can visit only
five different points.
Elephant Always two points along a diagonal; may not cross the river
or leap a piece. Can visit only seven different points.
Horse One point along a rank or file, then one point diagonally.
May not leap a piece.
Chariot Any distance along a rank or file, without leaping. Just
like a western rook.
Cannon Ordinarily moves like a chariot, but cannot capture unless
it leaps over a single piece of either color on the way to
its target.
Soldier One point straight ahead, until it has reached the far bank
of the river; then it may move one point straight forward or
along a rank. Never moves diagonally or backward.

As well as its regular move, the general has the theoretical power of
attacking the opposing general along an open file, moving just like a
chariot. Any move that puts the generals opposite one another along an open
file is therefore equivalent to moving into check, and is illegal.

Note that only the chariot is exactly like its counterpart in chess. The
horse is like the knight but must always take the “straight” part of its
move first, and can be blocked by a piece of either color at the elbow of
its path. The cannon cannot leap unless it is capturing, and cannot capture
without leaping.


Don’t rely too much on knowledge of western chess. Xiangqi is a much more
open, tactical game, with ready-cleared files that permit quick attack by
the chariot and the cannon, the most mobile pieces. Control of these open
files, particularly those aimed at the enemy castle, is of the utmost

The cannon is an interesting piece. It can be devastating at long range,
but once it has been “shot” over the enemy line it can lose its efficacy,
just like a spent ball. It is powerless against an enemy that is in close.
An important thing to remember is that the cannon can pin two enemy pieces
against their general – if either one moves, the general is in check. With
this in mind, many games begin with black’s cannon being moved to the
centre file. Some fascinating situations develop when two or more enemy
cannons line up against one another and begin leapfrogging at targets.

The elephant, the guards, and for the most part the general itself are
defensive pieces, except in those instances where they provide a screen for
the cannon. But their constant presence in the home field gives the
chariots, cannons, and horses more freedom to go to the attack. After
developing your pieces – getting the chariots onto open ranks and files,
bringing the horses off the back row, deploying the cannons behind screens
– move quickly against the enemy. There is no place in xiangqi for the
tenacious, passive defence. It is impossible to build an impregnable,
interlocked wall of men as you might do in western chess – chiefly because
of the very different nature of the pawns, or soldiers – and it is better
to deploy your forces in an active, aggressive way.

Do not overlook the power of the promoted soldier. Once across the river
this little piece triples in strength, and in many situations, especially
close in on the castle, it can be as effective as a chariot. And don’t
forget the general’s ability to close off a file to the opposing general –
a power that frequently clinches mate.

For purposes of evaluating trades, count guard and elephant at 2, cannon
and horse at 4, and chariot at 8. Trading a horse for a cannon may be a
good idea early in the game but becomes less wise as the board opens up and
the cannon becomes relatively weaker. Soldiers start at 1 but can greatly
increase in value depending on their position. In the early stages of the
game the enemy soldiers are temptingly exposed targets, but don’t waste
time on them: it is far more important to develop your major pieces and not
lose tempo.