1 / 58

電腦對局概論

電腦對局概論. 2012/05/02. Outline. 電腦對局基本原理 西洋棋 象棋 圍棋. Types of games. The Minimax Procedure. 零合遊戲 對手的失敗就是我的快樂. function A LPHA -B ETA -S EARCH ( state ) returns an action inputs : state , current state in game v  M AX -V ALUE ( state , –  ,   )

rocio
Télécharger la présentation

電腦對局概論

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 電腦對局概論 2012/05/02

  2. Outline • 電腦對局基本原理 • 西洋棋 • 象棋 • 圍棋

  3. Types of games

  4. The Minimax Procedure • 零合遊戲 • 對手的失敗就是我的快樂

  5. function ALPHA-BETA-SEARCH(state) returns an action inputs: state, current state in game v MAX-VALUE(state, –, ) return the action in SUCCESSORS(state) with value v function MAX-VALUE(state, ,  ) returns a utility value inputs: state, current state in game , the value of the best alternative for MAX along the path to state , the value of the best alternative for MIN along the path to state if TERMINAL-TEST(state) then return UTILITY(state) v  – fora, s in SUCCESSORS(state) do v  MAX(v, MIN-VALUE(s, ,  )) ifvthen returnv// fail-high   MAX(, v) returnv - Algorithm

  6. - Algorithm (cont.) function MIN-VALUE(state, ,  ) returns a utility value inputs: state, current state in game , the value of the best alternative for MAX along the path to state , the value of the best alternative for MIN along the path to state if TERMINAL-TEST(state) then return UTILITY(state) v   fora, s in SUCCESSORS(state) do v  MIN(v, MAX-VALUE(s, ,  )) ifvthen returnv // fail low   MIN(, v) returnv

  7. Negamax(B. Chen, 2010)

  8. Other Search Techniques • Null-Move heuristic • generate a good lower bound on the value of a position, using a shallow search in which the opponent gets to move twice at the beginning • the lower bound allows - pruning without the expense of a full-depth search

  9. Null-Move Forward Pruning • Instead of extending the search in hard positions, we reduce the search in easy positions • Allow a chess program to experience a dramatic reduction in branching factor with some manageable risk of missing something important • If I do nothing here, can the opponent do anything? • Assumption • Making a move will result in a higher score than not making a move, except in the endgame

  10. Null-Move Forward Pruning (cont.-1) • Before you generate any move, you do a reduced-depth search, with the opponent move first, even though it is usually not the best move • If that search result in a score  (fail high), then the true best move is also likely to fail high, and you return  right away without searching any moves • Idea • You give the opponent a free shot at you, if your position is still so good that you exceed , you assume that you’d also exceed  if you went and searched all of your moves

  11. Null-Move Forward Pruning (cont.-2) • Reason of saving time • The initial search is made with reduced depth • R: depth reduction factor • Rather than search all of your moves to depth D, you search all your opponent’s moves with a depth of D – R • An excellent value of R is 2 • Example • If you were going to search all your moves to depth 6, you end up searching all of your opponent’s moves to depth 4 • A practical speed up of a ply or two

  12. #define R 2 function ALPHA-BETA-SEARCH(depth, , ) returns an evaluation value ifdepth == 0 thenreturn EVALUATE() if last move was not null and position is unlikely to be zugzwangthen MAKENULLMOVE() v  –ALPHA-BETA-SEARCH (depth–1–R, –, –+1) UNMAKENULLMOVE() ifvthenreturn  GENERATELEGALMOVES() for each possible move do MAKENEXTMOVE() v  –ALPHA-BETA-SEARCH(depth–1, –, – ) UNMAKEMOVE() ifvthenreturn   MAX(, v) return minimal window (–1, ) Null-Move Algorithm

  13. Tricks • Minimal window • To see if the score of the null-move search is beta or better • If not, I don’t care how much worse than beta it is • Use minimal window (-1, ) to get more cutoffs faster • Note • Null-move changes the result of the search, and may cause you to miss some important line of play

  14. Should Not Use Null-Move • Null-move doesn’t work if the side to move is in check • The degree allowed to happen recursively should be considered, since if you let several of them follow in a row, the search degenerates down to just returning the evaluation • Not allow two null-move searches to occur without an intervening real move • Allow exactly two null-move searches before forcing a real move

  15. Violate the assumption Zugzwang: Positions in which all possible moves make the position worse Only use null-move in positions with many pieces left ? Should Not Use Null-Move (cont.)

  16. Solving games • Game-theoretic value of a game • The outcome, i.e., win, loss or draw, when all participants play optimally.

  17. Classication of games' solutions(L.V. Allis in 1994 ) • Ultra-weakly solved • the game-theoretic value of the initial position has been determined. • Weakly solved • for the initial position a strategy has been determined to achieve the game-theoretic value against any opponent. • The strategy must be efficient and practical in terms of resource usage. • Strongly solved: • a strategy has been determined for all legal positions.

  18. Complexity issue • State-space complexity of a game • the number of all legal positions in a game. • Game-tree (or decision) complexity of a game • the number of all leaf nodes in a solution search tree. • A solution search tree is a tree where the game-theoretic value of the root position can be decided. • .

  19. Complexity for Tic-Tac-Toe • Upper bound legal positions rotation and reflections • State space • 39 (19683)5478 765 • Game tree size • 9! 255168 26830

  20. Game tree (2-player, deterministic, turns)

  21. Fair game • A fair game • the game-theoretic value is draw and both players have roughly an equal probability on making a mistake

  22. A double dichotomy of the game space

  23. Games in practice • Predictions for 2010 at 2000(Herik et.al.)

  24. Games in practice • Status

  25. Chess • DeepBlue

  26. Minimax

  27. 象棋 • 子力 • 位置

  28. 子力

  29. ELP • 陳志昌、鄭武堯、許舜欽 • 1st Computer Olympiad 銅牌(1990) • 2nd Computer Olympiad金牌 • 4th Computer Olympiad銀牌 • 6th Computer Olympiad金牌 • 7th Computer Olympiad金牌 • 8th Computer Olympiad 銅牌 • 9th Computer Olympiad 銀牌 • 2004年世界電腦象棋爭霸賽第八名 • 2007年世界電腦象棋爭霸賽第三名

  30. 象棋世家 • 2004世界電腦象棋賽第四名 • 2007世界電腦象棋賽第二名 • 2010世界電腦象棋賽第二名 • 總會榮譽六段證書 • 6th、7th、10th、11th、14th Olympiad銀牌 • 15th Olympiad金牌

  31. 人機大戰 • 2006年1月14日象棋世家紅先勝台灣象棋八段陳振國 • 2008年第九屆人機大賽,千慮、象棋世家、ELP及棋天大聖參賽,邀請三位七段及一位八段高手參賽,象棋程式三勝四和一負 •  2009年第十屆人機賽,千慮、象棋世家、ELP及天馬行空參賽,邀請二位七段和兩位八段高手參賽,人腦以三勝五和的成績獲勝 • 2010年12/27新竹交大,象棋世家一勝一和劉國華八段與馬仲威八段。

  32. 圍棋

  33. 棋子與棋盤

  34. 1 2 3 4 5 6 段 弱 強 12 9 5 4 3 2 1 Kyu 1 9 Dan 初學者 業餘 職業棋士 棋力分級

  35. 百萬美金的懸賞 • 應昌期先生曾提供一百萬美金給能夠寫出擊敗職業棋士的圍棋程式的人

  36. Rank of Computer Go

  37. 電腦棋類的設計方式 • 西洋棋,象棋 • game tree, α-βcut off • 成功原因 • 合法步不多(30~40) • 有一個簡單而合理的審局函數 • 此方式不適用於圍棋 • 合法步太多(>200) • 目前沒有好的審局函數

More Related