Game complexity: Difference between revisions

Content deleted Content added
Post-move cleanup: Changed link from Bejeweled to Bejeweled (video game) using Move+
m Reverted 1 edit by 2401:D800:B4:30E9:A7A9:79A9:75AC:EDC7 (talk) to last revision by Remsense
 
(15 intermediate revisions by 11 users not shown)
Line 2:
{{Use mdy dates|cs1-dates=ly|date=May 2023}}
 
[[Combinatorial game theory]] [[Computational complexity theory|measures]] '''game complexity''' in several ways:
 
#State-space complexity (the number of legal game positions from the initial position),
#Game tree size (total number of possible games),
#Decision complexity (number of leaf nodes in the smallest decision tree for initial position),
#Game-tree complexity (number of leaf nodes in the smallest full-width decision tree for initial position),
#Computational complexity (asymptotic difficulty of a game as it grows arbitrarily large).
 
These measures involve understanding the game positions, possible outcomes, and computation[[Computational complexity theory|computational requiredcomplexity]] forof various game scenarios.
 
==Measures of game complexity==
 
=== State-space complexity ===
The '''state-space complexity''' of a game is the number of legal game positions reachable from the initial position of the game.<ref name="Allis1994"/>
 
When this is too hard to calculate, an [[upper bound]] can often be computed by also counting (some) illegal positions, meaning (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:. This is the number of [[Leaf nodes#Terminology|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.
 
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 generally infinite.
 
=== Decision trees ===
TheA next two measures use the idea of a ''[[decision tree]]'', which is a subtree of the game tree, with each position labelled with "player A wins", "player B wins", or "drawndraw", 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 withdirectly—with player A to move, a position 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. (With Andplayer correspondinglyB forto positionsmove, withcorresponding Bpositions toare movemarked similarly.)
 
The following two methods of measuring game complexity use decision trees:
 
==== Decision complexity ====
'''Decision complexity''' of a game is the number of leaf nodes in the smallest decision tree that establishes the value of the initial position.
 
==== Game-tree complexity ====
The '''gameGame-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.<ref name="Allis1994"/> A full-width tree includes all nodes at each depth. This is an estimate of the number of positions one would have to evaluate in a [[minimax]] search to determine the value of the initial position.
 
It is hard even to estimate the game-tree complexity, but for some games an approximation can be given by raising<math>GTC \geq b^d</math>, where {{Mvar|b}} is the game's average [[branching factor]] and ''b{{Mvar|d}}'' to the power ofis the number of [[Ply (chess)|plies]] ''d'' in an average game, or:.
This is an estimate of the number of positions one would have to evaluate in a [[minimax]] search to determine the value of the initial position.
 
It is hard even to estimate the game-tree complexity, but for some games an approximation can be given by raising the game's average [[branching factor]] ''b'' to the power of the number of [[Ply (chess)|plies]] ''d'' in an average game, or:
 
<math>GTC \geq b^d</math>.
 
=== Computational complexity ===
The '''[[Computational complexity theory|''computational complexity'']]''' of a game describes the [[Asymptotic analysis|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 game|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.)
 
The asymptotic complexity is defined by the most efficient algorithm for solving the game (in terms of whatever [[computational resource]] one is considering). algorithm for solving the game; theThe most common complexity measure, ([[computation time]]), is always lower-bounded by the logarithm of the asymptotic state-space complexity, since a solution algorithm must work for every possible state of the game. It will be upper-bounded by the complexity of any particular algorithm that works for the family of games. Similar remarks apply to the second-most commonly used complexity measure, the amount of [[DSPACE|space]] or [[computer memory]] used by the computation. It is not obvious that there is any lower bound on the space complexity for a typical game, because the algorithm need not store game states; however many games of interest are known to be [[PSPACE-hard]], and it follows that their space complexity will be lower-bounded by the logarithm of the asymptotic state-space complexity as well (technically the bound is only a polynomial in this quantity; but it is usually known to be linear).
* The [[depth-first search|depth-first]] [[minimax strategy]] will use [[computation time]] proportional to the game's tree-complexity, (since it must explore the whole tree), and an amount of memory polynomial in the logarithm of the tree-complexity, (since the algorithm must always store one node of the tree at each possible move-depth, and the number of nodes at the highest move-depth is precisely the tree-complexity).
* [[Backward induction]] will use both memory and time proportional to the state-space complexity, as it must compute and record the correct move for each possible position.
 
==Example: tic-tac-toe (noughts and crosses)==
For [[tic-tac-toe]], a simple upper bound for the size of the state space is 3<sup>9</sup> = 19,683. (There are three states for each cellof andthe 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.<ref>{{Cite web|url=https://math.stackexchange.com/questions/485752/tictactoe-state-space-choose-calculation|title=combinatorics - TicTacToe State Space Choose Calculation|website=Mathematics Stack Exchange|access-date=2020-04-08}}</ref><ref>{{cite web|last=T|first=Brian|title=Btsan/generate_tictactoe|website=[[GitHub]] |date=2018-10-20|url=https://github.com/Btsan/generate_tictactoe|access-date=2020-04-08}}</ref> And when rotations and reflections of positions are considered identical, there are only 765 essentially different positions.
 
To bound the game tree, there are 9 possible initial moves, 8 possible responses, and so on, so that there are at most 9! or 362,880 total games. However, games may take less than 9 moves to resolve, and an exact enumeration 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 game|generalized]]. A natural generalization is to [[m,n,k-game|''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 thisThis game can be solved in [[DSPACE]](''mn'') by searching the entire game tree. This places it in the important complexity class [[PSPACE]]. With; somewith more work, it can be shown to be [[PSPACE-complete]].<ref name="Reisch1980b">{{cite journal | author = Stefan Reisch | title = Gobang ist PSPACE-vollständig (Gobang is PSPACE-complete) | journal = Acta Informatica | volume = 13 | issue = 1 | pages = 59–66 | year = 1980 | doi=10.1007/bf00288536| s2cid = 21455572}}</ref>
 
==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. (In other words, the number of digits). 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.
 
Note: ordered by game tree size
 
{{sticky header}}
{| class="wikitable sortable sticky-header"
|-
!Game
Line 275 ⟶ 272:
|style="text-align:right;"|180
|style="text-align:right;"|<ref name=Bell_Halma>{{cite journal|author=G.I. Bell|title=The Shortest Game of Chinese Checkers and Related Problems|journal=Integers|year=2009|volume=9|doi=10.1515/INTEG.2009.003|arxiv=0803.1245|bibcode=2008arXiv0803.1245B|s2cid=17141575}}</ref>
|[[EXPTIME]]-complete <ref name=pebble>{{cite journal
| last1 = Kasai | first1 = Takumi
| last2 = Adachi | first2 = Akeo
Line 295 ⟶ 292:
|style="text-align:right;"|600
|style="text-align:right;"|<ref name=Bell_Halma/>
|[[EXPTIME]]-complete <ref name=pebble/>
|-
|[[Reversi]] (Othello)
Line 516 ⟶ 513:
| title = Computer Games Workshop, Amsterdam, the Netherlands, 15-17 June 2007
| year = 2007}}</ref><ref name="Hengens_thesis">{{cite web |author=P. P. L. M. Hensgens |title=A Knowledge-Based Approach of the Game of Amazons |year=2001 |publisher=Universiteit Maastricht, Institute for Knowledge and Agent Technology |url=https://project.dke.maastrichtuniversity.nl/games/files/msc/Hensgens_thesis.pdf}}</ref>
|[[PSPACE-complete]]<ref>{{cite arXiv | author = R. A. Hearn | author-link=Bob Hearn | title = Amazons is PSPACE-complete | date = 2005-02-02 | eprint = cs.CC/0502013 }}</ref>
|-
|[[Shogi]]
Line 539 ⟶ 536:
|style="text-align:right;"|361
|style="text-align:right;"|170
|style="text-align:right;"|360505
|style="text-align:right;"|150211
|style="text-align:right;"|250
|style="text-align:right;"|<ref name="Allis1994"/><ref name="cwi">{{cite web | title = Combinatorics of Go |author1=John Tromp |author2=Gunnar Farnebäck | year = 2007 | url = https://tromp.github.io/go/gostate.ps}} This paper derives the bounds 48&lt;log(log(''N''))&lt;171 on the number of possible games ''N''.</ref><ref name="Tromp2016">{{cite web | title=Number of legal Go positions | author=John Tromp | year=2016 | url=https://tromp.github.io/go/legal.html}}</ref>
<ref>{{Cite web|url=https://homepages.cwi.nl/~aeb/go/misc/gostat.html|title = Statistics on the length of a go game}}</ref>
|[[EXPTIME-complete]] (without the [[superko rule]])<ref name="Robson1983">{{Cite book | author = J. M. Robson | chapter = The complexity of Go | title = Information Processing; Proceedings of IFIP Congress | year = 1983 | pages = 413–417}}</ref>
|-
Line 570 ⟶ 568:
|style="text-align:right;"|infinite
|style="text-align:right;"|<ref>{{cite arXiv | author = CDA Evans and Joel David Hamkins | title = Transfinite game values in infinite chess | year = 2014| class = math.LO | eprint = 1302.4377 }}</ref>
|{{Unknown}}, but mate-in-''n'' is decidable<ref name="Brumleve2012">{{cite journal | author = Stefan Reisch, Joel David Hamkins, and Phillipp Schlicht | title = The mate-in-n problem of infinite chess is decidable | journal = Conference on Computability in Europe | year = 2012 | pages = 78–88 | arxiv = 1201.5597 }}</ref>
|-
|[[Magic: The Gathering]]
Line 583 ⟶ 581:
|[[Wordle]]
|style="text-align:right;"|5
|style="text-align:right;"|4.113 (12,972)
|style="text-align:right;"|
|style="text-align:right;"|6
|style="text-align:right;"|
|style="text-align:right;"|<ref>{{cite arXiv |last1=Lokshtanov |first1=Daniel |last2=Subercaseaux |first2=Bernardo |date=2022-05-14 |title=Wordle is NP-hard |class=cs.CC |eprint=2203.16713 }}</ref>
|[[NP-hardness|NP-hard]], unknown if [[PSPACE-complete]] with parametization.
|}
 
Line 611 ⟶ 609:
 
[[Category:Combinatorial game theory]]
[[Category:Game theory]]