hex a game of connections. the beginning invented independently by piet hein in 1942 and john nash...

26
Hex Hex A game of connections A game of connections

Post on 20-Dec-2015

229 views

Category:

Documents


2 download

TRANSCRIPT

HexHex

A game of connectionsA game of connections

The BeginningThe Beginning

• Invented independently by Piet Hein in 1942 and Invented independently by Piet Hein in 1942 and John Nash in 1948.John Nash in 1948.

• Played on a grid of hexagons. Standard size for Played on a grid of hexagons. Standard size for tournaments is 11x11 or 14x14.tournaments is 11x11 or 14x14.

• Object of the game is to make a continuous chain Object of the game is to make a continuous chain of your colour to connect your sides of the board.of your colour to connect your sides of the board.

• Simple RulesSimple Rules– Play anywhere: Very wide game treePlay anywhere: Very wide game tree– Swap Rule: Helps balance the gameSwap Rule: Helps balance the game

• Early Game ProofsEarly Game Proofs– First Player WinFirst Player Win– No TiesNo Ties

The BoardThe Board

Virtual ConnectionsVirtual Connections

• What is a virtual connection?What is a virtual connection?– Subgame: goal is to connect two board Subgame: goal is to connect two board

positions, not necessarily the edges.positions, not necessarily the edges.– A guarantee that for a given subgame, A guarantee that for a given subgame,

even if the opponent plays first, you can even if the opponent plays first, you can still win the subgame.still win the subgame.

– An edge to edge virtual connection for a An edge to edge virtual connection for a player means they win!player means they win!

Basic Virtual ConnectionsBasic Virtual Connections

• Simplest Basic Virtual Simplest Basic Virtual Connection is the “two Connection is the “two bridge”bridge”– The two blue pieces here The two blue pieces here

form a two bridge, and form a two bridge, and the lower piece forms a the lower piece forms a two bridge with the edge.two bridge with the edge.

• In diagrams, we In diagrams, we represent virtual represent virtual connections by connections by colouring all the pieces colouring all the pieces required to maintain required to maintain the connection.the connection.

Edge Connection TemplatesEdge Connection Templates

• A good example of more A good example of more complex virtual connections complex virtual connections are edge templates.are edge templates.

• These templates are virtual These templates are virtual connections from the edge to a connections from the edge to a piece on the board.piece on the board.

• The farther out the piece, the The farther out the piece, the more pieces that are needed to more pieces that are needed to connect it to the edge.connect it to the edge.

• Very useful to know for Very useful to know for learning how to play Hex learning how to play Hex better!better!

4 out connections

3 out connections

2 out connection

Almost Virtual ConnectionsAlmost Virtual Connections

• A subgame in which if A subgame in which if we get one free move, we get one free move, we play one piece to we play one piece to create a new full create a new full connection.connection.

• The piece that creates The piece that creates the full connection is the full connection is called the key of the called the key of the almost connection.almost connection.

• In our diagrams, a In our diagrams, a blue key is coloured blue key is coloured cyan and a red key is cyan and a red key is coloured magenta.coloured magenta.

Complex Virtual Complex Virtual ConnectionsConnections• The advantage to The advantage to

virtual connections is virtual connections is the number of pieces the number of pieces required to win a game required to win a game on any board is much on any board is much smaller.smaller.

• Sometimes, you can Sometimes, you can win with only a handful win with only a handful of pieces on the board!of pieces on the board!

• Consider this board Consider this board position. Blue responds position. Blue responds to Red’s rather poor to Red’s rather poor follow-up move …follow-up move …

• And Blue wins, because he already has a full connection And Blue wins, because he already has a full connection from edge to edge!from edge to edge!

Discovering Virtual Discovering Virtual ConnectionsConnections

Recursive Virtual Recursive Virtual ConnectionsConnections• By applying three rules, we can find some By applying three rules, we can find some

virtual connectionsvirtual connections• The connections found are a subset of all The connections found are a subset of all

connections, but they are still very usefulconnections, but they are still very useful• These rules were formalized in two papers These rules were formalized in two papers

written by Vadim Anshelevichwritten by Vadim Anshelevich• As each connection is discovered, it is added As each connection is discovered, it is added

to a data structure for use by later rulesto a data structure for use by later rules• Every two adjacent positions have a trivial Every two adjacent positions have a trivial

connection joining themconnection joining them

The And RuleThe And Rule

• Assume we haveAssume we have– Connection from A-BConnection from A-B– Connection from B-CConnection from B-C– B is our colourB is our colour– A-B and B-C do not A-B and B-C do not

intersectintersect

• Then the union of A-Then the union of A-B and B-C is a B and B-C is a connection from A-Cconnection from A-C

The And Rule – Empty The And Rule – Empty IntersectionIntersection

• The two The two connections must connections must have an empty have an empty intersectionintersection

• If they do not, one If they do not, one opponent move opponent move can challenge both can challenge both componentscomponents

The Almost RuleThe Almost Rule

• Assume we haveAssume we have– Connection from A-BConnection from A-B– Connection from B-CConnection from B-C– B is emptyB is empty– A-B and B-C do not A-B and B-C do not

intersectintersect

• Then the union of A-Then the union of A-B, B-C, and B is an B, B-C, and B is an almost connection almost connection from A-Cfrom A-C

The Or RuleThe Or Rule

• Assume we haveAssume we have– At least two Almost At least two Almost

connections from A-Bconnections from A-B– A subset of these A subset of these

connections has an connections has an empty intersectionempty intersection

• Then, the union of Then, the union of this subset is a this subset is a connection from A-Bconnection from A-B

The Or Rule - continuedThe Or Rule - continued

Recursive Virtual Recursive Virtual ConnectionsConnections

ALMOST Connections

AND Connections

OR Connections

Trivial Connections

When no new connections are found, we are done.

Applications of Virtual Applications of Virtual Connection InformationConnection Information

• We know of three good uses for We know of three good uses for virtual connection informationvirtual connection information– Proving a win for a playerProving a win for a player– Evaluation FunctionEvaluation Function– Limiting the search treeLimiting the search tree

Proving a win for a playerProving a win for a player

• If a player If a player has an has an edge-to-edge-to-edge edge connection, connection, they have a they have a guaranteed guaranteed win.win.

Evaluation FunctionEvaluation Function

• In 1953, Claude Shannon and E.F. In 1953, Claude Shannon and E.F. Moore made a Hex-playing machine, Moore made a Hex-playing machine, based on electrical resistancesbased on electrical resistances

• Vadim Anshelevich describes a Vadim Anshelevich describes a method of using electrical method of using electrical resistances in his Hex papers.resistances in his Hex papers.

Evaluation FunctionEvaluation Function

• Each virtual connection is a wire Each virtual connection is a wire between two positions, with a resistance between two positions, with a resistance based on the size of the connection, and based on the size of the connection, and the state of the endpoints.the state of the endpoints.

• A voltage is applied to the edges. The A voltage is applied to the edges. The resulting current that passes through resulting current that passes through the system is the value of the the system is the value of the evaluation function.evaluation function.

Limiting the search treeLimiting the search tree

• On smaller boards (7x7 and less) one On smaller boards (7x7 and less) one or both players will often have almost or both players will often have almost connections joining edge to edge connections joining edge to edge within the first few moveswithin the first few moves

• If the opponent does not play within If the opponent does not play within this connection, then the player can this connection, then the player can play the ‘key’ of the almost play the ‘key’ of the almost connection, forming a full connection.connection, forming a full connection.

Limiting the search treeLimiting the search tree

Mustplay RegionsMustplay Regions

• If a player has multiple almost edge-If a player has multiple almost edge-edge connections, then their edge connections, then their opponent must play a move that opponent must play a move that disrupts all such connections.disrupts all such connections.

• The opponent must then play a move The opponent must then play a move in the intersection of all of the in the intersection of all of the player’s almost edge-edge player’s almost edge-edge connections.connections.

Mustplay Region for D5Mustplay Region for D5

Mustplay RegionsMustplay Regions

• Since a player is forced to play in Since a player is forced to play in their mustplay region, we can their mustplay region, we can eliminate parts of the search tree.eliminate parts of the search tree.

• On smaller boards (7x7 and lower) On smaller boards (7x7 and lower) most lines of play have mustplay most lines of play have mustplay regions within the first few movesregions within the first few moves

• On larger boards, mustplay regions On larger boards, mustplay regions will only develop in the midgame.will only develop in the midgame.