Solving Quantum Tic-Tac-Toe
Takumi Ishizeki Akihiro Matsuura
Graduate School of Science and Engineering Graduate School of Science and Engineering
Tokyo Denki University Tokyo Denki University
Hiki, Saitama, 350-0394, Japan Hiki, Saitama, 350-0394, Japan
[email protected] [email protected]
Abstract—Quantum Tic-Tac-Toe is a two-player zero-sum game of the board, and the winner is the player who occupies a
of perfect information which is based on the concepts of quantum whole ‘winning set’ first (ref. [7]).
physics and was recently proposed by Goff et al. [1]. We analyze
winning strategies of Quantum Tic-Tac-Toe under the following For two-player zero-sum games with search space up to
two criteria: one is that the player who first achieves three marks around 1030 and with poor understanding in their structures,
in a row wins the game, which we call complete win; and the other which include the game we consider in this paper,
is when both players achieve three marks in a row, the player computational exploration for finding winning strategies is
whose largest subscript of the three marks is smaller wins the often employed. Results along this line are obtained for Qubic
game, which we call narrow win. In this paper, we show that (i) [8], Awari [9], and Checkers [10], among others.
under the criterion of complete win, the game is a draw; and (ii)
under the criterion of narrow win, the first player wins the game For two-player zero-sum games with larger search space
and needs totally nine marks for the win. We also explore (around 1040 and more) such as Othello, Chess, Shogi, and Go,
efficiency of move ordering techniques for accelerating game-tree it is generally believed that at present they are beyond complete
search and also consider some modification of rules of Quantum analysis even using fastest algorithms and computers. We note
Tic-Tac-Toe. that search spaces of these games are 1060, 10120, 10220, and
10360, respectively. Therefore, emphasis of research for these
Keywords-component; two-player game; Quantum Tic-Tac- games are focused on developing computer programs which
Toe; winning strategies; quantum physics; cyclic entanglement play strongly and flexibly just like humans.
I. INTRODUCTION In this paper, we analyze a two-player zero-sum game
called Quantum Tic-Tac-Toe, which was recently proposed by
Two-player zero-sum games have been studied in many Goff et al [1]. Quantum Tic-Tac-Toe is a game which makes
research fields such as mathematics, computer science, use of basic concepts of quantum physics such as
economics, psychology, and so forth. In computer science, superpositions, entanglement, observation and collapse of
main research topics are computational complexity, analysis of quantum states. Though the game is originally created for
winning strategies, game-tree search techniques, and educational use, it is strategic enough to play practically as a
development of computer programs which are strong and new two-player game. Thus, it is playable in several forms on
flexible enough to play just like humans. the internet [11],[12]. In its rules, players alternately place a
pair of marks, which are called quantum marks, at one move.
For games with small search space, it is possible to clarify Quantum marks are later fixed when a condition called cyclic
even manually which player wins the game after perfect play of entanglement occurs. Due to these rules, three marks in a row
both players. A typical example of this type is Tic-Tac-Toe on can occur simultaneously at some places on the board, which is
a 3 3 board, which is easily shown to end in a draw. Even different from the case of classical Tic-Tac-Toe. Furthermore,
when the search space is large or arbitrary, it is possible to the search space of the game is around 1014; so the game is far
analyze a game if mathematical structure of a game is well from being analyzed manually. Accordingly, as far as we know,
understood. Hex is one of such games and Nash showed in it is not known yet which player wins at the game. Though in
1949 that there is always a winning strategy of the first player the original game in [1], when two sets of three marks in a row
for Hex on an n n board of any size n (ref. [2]). Harary’s are completed simultaneously, scores are given separately for
generalized Tic-Tac-Toe [3] is also such a type of game, where each set of the three marks in a row. However, since we are
the purpose of the game is to achieve a specified polyomino, only interested in which player wins or whether the game is a
i.e., a figure formed by joining one or more squares edge to draw, we consider the following two winning criteria: (i) a
edge, on an n n board. For this game, polyominoes except for player who first achieves three marks in a row wins the game,
the one called “snaky” are mathematically completely analyzed. which we call complete win; and (ii) when both players achieve
Furthermore, generalized Tic-Tac-Toe on triangular and three marks in a row, the player whose largest subscript in the
hexagonal boards are also analyzed [4],[5],[6]. Tic-Tac-Toe three marks is smaller wins the game, which we call narrow
admits further abstraction on an arbitrary finite hypergraph, win. In this paper, we show that (i) under the criterion of
where the hyperedges are called ‘winning sets’, the union set is complete win, the game is a draw; and (ii) under the criterion
regarded as the board, the players alternately occupy elements of narrow win, the first player wins the game and needs totally
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
Copyright © 2011 RG Education Society
ISBN: 978-981-08-7932-7
330
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
(a) (b) (a) (b)
Figure 2. (a) Cyclic entanglement by the first three moves;
Figure 1. (a) Game board and quantum marks at (1, 2);
(b) Two possible classical marks. (b) Fix of quantum marks by the second player.
nine marks for the win. We also explore move ordering (a) (b)
techniques for accelerating game-tree search. Finally, we Figure 3. (a) Three marks in two rows achieved by the first player;
consider modification of rules of the game and obtain results
for this game. (b) Three marks in a row achieved by both players.
The remaining of the paper is organized as follows. In to fix the set of quantum marks which are related to the cyclic
Section II, rules of Quantum Tic-Tac-Toe are explained. In entanglement (in the original paper [1] it is written that the
Section III, our approach to Quantum Tic-Tac-Toe and the fixing of marks is done by the opponent due to balancing the
main results of the paper are summarized. In Section IV, the power of both players). In this example, the second player fixes
algorithm of the search program is stated. In Section V,
experimental results on the winning strategies and on the 3 to square 1 as shown in Fig. 2(b), then the remaining
acceleration of game-tree search are reported and discussed. quantum marks 1 and 2 are automatically fixed to squares
Finally, concluding remarks are given in Section VI. 2 and 5, respectively. Here we note that when cyclic
entanglement occurs, there are always two ways to fix the set
II. GAME RULES of quantum marks.
A. Game Board D. Exception for the Last Move
At the end of the eighth move, if all of the first eight moves
Quantum Tic-Tac-Toe is played on a 3 3 board. Moves of
the first and the second players are denoted with marks and are already fixed to eight squares, then since there is only one
square left, the first player places his two quantum marks to
, respectively. Subscripts of marks indicate the orders of this square and changes them promptly to the classical mark.
moves and are denoted as 1, 2 , , 9 . Nine squares on
the board are numbered 1, 2, , 9 as shown in Fig. 1(a). E. Definition of Win
The player who first achieves three classical marks in a row
B. Placement of Quantum Marks
wins the game. Then, different from the classical Tic-Tac-Toe,
Two players alternately mark a pair of two marks, called there are some situations in which more than one set of three
quantum marks, at a time to different squares. In Fig. 1(a), the marks in a row are achieved. For example, in Fig. 3(a), two
first player places two quantum marks to squares 1 and 2, sets of three marks in a row are achieved by the first player
which we denote as (1, 2). Quantum marks are derived from after the ninth move. In Fig. 3(b), three marks in a row are
the notion of a superposition in quantum mechanics and are not achieved simultaneously by both players. The latter case is not
fixed yet. They are fixed to either of the squares when the defined to be a draw, but the player whose largest subscript
condition called cyclic entanglement, which will be defined in among the three marks in a row is smaller wins the game. This
the next subsection, occurs. A fixed mark is called a classical type of win is called narrow win. If one of the players only
mark. Fig. 1(b) shows two possible classical marks of the first achieves three marks in a row, it is called complete win. In the
move. If there exist only quantum marks in a square, both original paper, the game is supposed to be played multiple
players can further place quantum marks to the square. times and the winner and the loser of narrow win get 1 and 0.5
C. Cyclic Entanglement
Cyclic entanglement is the condition on a set of quantum
marks such that if one of the quantum marks in the set is fixed
to some square, then the remaining quantum marks are
uniquely determined successively to either of the squares. In
quantum physics, this phenomenon corresponds to the collapse
of quantum states which occurs at the observation of the
system. Fig. 2(a) shows an example of occurrence of cyclic
entanglement by the move of the first player. When cyclic
3
entanglement occurs, the opponent determines to which places
331
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
points, respectively. Furthermore, when one player achieves
two “three marks in a row”, he gets 2 (or 1.5) points. In this
paper, however, since we are only interested in win-or-lose
results of this two-player game, we concentrate on examining
whether the game admits win of either player under the
conditions of narrow and complete wins.
III. MAIN RESULTS Figure 4. Eight essentially different first move of the first player.
In this paper, we analyze Quantum Tic-Tac-Toe under the A. Recusive Procedure of Game-tree search
criteria of narrow and complete wins. The search space of the
game is evaluated as follows. At each move of both players, When i = 1, 3, 5, 7, at a vertex of depth i of the first
there are in the worst case 9C2 = 36 ways to choose a pair of player, if the vertex results in the first player’s win for all
two quantum marks, so the search space is roughly 369 1.0 of the vertices at depth (i+1), then change the vertex at
! 1014 (we note that cyclic entanglement can further cause two depth (i -1) to the next and examine again whether there
branches corresponding to the two ways to fix the quantum is a vertex at depth i which achieves the first player’s win
marks). Therefore, we developed computer programs to (note that when i =1 and the condition holds, the program
analyze Quantum Tic-Tac-Toe and obtained the following simply returns the first player’s win). Otherwise, that is,
results. if the vertex at depth i does not result in the first player’s
win by some move of the second player at depth (i+1),
Under the criterion of complete win, Quantum Tic-Tac- then change the original vertex at depth i to the next and
Toe is a draw. examine again whether the new vertex of the first player
results in his win for all of the vertices at depth (i+1).
Under the criterion of narrow win, the first player is the
winner and nine total moves are necessary and sufficient When i = 9, at a vertex of depth i of the first player, if the
for the win. vertex results in the first player’s win, then change the
vertex at depth (i -1) and examine again whether there is
We also considered a modified rule such that when cyclic a vertex at depth i which results in the first player’s win.
entanglement occurs, the player who generated it, instead of the Otherwise, that is, if the vertex at depth i does not result
opponent, can fix the quantum marks. With this rule, we have in the first player’s win, then change the vertex at depth i
the following results. to the next and examine whether the new vertex of the
first player achieves his win.
For the modified Quantum Tic-Tac-Toe, under the
criterion of complete win, the first player is winner and If there is a vertex at depth (i -1) such that the program
nine total moves are necessary and sufficient for the win. returns no win of the first player for all of the vertices at
As a result, under the criterion of narrow win, again the depth i below the above vertex at depth (i -1), then the
first player is the winner. program returns no win of the first player.
In the analysis of winners, we also explored techniques for Using this procedure, we can examine whether there is a
accelerating computing time of the game-tree search based on winning strategy for the first player under the criterion of
the priority of squares to be marked by both players. complete win. The program is easily modified to check a
winning strategy for the second player and is also modified for
In the next section, we illustrate our method for analyzing the criterion of narrow win.
Quantum Tic-Tac-Toe.
B. Move Ordering
IV. SEARCH METHOD
Computing time for the game-tree search often depends on
Our analysis is based on the depth first search of the game the priority of vertices to be searched. The technique for
trees. A game tree consists of a root vertex, vertices at depth i, determining the order of vertices to be searched is generally
1 < i < 9, which represent status of play after the marks at turn i, known as move ordering. The simplest one is of the
and edges such that two vertices are connected if the parent alphabetical order. Furthermore, since the center square, i.e.,
vertex is changed to the child vertex by the move of the child square 5, and the corner squares, i.e., squares 1, 3, 7, and 9, are
vertex. When i is odd, the vertices of depth i are of the first favorable to be marked first, we consider two more move
player’s, and when i is even, the vertices are of the second ordering methods: One has the priority such that “corner >
player’s. As stated in Section III, there are 9C2 = 36 ways for center > remaining” and the other has the priority such that
the first player to choose the first quantum marks. However, by “center > corner > remaining.”
the symmetry of the board, the eight moves (1, 2), (1, 3), (1, 5),
(1, 6), (1, 9), (2, 5), (2, 6), and (2, 8), shown in Fig. 4, are
sufficient for the search.
In the computer program for searching a winning strategy
of the first player under the criterion of complete win, we
execute the following recursive procedure for the game tree.
332
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
Another promising criterion of move ordering is to give TABLE I. SEARCH RESULTS FOR THE ORIGINAL RULE
priority on the quantum marks by which cyclic entanglement
occurs. This is because when cyclic entanglement occurs, at Search Win Num. of Avg Num. of Computing
least two pairs of quantum marks are fixed to squares, which Method Vertices Vertices for " 2 Time [s]
results in the exponential reduction of the search space. None 47,025,703 66.90
FCW (1, 9) 78,533,033 2.13 105.83
We make use of these move ordering methods to accelerate FNW None 88,372,114 8.00 116.67
the computing time of the game-tree search. SNW None 24,829,603 36.00 029.83
SCW 36.00
V. EXPERIMENTAL RESULTS Total — 238,760,453 — 319.23
We wrote computer programs for searching winning
strategies of the first and the second players, based on the
methods in Section IV. Experiments were executed using a
computer with AMD Phenom! X4 955 3.2GHz and 3 GB
memory. The computer programs were written by the C
language and Borland C++ Compiler 5.5 was used.
A. Results for Quntum Tic-Tac-Toe (Original Rule) (a) (b)
1) Results on Winning Strategy Figure 5. Example of first player’s naroow win: (a) Cyclic entanglement at
the ninth move; (b) Narrow win aschieved by the first player.
For brevity, we call the search programs for the first
player’s complete win and narrow win as FCW and FNW, player at the ninth move places quantum marks to (6, 9) and
respectively. Similarly, we call the search programs for the
second player’s complete win and narrow win as SCW and generates cyclic entanglement. If the second player fixes 9 to
SNW, respectively. Table I shows the search results for FCW, square 6, then the first player solely achieves three marks in the
FNW, SCW, and SNW. In the table, the second column first row and wins. On the other hand, if the second player fixes
indicates the existence of a winner, where ‘(1, 9)’ for FNW
means that the first player wins with the first quantum marks to 9 to square 9 as shown in Fig. 5(b), then the first player
squares (1, 9). The third column indicates the numbers of achieves three marks in the first row and the second player
vertices of the game trees. The fourth column indicates the achieves three marks in the second row. Since the first player’s
average number of vertices at depth two, that is, the average largest subscript of the three marks is 7 and that of the second
number of moves to be checked for 2 of the second player player is 8, the game ends with the first player’s narrow win.
(the smaller this value is, the more pruning of game tree
occurs). The total computing time is 319.23 seconds. When the 2) Minimality of the Number of Moves
search is restricted to FNW and FNW, the computing time is
172.73 seconds. In order to show that nine moves are necessary for the first
player’s narrow win, it is enough to show that there exists no
By Table I, Quantum Tic-Tac-Toe is shown to be a draw winning strategy for the game tree such that (1, 9) of the first
under the criterion of complete win. Under the criterion of move is fixed and the depth of the game tree is restricted to
narrow win, the first player wins only by the first diagonal eight, that is, we stop the game-tree search after the eighth
move (1, 9) (and (3, 7)). This result seems to be somewhat move (of the second player). The search results are shown in
surprising because intuitively, the center square, i.e., square 5, Table II. By Table II, there is no narrow win for the first player.
would be desirable to be marked first as in the case of classical
Tic-Tac-Toe. Consequently, nine moves are necessary and sufficient for
the first player’s narrow win.
Further observation is that at FCW, by the results that the
average number of vertices for 2 is 2.13 out of 36 vertices, TABLE II. RESULTS FOR NARROW WIN WITH DEPTHS EIGHT
we see that the second player’s first move prevents the first
player to win against most of the first player’s first move. As Search Win Num. of Avg Num. of Computing
for SNW and SCW, after knowing the first player’s narrow win, Method None Vertices Vertices for " 2 Time [s]
these programs only answer that there is no win for the second 00.10
player, however, we executed them to see whether there exists FCW 118,754 1.00
win of the second player if the first player does not place to (1,
9) at the first move. The result is that the second player cannot 3) Acceleration of Computing Time
win even when the first player’s first move is not (1, 9).
We further examined acceleration of computing time based
We show the example of the first player’s narrow win in on the move ordering methods stated in Section IV, B. The
Fig. 5. Fig. 5(a) shows the situation after the eight moves methods we consider are illustrated as follows.
where 2 , 3, 4 , 5 , 6 are already fixed. Then the first
333
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
Method 1-a: The alphabetical move ordering TABLE VIII. COMPARISON OF ORDERING METHODS
Method 1-b: The alphabetical move ordering with
priority in cyclic entanglement
Method 2-a: Move ordering with priority “corner >
center > remaining”
Method 2-b: Move ordering with priority “corner >
center > remaining” and in cyclic entanglement
Method 3-a: Move ordering with priority “center >
corner > remaining”
Method 3-b: Move ordering with priority “center >
corner > remaining” and in cyclic entanglement
For comparison, search programs FNW and FCW with By Table VIII, we first observe that the methods of giving
combination of respective move ordering methods are used. priority in center square (Methods 3-a, 3-b) achieve
The results are summarized in Tables III to VII (we note that tremendous reduction in computing time, and mostly they are
Method 1-a is used in Table I). The comparison of the more than ten times faster than Methods 1-* and 2-*.
computing times is shown in Table VIII. Furthermore, priority in cyclic entanglement (Methods 1-b, 2-b,
and 3-b) achieves sure reduction in time and about 1.6 times
TABLE III. RESULTS FOR ORDERING METHOD 1-B faster on average than the methods without it. In all, Method 3-
b achieves the best performance which is 19.7 times as fast as
Search Win Num. of Avg Num. of Computing that of the original Method 1-a of alphabetical move ordering.
Method Vertices Vertices for " 2 Time [s]
None 26,939,590 36.38 B. Results for Quntum Tic-Tac-Toe (Modified Rule)
FCW (1, 9) 53,210,944 2.88 072.29
FNW 8.63 1) Results on Winning Strategy
Total — 80,150,534 — 108.67
We also examined winning strategies of Quantum Tic-Tac-
TABLE IV. RESULTS FOR ORDERING METHOD 2-A Toe with the modified rule such that the player who generates
cyclic entanglement instead of the opponent fixes the quantum
Search Win Num. of Avg Num. of Computing marks. The results are summarized in Table IX.
Method Vertices Vertices for " 2 Time [s]
None 44,959,854 062.83 Different from the original rule, in this game, there exists
FCW (1, 9) 63,454,435 2.00 082.86 complete win of the first player by the first move (1, 3). There
FNW 9.38 are also narrow win of the first player by the first moves (1, 6),
Total — 108,414,289 — 145.69 (1, 9), and (2, 8) along with (1, 3). These results imply that this
modified rule provides strong advantage to the first player.
TABLE V. RESULTS FOR ORDERING METHOD 2-B Therefore, the original rule of giving the opponent the right to
fix the quantum marks at cyclic entanglement should be quite
Search Win Num. of Avg Num. of Computing reasonable to balance the power of the players.
Method Vertices Vertices for " 2 Time [s]
None 17,666,353 24.33 We show the example of the first player’s complete win in
FCW (1, 9) 36,315,973 2.88 47.65 Fig. 6. Fig. 6(a) shows the situation after the eight moves
FNW 10.00
Total — 53,982,326 — 71.98 where 2 , 3, 4 , 5 , 6 , 7 are already fixed. Then
TABLE VI. RESULTS FOR ORDERING METHOD 3-A the first player at the ninth move places quantum marks to (1,
6) and generates cyclic entanglement with squares 1, 3, and 6.
Search Win Num. of Avg Num. of Computing TABLE IX. SEARCH RESULTS FOR THE MODIFIED RULE
Method Vertices Vertices for " 2 Time [s]
None 2,880,305 3.45 Search Num. of Avg Num. of Computing
FCW (1, 9) 5,692,464 1.13 6.67 Method Win Vertices for " 2 Time [s]
FNW — 7.00 8.50
Total 8,572,769 — 10.12 FCW Vertices 12.75
(1, 3) 08,187,395 17.68
TABLE VII. RESULTS FOR ORDERING METHOD 3-B FNW (1, 3), (1, 6) 16,660,087 22.88
(1, 9), (2, 8) 10.21
Search Win Num. of Avg Num. of Computing SNW None 09,408,482 37.00 6.91
Method Vertices Vertices for " 2 Time [s] SCW None 06,656,866 37.00
None 2,430,744 2.76 Total — 43.30
FCW (1, 9) 5,019,482 2.13 5.99 — 40,912,830
FNW 7.38
Total — 7,450,226 — 8.75
334