Xiangqi and Combinatorial Game Theory
Xiangqi and Combinatorial Game Theory
net/publication/2491574
CITATIONS READS
2 1,146
2 authors:
All content following this page was uploaded by Samee Ullah Khan on 29 December 2013.
Abstract
We explore whether combinatorial game theory (CGT) is suitable for
analyzing endgame positions in Xiangqi (Chinese Chess). We discover
some of the game values that can also be found in the analysis of Interna-
tional Chess, but we also experience the limitations of CGT when applied
to a loopy and non-separable game like Xiangqi.
1 Introduction
Most people believe that Xiangqi (Chinese Chess) and Shogi are variants of
Chess (by Chess we always mean International Chess) which was invented by
the Indians in the 6th Century. But this is probably not true. Rather, Xiangqi
and Backgammon evolved from an ancient Chinese game called Liubo that was
invented some 3,500 years ago [14, pp. 3{11]. Like Liubo, the modern Xiangqi
consists of one king, ve pawns, and several higher order pieces, and the game
is decided by capturing the opponent's king. Unlike in Liubo, the moves of
modern Xiangqi are not determined by the roll of dice. The dice part of the
game eventually evolved into another famous game, Backgammon. Based on this
revelation, Xiangqi predated both Shogi and Chess, and the latter are obviously
variants of the former instead.
Since Xiangqi and Chess are purely strategic games without random moves,
it should, at least in principle, be possible to decide whether there is a winning
strategy for the rst or the second player, or whether the game always ends with
a draw (assuming perfect play). Such games are called combinatorial games, and
combinatorial game theory (CGT) is a branch of mathematics devoted to their
analysis [3]. A rich theory on how to evaluate game positions has been developed
in recent years, and it has been successfully applied to analyze certain endgame
positions of Chess [8] and Go [4], for example.
Unfortunately, CGT cannot directly be applied to Xiangqi (or Chess). In
Section 2 we will therefore make a few simplifying assumptions about the game
to make it better accessible to CGT. These assumptions will of course a ect the
actual value of a game position but we will still be able to correctly identify the
winner.
Department of Computer Science, The Hong Kong University of Science and Technology,
Hong Kong, Email: frudolf,sameeg@cs.ust.hk.
1
In Chess, pawn endgames can be easily analyzed if there are no higher order
pieces are on the board [8]. The situation in Xiangqi is not so easy, unfortu-
nately. Pure pawn endgames are rare because higher order pieces usually survive
until the end, leading to loopy games with more complex values.
Another problem in strategic games is to nd a winning move (or at least a
good move) for a given game position. Since the search space is usually astro-
nomically large, nding the best move by exhaustive search is not a good idea.
Actually, most interesting games are PSPACE- or EXPTIME-complete (would
a game with an easily computable winning strategy not be quite boring?). We
believe that Xiangqi, like Chess [10] and Go [16], is EXPTIME-complete. There
exist many endgame rules forbidding the perpetual chase of some opponent's
piece [1, 13], and experience with other board games (like Go with the Ko-rule)
shows that such rules usually make a game polynomially intractable.
In Section 2 we give a short introduction of CGT. And we propose a few
restrictions to the movements of the pieces to make Xiangqi better accessible
to CGT. In Section 3 we analyze pawn endgame positions that show that some
of the `usual' game values of CGT also appear as value of Xiangqi positions. In
particular, we construct game positions with integral, fractional, and in nites-
imal values. In Section 4 we discuss game values of realistic positions, without
the restrictions of Section 3. In particular, we construct game positions of value
over, tis and tisn, on and off, dud, and nimbers. We conclude with a few
general remarks in Section 5.
2 Basic De nitions
We rst give a short introduction of CGT. Then we propose a few restrictions
to piece movements in Xiangqi to make the game better suited for analysis by
CGT.
2
move. Some games (like Chess) also know ties, i.e., positions where the play
ends but neither player wins.
Typical examples of combinatorial games are Chess, Nine-Men Morris, Check-
ers, and Go. Games where the players do not have the same moves available from
the same game position are called partizan games, otherwise they are impartial
games. Note that in the game graph of partizan games we must distinguish
between edges corresponding to Left's and Right's options. In impartial games,
each player can use any edge of the game graph.
A combinatorial game without draws or ties can have four di erent outcomes
(assuming perfect play): Left/Right player wins (whether he starts or not), or
rst/second player to move wins. The ultimate goal of combinatorial game
theory (CGT) is to classify all combinatorial games into these four categories.
Algorithmic combinatorial game theory (ACGT) on the other hand studies
the complexity of computing winning moves. Even if it is known which player
wins, it can be very dicult to nd a winning move. It is known that in Hex the
rst player has a winning strategy but this strategy still has to be discovered [5].
To better understand the structure of games Conway introduced the surreal
numbers [2, 6, 12], generalizing the real and ordinal number system. They are
given by a simple recursive de nition [6, pp. 4]:
If
L; R are any two sets of numbers, and no member of is any L
in a natural way, the surreal numbers form a eld which includes both the real
numbers and the ordinal numbers. In particular, the surreal numbers are totally
ordered.
It turns out that the surreal numbers are actually a subclass of the class of
combinatorial games. A game position is completely characterized by Left's
G
switch. Some of the algebraic structure of the surreal numbers, such as addition
and the order relation, carries over to games, but games are no longer totally
ordered.
If two non-identical games have the same value (f j g = 0 = f?1 j 1g, for
example) then they also have the same outcome (assuming perfect play). In
particular, in any game of value 0 the second player to move wins, because in
the endgame f j g neither player has an option and the rst player to move
immediately loses. In all positive games (i.e., of value larger than 0), like f0 j
g = 1 for example, Left wins. Intuitively, in this case the value of the game
characterizes the number of spare moves Left could make after winning the
game.
Symmetrically, Right wins in all negative games. And if a game is fuzzy, G
3
the rst player can move to game 0 where the second player loses (because he
is now the rst player in this game of value 0). This game is called . Note
?
that games can also be confused with other numbers than 0, but then they are
not fuzzy, i.e., rst player wins. For example, f3 j 2g is confused with 2 but
nonetheless positive, i.e., Left wins this game.
Other interesting games are the in nitesimals f0 j g = " (`up'; positive, but
?
tion 3.2), i.e., it is a rst player win. But without the assumption the second
player's best option would be to perpetually move its king, eventually forcing
the rst player to do the same, resulting in a draw. Berlekamp et al. [2, pp. 317]
call this situation a dud.
Assumption 1 is actually equivalent to say that the subgame played by the
two kings on their respective 3 3 roaming areas has value zero. Since the kings
could move forever, resulting in a draw, this is not quite right. But it is close
enough since we could augment CGT to include draws by arbitrarily treating
a draw as a second player win (at least, it is a position where the rst player
cannot win).
We put a similar restriction on pawns. Since pawns can move horizontally
after crossing the river in the middle of the board they are another potential
source of loopy games.
Assumption 2: We assume that pawns can only move horizontally if there is
a possibility to capture an opponent's piece.
In particular, after the opponent has lost all his pieces the pawns can only
move forward. This allows the pawns to move horizontally, but only in one
4
direction until they hit the board boundary. With this assumption we will
usually underestimate the value of a game position because we deprive a player
of additional spare moves, but we will still usually predict the right winner.
Elkies [8] observed that another drawback of Chess is the rather small board
size, compared to the Go board. In particular, most pieces can have a far-
reaching impact. This is also true for Xiangqi. As a consequence, it is very
dicult to subdivide a game into several independent subgames, a key step in
CGT analysis. Although the Xiangqi board is slightly bigger (910) than the
Chess board (8 8) it has only ve pawns besides the pairs of higher order pieces
(rook, guardian, cannon, and elephant). The rules of Xiangqi [1, 13] are more
complex than in Chess and players rely more on higher order pieces rather than
pawns. To make CGT work we restrict the arbitrary movements of the pieces.
Assumption 3: We assume we can analyse subgames on di erent parts of the
board independently.
We usually consider subgames on a single le or on a collection of les.
We denote by ( ) the value of the subgame on le x, and by ( ? )
val x val x y
the subgame on les x, x+1, , y. The assumption that pieces in one subgame
:::
cannot interact with the pieces in another subgame is clearly a strong restriction,
and it might easily result in a wrong evaluation of a game position.
In Chess pawn endgames, a subgame usually ends with the pawns blocking
each other. This is not possible in Xiangqi. Therefore, we only analyze subgames
until the rst piece is captured.
Assumption 4: We assume that a subgame ends either when some piece is
captured or when no piece can move.
Conceptually, after a piece has been captured all other pieces are consid-
ered immobile, so we consider this to be a subgame of value 0 (i.e., a second
player win; note that the second player is the player who just won the subgame
by capturing a piece). In Subsection 3.2 we will discuss some implications of
Assumption 4. We note that Elkies implicitly introduced a similar assumption
when he analyzed Chess positions [8]. He lets a game end when one player
could be forced to move a piece in a trebuchet (mutual Zugzwang) position,
thus eventually losing the game.
3 Pawn Endgames
Compared to Chess, pawns in Xiangqi seem to be weaker because they are never
elevated to higher order pieces. But their movement becomes more complicated
when they cross the river, greatly increasing their power. Fortunately (or un-
fortunately), pawns cannot be blocked by an opponent's pawn on the same le
as capture is made on the same le. Thus, pawns will usually survive longer
than in Chess.
3.1 Integral and Fractional Values
In Fig. 1(b), the subgame on le i has value ( ) = 0 because the rst player
val i
to move immediately loses his pawn. And we can create positions with arbitrary
5
Figure 1: Two fuzzy games: (a) value ; (b) value f" j 0 g.
? ;?
integer values on a single le by placing one Red pawn on the black half of the
board and one Black pawn on the red half of the board. These pawns cannot
interact, they can only move foward until they reach the baseline. The value of
this subgame is then the di erence between the number of Red's moves and the
number of Black's moves. Having subgames of integer value on single les, we
can easily create subgames of fractional value ( 12 = f0 j 1g, for example).
It seems impossible to create more complex positions of integral or fractional
value because, by Assumption 4, a subgame ends when some piece is captured.
As a consequence, there are no spare moves for the winner after capturing a piece
(and the number of spare moves is intuitively the value of a winning position).
move.
In Fig. 1(b), we rst consider the sub-game of les a and b. Red has two
options, 1. a5-a6 and 1. b7xa7. The former move will lead to a position of value
?, and the latter move will lead to a position of value 0. On the other hand,
Black has only one option, 1. a7-a6, leading to a position of value . Thus,
::: ?
a reversible move [6, pp. 110] that could be bypassed, see [3, pp. 62{66]), we see
that ( ? ) = f0 j g = ". So the subgame on les a-b is a winning position
val a b ?
for Red, although with in nitesimally small advantage (i.e., Red does not have
a full spare move).
6
What would be the value of the subgame without Assumption 4? The red
pawn on b7 could move to the left to capture the black pawn on a7, but af-
terwards could only move forward on the a le (3 more moves). Also, if Black
would rst move is pawn to a6 then the red pawn could only move forward on
the b le and never enter the a le. Thus, we would obtain ( ? ) = f7 j val a b
must also consider the black pawn on g4, so we consider the subgame consisting
of the les g to h. Red has only one option, 1. i4-i5, leading to a position
of value . On the other hand, Black has two options, 1. i6-i5 and 1.
? ::: :::
g4-h4. The former move also leads to a position of value . The latter move
?
leads to a position symmetrical to the position on the a-b le, so it has value
? ( ? ) = #. Thus, ( ? ) = f j #g = f j #g = # 2. So this subgame
val a b val g i ? ?; ?
is a winning position for Black. But what is the value of the full board?
Intuitively, we would expect a small advantage for Black because the position
is nearly symmetrical, except for an additional spare move for Black with the
pawn on g4. Indeed, we have ( ? ? ) = f" j 0g, an in nitesimally small
val a b; g i ?
negative value. For the value of the full board we obtain " + + # 2 = f" j 0 g
? ;?
which is fuzzy, i.e., the board is a rst player win. Red could start with 1. i4-i5,
leaving Black only the options 1. i6xi5 (where Red would win with 2. e4-e5),
:::
1. e7-e6 (where Red would win with 2. i5xi6; note that this move would
:::
end the subgame on les g-i), and 1. a7-a6 (where Red would win with
:::
2. i5xi6). And similarly, Black could win by rst moving 1. a7-a6. :::
4 Real Endgames
To analyze pure pawn endgames we introduced restrictions on the pawn move-
ments (Assumption 2) to prevent loopy games. For higher order pieces we
cannot easily do the same trick. Also, Assumption 4 does not seem to be useful
anymore (we want to be able to capture and capture back).
4.1 King Plus Pawn Against King
An important endgame position is Red with king and one pawn against Black
only with the king (see Fig. 2(a)). This position is a win for Red. A winning
move sequence is, for example, 1. f7-f8 Ke10-e9, 2. Kf1-f2 Ke9-e10, 3. f8-f9
Ke10-d10 4. f9-e9 | stalemate.
What is this game's value? Red could straightforward attack the Black king,
but it could also delay the attack by arbitrary king or pawn moves. Black can
only sit there and wait for Red's attack. This is an example of a game called
over [2, pp. 321].
7
Figure 2: (a) King plus pawn against king; (b) A classical endgame.
Adding a Black pawn in Fig. 2(a) would make the game in nite as neither
of the opponents could force a win. Such a game is called a dud [2, pp. 317].
Actually, dud= on+off (see also Subsection 4.5).
8
Figure 3: (a) King plus rook against king; (b) tis and tisn.
move forward and the game would end as a draw. Red does also not want to
move h6-g6 because it would lose immediately. Similarly, Black does not want
to move g7-g6.
This is an example of a game called tis and tisn [2, pp. 322]. If Black moves
a pawn rst he loses the game. And if Red moves a pawn rst he either loses
the game or it ends in a draw. Thus, both sides always move their kings, and
we have again an in nite game.
If the black pawn started at g8 instead of g7 then the situation would be
better for Red. Red's rst move 1. h6-g6 would result in a subgame of value
( ? ) = 0 (which is better than tis), while Black's only option 1. g8-g7
val g h :::
If Red captures the rook the game will end as a draw: 2. Rf2xf8 Kf9xf8, and
the two Kings have in nite moves.
4.5 On and O
The simplest loopy games are on and off [2, pp. 316{320]. These are two inde-
pendent subgames, where in on Red can move forever undisturbed by Black's
moves, whereas in off Black can move forever undisturbed by Red's moves.
These games could of course be constructed with pawns that move horizontally
forever after crossing the river. But we can also employ guardians to get these
positions. Their movement is restricted to the castle so they cannot interact
with the opponent's king or guardians. But they can move as often as they like.
Thus, a subgame where Red (Black) has one guardian and the king is an on
(off). And the sum of these two games is a dud, i.e., an in nite game where no
player can win or lose.
9
Figure 4: (a) A strange game; (b) A nimber.
occupy the e le and the game ends as a draw, i.e., we have a dud. The game
graph of this game is shown in Fig. 5.
4.7 Nimbers
We can also construct Xiangqi positions that are equivalent to positions of the
game Nim. These game values play an important role in CGT and they are
called nimbers [3, pp. 41]. Nim is played on heaps of pebbles. Both Left and
Right play alternatingly taking away some pebbles from one of the heaps. The
rst player not able to move loses. In Poker-Nim [3, pp. 53], they can also put
back some of the pebbles they have taken away earlier in the game. It turns out
that Nim and Poker-Nim are actually equivalent.
Now consider the game in Fig. 4(b). Both Red and Black have two cannons
and two guardians. None of the pieces are able to move (without immediately
10
losing the game) except the cannons, and even they can only move vertically
on their respective le. Thus, this position is equivalent to a Nim position.
The les with the cannons correspond to heaps, and the distance between two
cannons corresponds to the number of pebbles in the heap. For example, le c
corresponds to a heap of size 8, and le e corresponds to a heap of size 4. It is
not dicult to see that this particular position is a rst player win.
5 Conclusions
We have applied CGT to the analysis of certain Xiangqi positions. In many
cases, we were only able to carry out a meaningful analysis if we assumed certain
restrictions on the movement of pieces on the board. Without these restrictions,
most Xiangqi positions seem to be beyond the power of CGT (we only see that
the games are loopy and in nite). The greatest challenge is to incorporate sums
of non-independent subgames into CGT.
6 Acknowledgements
We are grateful for the existence of David Wolfe's Gamesman's Toolkit [17], a
very useful tool for computing values of game positions.
References
[1] Hong Kong Chinese Chess Association. Asia XiangQi Rules, 2001. http:
//txa.ipoline.com/rule/asia/asiarule.htm.
11
[9] A. S. Fraenkel. Scenic trails ascending from sea-level Nim to alpine Chess.
In R. J. Nowakowski, editor, Proceedings of the 1994 MSRI Workshop on
Combinatorial Games | Games of No Chance, volume 29, pages 13{42.
Cambridge University Press, Cambridge, England, 1996.
[10] A. S. Fraenkel and D. Lichtenstein. Computing a perfect strategy for
n n
12