Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Game of Hex A Domain Specific Search Technique For A Beautiful Game Stefan Kiefer.

Similar presentations


Presentation on theme: "The Game of Hex A Domain Specific Search Technique For A Beautiful Game Stefan Kiefer."— Presentation transcript:

1 The Game of Hex A Domain Specific Search Technique For A Beautiful Game Stefan Kiefer

2 This Talk presents the game of Hex and a (search) method for Hex-playing computer programs presents the game of Hex and a (search) method for Hex-playing computer programs is mainly based on the information of the following paper: is mainly based on the information of the following paper: –V. V. Anshelevich. A Hierarchical Approach to Computer Hex. Artificial Intelligence, 134, 2002, pp.101-120. wants to explain: wants to explain: –the rules of Hex –the key concept of virtual connections –applications of virtual connections

3 The Beginning Invented independently by Piet Hein in 1942 and John Nash in 1948. Invented independently by Piet Hein in 1942 and John Nash in 1948. Played on a grid of hexagons. A standard size is 11x11. Also common: 10x10, 14x14, 19x19. Played on a grid of hexagons. A standard size is 11x11. Also common: 10x10, 14x14, 19x19. Object of the game is to make a continuous chain of your color to connect your sides of the board. Object of the game is to make a continuous chain of your color to connect your sides of the board. Simple Rules Simple Rules –Play anywhere: Very wide game tree Nice properties: Nice properties: –First Player Win (easy proof) –No Ties (intuitively easy) Unfortunately: not widely played by humans, not yet ;-) but you can play at www.playsite.com Unfortunately: not widely played by humans, not yet ;-) but you can play at www.playsite.com

4 The Board

5 The Challenge Write a program that plays Hex! Write a program that plays Hex! Difficult: Difficult: –The board is large: Every empty cell is a legal move.  The game tree is wide: b =~ 80 between chess (b =~ 35) and go (b =~ 250)  Massive Alpha-Beta-Search doesn’t work well. –Determining the winner (assuming perfect play) in an arbitrary Hex position is PSPACE-complete [Rei81]. How to get knowledge about the “potential” of a given position without massive game-tree search? How to get knowledge about the “potential” of a given position without massive game-tree search?

6 The Challenge (cont‘d) Who can win (assuming perfect play)? Who can win (assuming perfect play)? –I don’t know. –And: We have no efficient algorithm to figure it out! Given this position: Given this position:

7 Virtual Connections: Two-Bridges a tactical element: “two- bridges” Blue can connect the blue cells: even if red moves first! even if red moves first! no matter what red does! no matter what red does! This is called a Virtual Connection between the blue cells.

8 Virtual Connections: Two-Bridges

9 Virtual Connections: The AND-rule Virtual connections can be combined to larger virtual connections. Virtual connections can be combined to larger virtual connections. The AND-rule: two virtual connections with a common occupied end together form a larger virtual connection. The AND-rule: two virtual connections with a common occupied end together form a larger virtual connection. The “carriers” A and B have to be disjoint. The “carriers” A and B have to be disjoint. A B

10 Virtual Connections: Edge Templates from the 3rd Row u x v y x-u and u-y are virtually connected (by two-bridges). x-u and u-y are virtually connected (by two-bridges). u is not occupied. u is not occupied. But, if Blue moves first, (s)he can establish a virtual connection by playing on u. But, if Blue moves first, (s)he can establish a virtual connection by playing on u. The situation in the red oval is called a Virtual Semi- Connection between x and y. The situation in the red oval is called a Virtual Semi- Connection between x and y. A B

11 Virtual Connections: Virtual Semi- Connections and the OR-Rule u xv y Due to the same reason, there is also a virtual semi- connection between x and y via v. Due to the same reason, there is also a virtual semi- connection between x and y via v. Because the intersection of the carriers of both virtual semi-connections is empty, we can combine them to a full virtual connection! Because the intersection of the carriers of both virtual semi-connections is empty, we can combine them to a full virtual connection!

12 The OR-rule wrapped up 1. Build virtual semi-connections: 2. Combine them to a virtual connection:

13 Also the two-bridges can be derived using the OR-rule: x and y are virtually semi- connected via u. x and y are virtually semi- connected via u. x and y are also virtually semi- connected via v. x and y are also virtually semi- connected via v. Application of the OR-rule yields a virtual connection between x and y using {u,v} as the carrier.  the well-known two-bridge! Application of the OR-rule yields a virtual connection between x and y using {u,v} as the carrier.  the well-known two-bridge! Virtual Connections: Virtual Semi- Connections and the OR-rule x y u v

14 Straight-forward Calculation of Virtual Connections VC := neighboring cells; // these are trivial virtual connections // with empty carriers: “first generation” Repeat apply AND/OR-rules to VC and add the new virtual connections to VC Until no new virtual connections are found; Return VC

15 Straight-forward Calculation of Virtual Connections (cont’d) This procedure combines – generation by generation – existing virtual connections to larger ones. This procedure combines – generation by generation – existing virtual connections to larger ones. Thus, a hierarchy of virtual connections is defined. Thus, a hierarchy of virtual connections is defined. Large virtual connections can provide information about the potential of Hex positions far ahead. Large virtual connections can provide information about the potential of Hex positions far ahead.

16 Examples for Virtual Connections found by the Algorithm: 4th row

17 Examples for Virtual Connections found by the Algorithm: a Ladder x y

18 Examples for Virtual Connections found by the Algorithm: a Win

19 Examples for Virtual Connections found by the Algorithm: an early Win

20 Applications of Virtual Connections 1. Proving a win for a player (as seen on the previous two slides) 2. Limiting the search tree (see next slide) 3. Building a good evaluation function (see later)

21 Limiting the search tree If Red sees the virtual semi- connection between the two blue sides, then (s)he has to play there. If Red sees the virtual semi- connection between the two blue sides, then (s)he has to play there. Otherwise, Blue plays on the cyan cell and turns the virtual semi-connection into a virtual connection and wins! Otherwise, Blue plays on the cyan cell and turns the virtual semi-connection into a virtual connection and wins!

22 An Evaluation Function Idea: As in virtual connections, look at the board from one player’s (e.g. Blue’s) perspective. As in virtual connections, look at the board from one player’s (e.g. Blue’s) perspective. Put wires and resistors (yes, electrical ones) in the board and apply a voltage between the blue sides. Put wires and resistors (yes, electrical ones) in the board and apply a voltage between the blue sides. The higher the current, the better the position for Blue! A shortcut means win! The higher the current, the better the position for Blue! A shortcut means win!

23 An Evaluation Function (cont’d)

24 Do for both players: Do for both players: –Put in the wires, resistors and apply the voltage. –Calculate the total current using Kirchhoff’s laws (linear equation system). Compare the “blue” and the “red” circuit: Compare the “blue” and the “red” circuit: –e.g. by dividing the currents: I(blue)/I(red). –Then: A high value (>1) means an advantage for Blue. A high value (>1) means an advantage for Blue. A low value (<1) means an advantage for Red. A low value (<1) means an advantage for Red.

25 An Evaluation Function: Enhanced with Virtual Connections How to include virtual connections in the circuits? How to include virtual connections in the circuits? Very natural: Put additional links (with a small positive resistance) between virtually connected cells. Very natural: Put additional links (with a small positive resistance) between virtually connected cells. Thus, the current between virtually connected cells is increased Thus, the current between virtually connected cells is increased –reflecting the fact that they can be actually connected in the future.

26 An Evaluation Function: Enhanced with Virtual Connections (cont’d)

27 It turns out: A far-sighted evaluation function can be created in this way. It turns out: A far-sighted evaluation function can be created in this way. A shallow game-tree search (alpha- beta) is then sufficient. A shallow game-tree search (alpha- beta) is then sufficient. Modern Hex-playing programs (like Hexy) spend most of their time in the detection of virtual connections in order to enhance the evaluation function. Modern Hex-playing programs (like Hexy) spend most of their time in the detection of virtual connections in order to enhance the evaluation function.

28 Results: The Performance The program “Hexy” (by Anshelevich himself) was the first to employ the presented ideas. The program “Hexy” (by Anshelevich himself) was the first to employ the presented ideas. It won the computer olympiad tournament in 2000. It won the computer olympiad tournament in 2000. According to its author, Hexy doesn’t reach the playing strength of the best human players. He played with Hexy at www.playsite.com. According to its author, Hexy doesn’t reach the playing strength of the best human players. He played with Hexy at www.playsite.com.www.playsite.com Recently, the open source program “Six” was developed, based on the same ideas. It won the computer olympiad 2003 last week. Hexy didn’t take part. Recently, the open source program “Six” was developed, based on the same ideas. It won the computer olympiad 2003 last week. Hexy didn’t take part.

29 References V. V. Anshelevich. A Hierarchical Approach to Computer Hex. Artificial Intelligence, 134, 2002, pp.101-120. V. V. Anshelevich. A Hierarchical Approach to Computer Hex. Artificial Intelligence, 134, 2002, pp.101-120. Hexy: http://home.earthlink.net/~vanshel/ Hexy: http://home.earthlink.net/~vanshel/http://home.earthlink.net/~vanshel/ Six: http://hex.retes.hu/six/ Six: http://hex.retes.hu/six/http://hex.retes.hu/six/ More Hex-links: http://www.cs.ualberta.ca/~javhar/hex/ More Hex-links: http://www.cs.ualberta.ca/~javhar/hex/ http://www.cs.ualberta.ca/~javhar/hex/ [Rei81] Stefan [Rei81] Stefan Reisch: Hex ist PSPACE- vollständig. Acta Informatica 15, 1981, pp. 167-191.

30 Incompleteness of the AND/OR- rules Can all virtual connections be detected by the presented algorithm using the AND/OR-rules? Can all virtual connections be detected by the presented algorithm using the AND/OR-rules? Answer: No: Answer: No:

31 How much time does our algorithm for virtual connections take? We know: We know: –Determining the winner of an arbitrary Hex position is PSPACE-complete. –The AND/OR-rules are incomplete, i.e., they don’t discover all virtual connections. So, maybe our algorithm (using only AND/OR-rules) can be implemented efficiently? So, maybe our algorithm (using only AND/OR-rules) can be implemented efficiently? Answer: No: The algorithm solves a PSPACE-complete problem as well. Answer: No: The algorithm solves a PSPACE-complete problem as well.

32 Virtual Connections: Are they still useful? The previous two slides showed disadvantages of virtual connections and the AND/OR-rules. What does that tell us? The previous two slides showed disadvantages of virtual connections and the AND/OR-rules. What does that tell us? Well, these were theoretical results, not always meaningful to the practice… Well, these were theoretical results, not always meaningful to the practice… The calculation of virtual connections has already been proven to be useful in practice. The calculation of virtual connections has already been proven to be useful in practice. Since it is computationally expensive, good heuristics need to be developed: Since it is computationally expensive, good heuristics need to be developed: –Which computed virtual connections should be combined (by which rules)? –When to stop with the search for virtual connections? This is a research challenge for the future. This is a research challenge for the future.


Download ppt "The Game of Hex A Domain Specific Search Technique For A Beautiful Game Stefan Kiefer."

Similar presentations


Ads by Google