常见棋类AI复杂度介绍

常见棋类AI复杂度介绍
本帖子是扫盲帖子,是关于棋类复杂度的介绍
这里介绍五种常见棋类:黑白棋,五子棋,中国象棋,国际象棋,围棋

黑白棋:相当经典的游戏,因为棋盘为8X8大小,且每一步变化不多,估算的搜索空间复杂度为10的28次方
而小棋盘版的6X6黑白棋,已经被软件穷尽所有变化,证明是后手必胜,人们猜测8X8也是后手必胜

五子棋:虽然是经典游戏,但在加入禁手,三手交换,五手两打后,变得复杂化起来,特别是禁手会存在各种假禁手,
导致禁手判断的工作一点也不轻松,日本曾有人出的一些禁手题,还能难倒很多爱好者。
目前,即使先不考虑禁手规则,而棋盘大小为15X15的五子棋,
考虑了开局有很多不必要的着法,剪掉以后,空间复杂度仍然有10的105次方
如果加入禁手规则,会让空间复杂度略减(当有禁手点出现的时候),但禁手判断的复杂性,却填补了这个复杂度的减小,
反而使软件的复杂度更大(拖慢软件搜索速度)

中国象棋:几百年以来唯一规则没变化过的古老棋类,棋盘比国际象棋稍大(9X10),
总变化也比国际象棋略多一些,为10的48次方

国际象棋:国际上知名度很高的棋类,并且他的发明的传说也一样出名(就是第一个格子放一个谷子,后面每格是前面的两倍那个)
它的空间复杂度比中国象棋稍低,为10的47次方

围棋:当之无愧的复杂度之王,拥有19X19的超大棋盘,空间复杂度高达10的360次方,居棋类复杂度之首,并且远远抛离第二名的棋类


可能有些人认为,五子棋的AI比象棋AI要容易实现?按状态空间复杂度来看,显然不是这样,
那为什么产生这个错觉?这是因为他看到的只是着法生成的复杂度

着法生成是棋类AI的一个组成部分,着法生成显然和棋类规则的复杂程度有关。对于以上几种棋类,显然是中国象棋和国际象棋的着法最为复杂
但这并不表明这个棋类就复杂,规则更简单的围棋显然不是这样
我猜很可能是他只看到着法生成器的复杂度,因为只要有着法生成器,电脑就已经能应对下子了,
再加上简单的静态评估函数,就可以实现最简单的AI,即使根本没有进行搜索。
但不搜索的AI没有任何意义

如何公平比较AI的实现难度呢?这些棋类都是竞技棋类,有严格的水平段位制
和人类相同段位的棋手做比较,拿五子棋和象棋的话,我们假设和五子棋的初段棋手,和中国象棋的初段棋手来比
目前最顶尖的五子棋软件是黑石,但总体水平只达到了职业初段,虽然局部攻杀水平极高,但也不能和人类最高水平棋手相较量
最顶尖的中国象棋软件,很多,有倚天,旋风,天机,大圣,奇兵,其中大圣曾和许银川(九段)六战成和

如果说国际象棋,最出名的当数1997年的深蓝之战,3.5 : 2.5 击败了人类最顶尖的棋手

其实这也可见,这和棋类的状态空间复杂度有着密切的联系,较低的空间复杂度的棋类,机器在人类面前显得水平越强
特别是黑白棋,自从zebra的出现,就把人类最顶尖棋手远远抛离

更多的其它棋类状态空间复杂度的比较,可以见wiki百科:
http://en.wikipedia.org/wiki/Game_complexity

部分英文词汇:
Chess   国际象棋
Xiangqi 中国象棋
Gomoku  无禁手的五子棋(Renju才是有禁手五子棋的名字)
Reversi 黑白棋(另一名字是Othello)
Go      围棋


Game complexity


Game complexity

From Wikipedia, the free encyclopedia

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.

Contents

   [hide

[edit]Measures of game complexity

[edit]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.[1]

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.

[edit]Game tree size

The game tree size is the total number of possible games that can be played: it's 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.

[edit]Decision trees

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.)

[edit]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. Such a tree includes all possible decisions for the player to move second, but only one possibility for each decision for the player who starts the game.

[edit]Game-tree complexity

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.[1] 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:

GTC ≥ b^d

[edit]Computational complexity

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.)

[edit]Example: tic-tac-toe

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 getk 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.[2]

[edit]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.

Game Board size

(cells)

State-space complexity

(as log to base 10)

Ref Game-tree complexity

(as log to base 10)

Ref Average game length

(plies)

Complexity class of suitable generalized game
Tic-tac-toe93 5 9PSPACE-complete[2]
Sim153 8 14?, but in PSPACE[3]
Pentominoes6412[4]18[4]10 [5]?, but in PSPACE
Kalah [6]1413[4]18[4] Generalization is unclear
Connect Four4213[7]21[1]36[1]?, but in PSPACE
Domineering (8 × 8)6415[4]27[4]32?, but in PSPACE; in P for certain dimensions[8]
Congkak-61415[4]33[4]  
English draughts (8x8) (checkers)3220 or 18[9] or[1]31[1]70[1]EXPTIME-complete[10]
Awari[11]1212[1]32[1]60[1]Generalization is unclear
Qubic6430[1]34[1]20[1]PSPACE-complete[2]
Fanorona4521[12]46[12]22?, but in EXPTIME
Nine Men's Morris2410[1]50[1]??, but in EXPTIME
International draughts (10x10)5030[1]54[1]90[1]EXPTIME-complete[10]
Chinese checkers (2 sets)12123[13]? ?EXPTIME-complete [14]
Chinese checkers (6 sets)12178 ? ?EXPTIME-complete [14]
Lines of Action6423[15]64[15]44[15]?, but in EXPTIME
Reversi6428[1]58[1]58[1]PSPACE-complete[16]
On Top[disambiguation needed] (2p base game)7288[17]62[17]31 
Hex (11x11)12157[4]98[4]40PSPACE-complete[18]
Gomoku (15x15, freestyle)225105[1]70[1]30[1]PSPACE-complete[2]
Go (9x9)8138[19]  45[1]EXPTIME-complete[20]
Chess6447[21]123[21]80EXPTIME-complete[22]
Connect6361172[23]140[23]30PSPACE-complete[24]
Backgammon2820 144 50-60[25]Generalization is unclear
Xiangqi9048[1]150[1]95[26]?, believed to be EXPTIME-complete
Abalone6125[27]154[27]87[27]?, but in EXPTIME
Havannah271127[4]157[4]66[28]?, but in PSPACE
Quoridor8142 162[29]91[29]?, but in PSPACE
Carcassonne (2p base game)72>40[30]195[30]71Generalization is unclear
Amazons (10x10)10040[31]212[31]80[32]PSPACE-complete[33]
Go (13x13)16979[19]  90[1]EXPTIME-complete[20]
Shogi8171[26]226[26]115 [34]EXPTIME-complete[35]
Arimaa6443[36]402[37]92[37]?, but in EXPTIME
Go (19x19)361171[19]360[1]150[1]EXPTIME-complete[20]
Stratego92115[38]535[38]381[38] 

[edit]See also


  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值