Download Hex

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
The Game of Hex
A Domain Specific Search
Technique For A Beautiful Game
Stefan Kiefer
This Talk
• presents the game of Hex and a (search)
method for Hex-playing computer programs
• 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:
– the rules of Hex
– the key concept of virtual connections
– applications of virtual connections
The Beginning
• 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.
Object of the game is to make a continuous chain
of your color to connect your sides of the board.
Simple Rules
– Play anywhere: Very wide game tree
• 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
The Board
The Challenge
• Write a program that plays Hex!
• 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?
The Challenge (cont‘d)
• Given this
position:
• Who can win (assuming perfect play)?
– I don’t know.
– And: We have no efficient algorithm to figure it out!
Virtual Connections: Two-Bridges
a tactical element:
“two- bridges”
Blue can connect the blue
cells:
• even if red moves first!
• no matter what red
does!
This is called a
Virtual Connection
between the blue cells.
Virtual Connections: Two-Bridges
Virtual Connections: The AND-rule
• 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.
B
A
• The “carriers” A and B have to be disjoint.
Virtual Connections:
Edge Templates from the 3rd Row
• x-u and u-y are virtually
•
•
y
B
u
A
x
v
•
connected (by two-bridges).
u is not occupied.
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 SemiConnection between x and y.
Virtual Connections: Virtual SemiConnections and the OR-Rule
• Due to the same reason,
y
u
•
x
v
there is also a virtual semiconnection 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!
The OR-rule wrapped up
1. Build virtual semi-connections:
2. Combine them to a virtual connection:
Virtual Connections: Virtual SemiConnections and the OR-rule
u
x
y
v
Also the two-bridges can be
derived using the OR-rule:
• x and y are virtually semiconnected via u.
• x and y are also virtually semiconnected 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!
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
Straight-forward Calculation of
Virtual Connections (cont’d)
• This procedure combines – generation by
generation – existing virtual connections
to larger ones.
• Thus, a hierarchy of virtual connections
is defined.
• Large virtual connections can provide
information about the potential of Hex
positions far ahead.
Examples for Virtual Connections
found by the Algorithm: 4th row
Examples for Virtual Connections
found by the Algorithm: a Ladder
x
y
Examples for Virtual Connections
found by the Algorithm: a Win
Examples for Virtual Connections
found by the Algorithm: an early Win
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)
Limiting the search tree
• If Red sees the
virtual semiconnection
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!
An Evaluation Function
Idea:
• 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.
• The higher the current, the better the
position for Blue! A shortcut means win!
An Evaluation Function (cont’d)
An Evaluation Function (cont’d)
• 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:
– e.g. by dividing the currents: I(blue)/I(red).
– Then:
• A high value (>1) means an advantage for Blue.
• A low value (<1) means an advantage for Red.
An Evaluation Function: Enhanced
with Virtual Connections
• How to include virtual connections in the
circuits?
• Very natural: Put additional links (with a
small positive resistance) between
virtually connected cells.
• Thus, the current between virtually
connected cells is increased
– reflecting the fact that they can be actually
connected in the future.
An Evaluation Function: Enhanced
with Virtual Connections (cont’d)
An Evaluation Function: Enhanced
with Virtual Connections (cont’d)
• It turns out: A far-sighted evaluation
function can be created in this way.
• A shallow game-tree search (alphabeta) 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.
Results: The Performance
• The program “Hexy” (by Anshelevich himself)
•
•
•
was the first to employ the presented ideas.
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.
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.
References
• V. V. Anshelevich. A Hierarchical Approach
to Computer Hex. Artificial Intelligence,
134, 2002, pp.101-120.
• Hexy: http://home.earthlink.net/~vanshel/
• Six: http://hex.retes.hu/six/
• More Hex-links:
http://www.cs.ualberta.ca/~javhar/hex/
• [Rei81] Stefan Reisch: Hex ist PSPACEvollständig. Acta Informatica 15, 1981, pp.
167-191.
Incompleteness of the AND/ORrules
• Can all virtual connections be detected by
the presented algorithm using the AND/ORrules?
• Answer: No:
How much time does our algorithm
for virtual connections take?
• 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?
• Answer: No: The algorithm solves a
PSPACE-complete problem as well.
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?
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.
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.