Combinatorial game theory has several ways of measuring game complexity. This article describes five of them: state-space complexity, game tree size, decision complexity, game-tree complexity, and computational complexity.
Measures of game complexity
The state-space complexity of a game is the number of legal game positions reachable from the initial position of the game.
When this is too hard to calculate, an upper bound can often be computed by including illegal positions or positions that can never arise in the course of a game.
Game tree size
The game tree size is the total number of possible games that can be played: the number of leaf nodes in the game tree rooted at the game's initial position.
The game tree is typically vastly larger than the state space because the same positions can occur in many games by making moves in a different order (for example, in a tic-tac-toe game with two X and one O on the board, this position could have been reached in two different ways depending on where the first X was placed). An upper bound for the size of the game tree can sometimes be computed by simplifying the game in a way that only increases the size of the game tree (for example, by allowing illegal moves) until it becomes tractable.
However, for games where the number of moves is not limited (for example by the size of the board, or by a rule about repetition of position) the game tree is infinite.
The next two measures use the idea of a decision tree. A decision tree is a subtree of the game tree, with each position labelled with "player A wins", "player B wins" or "drawn", if that position can be proved to have that value (assuming best play by both sides) by examining only other positions in the graph. (Terminal positions can be labelled directly; a position with player A to move can be labelled "player A wins" if any successor position is a win for A, or labelled "player B wins" if all successor positions are wins for B, or labelled "draw" if all successor positions are either drawn or wins for B. And correspondingly for positions with B to move.)
Decision complexity of a game is the number of leaf nodes in the smallest decision tree that establishes the value of the initial position.
The game-tree complexity of a game is the number of leaf nodes in the smallest full-width decision tree that establishes the value of the initial position. A full-width tree includes all nodes at each depth.
This is an estimate of the number of positions we would have to evaluate in a minimax search to determine the value of the initial position.
It's hard even to estimate the game-tree complexity, but for some games a reasonable lower bound can be given by raising the game's average branching factor to the power of the number of plies in an average game, or:
The computational complexity of a game describes the asymptotic difficulty of a game as it grows arbitrarily large, expressed in big O notation or as membership in a complexity class. This concept doesn't apply to particular games, but rather to games that have been generalized so they can be made arbitrarily large, typically by playing them on an n-by-n board. (From the point of view of computational complexity a game on a fixed size of board is a finite problem that can be solved in O(1), for example by a look-up table from positions to the best move in each position.)
For tic-tac-toe, a simple upper bound for the size of the state space is 39 = 19,683. (There are three states for each cell and nine cells.) This count includes many illegal positions, such as a position with five crosses and no noughts, or a position in which both players have a row of three. A more careful count, removing these illegal positions, gives 5,478. And when rotations and reflections of positions are considered identical, there are only 765 essentially different positions.
A simple upper bound for the size of the game tree is 9! = 362,880. (There are nine positions for the first move, eight for the second, and so on.) This includes illegal games that continue after one side has won. A more careful count gives 255,168 possible games. When rotations and reflections of positions are considered the same, there are only 26,830 possible games.
The computational complexity of tic-tac-toe depends on how it is generalized. A natural generalization is to m,n,k-games: played on an m by n board with winner being the first player to get k in a row. It is immediately clear that this game can be solved in DSPACE(mn) by searching the entire game tree. This places it in the important complexity class PSPACE. With some more work it can be shown to be PSPACE-complete.
Complexities of some well-known games
Due to the large size of game complexities, this table gives the ceiling of their logarithm to base 10. All of the following numbers should be considered with caution: seemingly-minor changes to the rules of a game can change the numbers (which are often rough estimates anyway) by tremendous factors, which might easily be much greater than the numbers shown.
(as log to base 10)
(as log to base 10)
|Average game length
|Branching factor||Ref||Complexity class of suitable generalized game|
|Pentominoes||64||12||18||10||75||||?, but in PSPACE|
|Kalah ||14||13||18||||Generalization is unclear|
|Connect Four||42||13||21||36||4||||?, but in PSPACE|
|Domineering (8 × 8)||64||15||27||30||8||||?, but in PSPACE; in P for certain dimensions|
|English draughts (8x8) (checkers)||32||20 or 18||31||70||2.8|| or ||EXPTIME-complete|
|Awari||12||12||32||60||3.5||||Generalization is unclear|
|Fanorona||45||21||46||44||11||||?, but in EXPTIME|
|Nine Men's Morris||24||10||50||50||10||||?, but in EXPTIME|
|International draughts (10x10)||50||30||54||90||4||||EXPTIME-complete|
|Chinese checkers (2 sets)||121||23||||EXPTIME-complete |
|Chinese checkers (6 sets)||121||78||||EXPTIME-complete |
|Lines of Action||64||23||64||44||29||||?, but in EXPTIME|
|OnTop (2p base game)||72||88||62||31||23.77|||
|Gomoku (15x15, freestyle)||225||105||70||30||210||||PSPACE-complete|
|Chess||64||47||123||80||35||||EXPTIME-complete (without 50-move drawing rule) |
|Backgammon||28||20||144||50-60||250||||Generalization is unclear|
|Xiangqi||90||48||150||95||38||||?, believed to be EXPTIME-complete|
|Abalone||61||25||154||87||60||||?, but in EXPTIME|
|Quoridor||81||42||162||91||60||||?, but in PSPACE|
|Carcassonne (2p base game)||72||>40||195||71||55||||Generalization is unclear|
|Amazons (10x10)||100||40||212||84||374 or 299||||PSPACE-complete|
|Arimaa||64||43||402||92||17281||||?, but in EXPTIME|
|Double dummy bridge||(52)||<17||<40||52||5.6|
|Bejeweled and Candy Crush (8x8)||64||<50||||NP-hard|
- Go and mathematics
- Solved game
- Shannon number
- list of NP-complete games and puzzles
- list of PSPACE-complete games and puzzles
Notes and references
- Victor Allis (1994). Searching for Solutions in Games and Artificial Intelligence (Ph.D. thesis). University of Limburg, Maastricht, The Netherlands. ISBN 90-900748-8-0.
- Stefan Reisch (1980). "Gobang ist PSPACE-vollstandig (Gomoku is PSPACE-complete)". Acta Informatica 13: 5966.
- Wolfgang Slany: The Complexity of Graph Ramsey Games
- H. J. van den Herik; J. W. H. M. Uiterwijk; J. van Rijswijck (2002). "Games solved: Now and in the future". Artificial Intelligence 134 (1–2): 277–311. doi:10.1016/S0004-3702(01)00152-7.
- Hilarie K. Orman: Pentominoes: A First Player Win in Games of no chance, MSRI Publications – Volume 29, 1996, pages 339-344. Online: pdf.
- See van den Herik et al for rules.
- John Tromp (2010). "John's Connect Four Playground".
- Michael Lachmann (July 2000). Who wins domineering on rectangular boards?. MSRI Combinatorial Game Theory Research Workshop.
- Jonathan Schaeffer et al. (July 6, 2007). "Checkers is Solved". Science 317 (5844): 1518–1522. doi:10.1126/science.1144079. PMID 17641166.
- J. M. Robson (1984). "N by N checkers is Exptime complete". SIAM Journal on Computing, 13 (2): 252–267. doi:10.1137/0213018.
- See Allis 1994 for rules
- M.P.D. Schadd, M.H.M. Winands, J.W.H.M. Uiterwijk, H.J. van den Herik and M.H.J. Bergsma (2008). "Best Play in Fanorona leads to Draw". New Mathematics and Natural Computation 4 (3): 369–387. doi:10.1142/S1793005708001124.
- G.I. Bell (2009). "The Shortest Game of Chinese Checkers and Related Problems". Integers. arXiv:0803.1245.
- Takumi Kasai, Akeo Adachi, and Shigeki Iwata (1979). "Classes of Pebble Games and Complete Problems". SIAM Journal on Computing 8 (4): 574–586. doi:10.1137/0208046. Proves completeness of the generalization to arbitrary graphs.
- Mark H.M. Winands (2004). Informed Search in Complex Games (Ph.D. thesis). Maastricht University, Maastricht, The Netherlands. ISBN 90-5278-429-9.
- S. Iwata and T. Kasai (1994). "The Othello game on an n*n board is PSPACE-complete". Theor. Comp. Sci. 123 (2): 329–340. doi:10.1016/0304-3975(94)90131-7.
- Robert Briesemeister (2009). Analysis and Implementation of the Game OnTop (Thesis). Maastricht University, Dept of Knowledge Engineering.
- Stefan Reisch (1981). "Hex ist PSPACE-vollständig (Hex is PSPACE-complete)". Acta Inf. (15): 167–191.
- John Tromp and Gunnar Farnebäck (2007). "Combinatorics of Go". This paper derives the bounds 48<log(log(N))<171 on the number of possible games N.
- J. M. Robson (1983). "The complexity of Go". Information Processing; Proceedings of IFIP Congress. pp. 413–417.
- The size of the state space and game tree for chess were first estimated in Claude Shannon (1950). "Programming a Computer for Playing Chess". Philosophical Magazine 41 (314). Shannon gave estimates of 1043 and 10120 respectively, smaller than the upper bound in the table, which is detailed in Shannon number.
- Aviezri Fraenkel and D. Lichtenstein (1981). "Computing a perfect strategy for n×n chess requires time exponential in n". J. Comb. Th. A (31): 199–214.
- Chang-Ming Xu; Ma, Z.M.; Jun-Jie Tao; Xin-He Xu (2009). "Enhancements of proof number search in connect6". 2009 Chinese Control and Decision Conference. p. 4525. doi:10.1109/CCDC.2009.5191963. ISBN 978-1-4244-2722-2.
- On the fairness and complexity of generalized k-in-a-row games
- Shi-Jim Yen, Jr-Chang Chen, Tai-Ning Yang, and Shun-Chin Hsu (March 2004). "Computer Chinese Chess". International Computer Games Association Journal 27 (1): 3–18.
- Chorus, Pascal. "Implementing a Computer Player for Abalone Using Alpha-Beta and Monte-Carlo Search". Dept of Knowledge Engineering, Maastricht University. Retrieved 29 March 2012.
- Joosten, B. "Creating a Havannah Playing Agent". Retrieved 29 March 2012.
- E. Bonnet, F. Jamain and A. Saffidine (2014-03-25). "Havannah and TwixT are PSPACE-complete". arXiv:1403.6518 [cs.CC].
- Lisa Glendenning (May 2005). Mastering Quoridor. Computer Science (B.Sc. thesis). University of New Mexico.
- Cathleen Heyden (2009). Implementing a Computer Player for Carcassonne (Thesis). Maastricht University, Dept of Knowledge Engineering.
- The lower branching factor is for the second player.
- Julien Kloetzer; Hiroyuki Iida; Bruno Bouzy (2007). The Monte-Carlo Approach in Amazons.
- P. P. L. M. Hensgens (2001). A Knowledge-Based Approach of the Game of Amazons. Universiteit Maastricht, Institute for Knowledge and Agent Technology.
- R. A. Hearn (2005-02-02). "Amazons is PSPACE-complete". arXiv:cs.CC/0502013 [cs.CC].
- Hiroyuki Iida, Makoto Sakuta, Jeff Rollason (January 2002). "Computer shogi". Artificial Intelligence 134 (1–2): 121–144. doi:10.1016/S0004-3702(01)00157-6.
- H. Adachi, H. Kamekawa, and S. Iwata (1987). "Shogi on n × n board is complete in exponential time". Trans. IEICE. J70-D: 1843–1852.
- Christ-Jan Cox (2006). "Analysis and Implementation of the Game Arimaa".
- David Jian Wu (2011). "Move Ranking and Evaluation in the Game of Arimaa".
- Brian Haskin (2006). "A Look at the Arimaa Branching Factor".
- A.F.C. Arts (2010). Competitive Play in Stratego (Thesis). Maastricht.
- Double dummy bridge (i.e. double dummy problems in the context of contract bridge) is not a proper board game but has a similar game tree, and is studied in computer bridge, which motivates including it in the list. The bridge table can be regarded as having one slot for each player and trick to play a card in, which corresponds to board size 52. Game-tree complexity is a very weak upper bound: 13! to the power of 4 players regardless of legality. State-space complexity is for one given deal; likewise regardless of legality but with many transpositions eliminated. Note that the last 4 plies are always forced moves with branching factor 1.
- L. Gualà, S. Leucci, E. Natale (2014). "Bejeweled, Candy Crush and other Match-Three Games are (NP-)Hard".