Difference between revisions of "AND and OR rules"

From HexWiki
Jump to: navigation, search
 
m (minor grammar)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
AND and OR rules are ways to describe how well two distant groups are [[connection|connected]].
+
The '''AND and OR rules''' are deduction rules that can be used to build [[virtual connection|virtual connections]] and semi-connections. They often make it possible to compute whether two distant [[group]]s are [[connection|connected]]. These rules were published by [[Vadim Anshelevich]] in 2000 and 2002, see the references below. Anshelevich used these rules in his program [[Hexy]].
  
==AND==  
+
== Connections and semi-connections ==
  
The AND rule states that for a given player (say [[Red]]), two of their pieces can be connected if it is their turn. In the example below, if Red is to play then she can connect the two pieces. The pieces are said to be connected weakly.
+
The AND and OR rules are formulated from the viewpoint of one [[player]]. In this article, we take Red's point of view, although analogous rules can of course also be applied to Blue.
<hex> R3 C5 Vb2 Sc2 Vd2 </hex>
+
  
==OR==
+
Consider two cells ''x'' and ''y'' and a set ''E'' of cells containing neither ''x'' nor ''y''. Each of the cells ''x'' and ''y'' may either be empty or occupied by Red. We say that ''E'' is a '''virtual connection''' between ''x'' and ''y'' if Red has a second player strategy in the region ''E'' that results in ''x'' and ''y'' being connected. We say that ''E'' is a '''semi-connection''' if Red has a first-player strategy in ''E'' that results in ''x'' and ''y'' being connected. We say that ''x'' and ''y'' are the '''endpoints''' of the connection and ''E'' is its '''carrier'''.
  
The OR rule states that whoever turn it is, the pieces can be connected. Hence using the OR rule is a way to create [[virtual connection|virtual connections]]. The [[bridge]] is the most famous [[pattern]] involving the OR rule. In the example, even if it is [[Blue]]'s turn, Red can maintain the connection because Blue cannot occupy both starred cells in one move.
+
In other words, a virtual connection is a connection that Red can guarantee even if Blue goes first, whereas a semi-connection is a connection that Red can guarantee if Red goes first. Red can turn any semi-connection into a virtual connection by placing one more stone in it. Conversely, any move by Blue in a Red virtual connection results in at least a semi-connection.
  
<hex> R4 C4 Vb2 Sc2
+
Here are some examples of virtual connections between ''x'' and ''y'':
            Sb3 Vc3 </hex>
+
  
==Relations==
+
<hexboard size="2x2"
 +
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  contents="E x:a1 y:b2"
 +
/> <hexboard size="3x3"
 +
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  visible="-a1"
 +
  contents="R x:b1 a2 a3 y:c3"
 +
/> <hexboard size="6x6"
 +
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  visible="-area(a1,a4,c1)-area(f6,f4,e6)"
 +
  contents="E x:a5 R b6 d4 d6 e4 c2 e1 y:f2 B c4 d3 e3"
 +
/>
  
Two not intersecting AND-connections make one OR-connection like in the bridge above. This is due to th fact that the opponent cannot counter both connection.
+
And here are some examples of semi-connections:
  
Two consecutive OR-connections make one AND-connection. If Red plays the star hexa then she has connected strongly the two extreme hexas.
+
<hexboard size="1x3"
<hex> R5 C5 Vb2 Sc3 Vd4 </hex>
+
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  contents="E x:a1 y:c1"
 +
/> <hexboard size="3x3"
 +
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  visible="-a1"
 +
  contents="R x:b1 a2 a3 y:c3 B c1"
 +
/> <hexboard size="6x6"
 +
  edges="none"
 +
  coords="none"
 +
  float="inline"
 +
  visible="-area(a1,a4,c1)-area(f6,f4,e6)"
 +
  contents="E x:a5 R b6 d6 e4 c2 e1 y:f2 B c4 d3 e3"
 +
/>
  
==External link==
+
Schematically, we will represent a virtual connection by a red box, and a semi-connection by a white box, like this:
 +
[[Image: Connections.png|217px]]
  
Jack van Rijswijck.[http://home.fuse.net/swmeyers/y-hex.pdf Search and evaluation in Hex]. See paragraph 2.1.
+
== AND rule ==
 +
 
 +
The AND rule is concerned with what happens when a connection ''E''₁ from ''x'' to ''y'' and a connection ''E''₂ from ''y'' to ''z'' are joined together "in sequence". Here, we assume that the two connections have disjoint carriers, or more precisely, that they do not have any empty cells in common.
 +
 
 +
The AND rule states that the connection from ''x'' to ''z'' is:
 +
 
 +
* A virtual connection if ''E''₁ and ''E''₂ are virtual connections and ''y'' is occupied by Red.
 +
 
 +
* A semi-connection if ''E''₁ and ''E''₂ are virtual connections and ''y'' is empty.
 +
 
 +
* A semi-connection if one of ''E''₁ and ''E''₂ is a virtual connection, the other a semi-connection, and ''y'' is red.
 +
 
 +
In pictures:
 +
 
 +
[[Image: And-rule.png|669px]]
 +
 
 +
 
 +
== OR rule ==
 +
 
 +
The OR rule is concerned with what happens when two or more connections from ''x'' to ''y'' are joined together "in parallel". Here we do ''not'' assume that the carriers are pairwise disjoint, i.e., some of the carriers may overlap.
 +
 
 +
The OR rule states that if each of ''E''₁, ..., ''E''ₙ is a semi-connection from ''x'' to ''y'', and if there is no empty cell that is common to all of their carriers, then their union forms a virtual connection from ''x'' to ''y''.
 +
 
 +
In pictures:
 +
 
 +
[[Image: Or-rule.png|550px]]
 +
 
 +
== Application of the rules ==
 +
 
 +
The rules can be applied repeatedly. The simplest kind of virtual connection is when two cells are directly next to each other.
 +
<hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  visible="a3 a2"
 +
  contents="R x:a3 E y:a2"
 +
  />
 +
By the AND rule, we get a semi-connection from ''x'' to ''z'':
 +
<hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 a2"
 +
  contents="R x:a3 E y:a2"
 +
/> AND <hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a2 b1"
 +
  contents="E y:a2 R z:b1"
 +
/> = <hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 a2 b1"
 +
  contents="R x:a3 E y:a2 R z:b1"
 +
/>
 +
Combining this with another semi-connection, we get a virtual connection from ''x'' to ''z'' by the OR rule:
 +
<hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 a2 b1"
 +
  contents="R x:a3 R z:b1"
 +
/> OR <hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b2 b1"
 +
  contents="R x:a3 R z:b1"
 +
/> = <hexboard size="3x2"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 a2 b2 b1"
 +
  contents="R x:a3 R z:b1"
 +
/>
 +
By the AND rule, we get a semi-connection from ''a'' to ''z'':
 +
<hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b3 c3"
 +
  contents="R a:a3 R x:c3"
 +
/> AND <hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="c3 c2 d2 d1"
 +
  contents="R x:c3 R z:d1"
 +
/> = <hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b3 c3 c2 d2 d1"
 +
  contents="R a:a3 R x:c3 R z:d1"
 +
/>
 +
Combining this with another semi-connection by the OR rule, we get a virtual connection from ''a'' to ''z'':
 +
<hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b3 c3 c2 d2 d1"
 +
  contents="R a:a3 R c3 R z:d1"
 +
/> OR <hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b2 c1 d1"
 +
  contents="R a:a3 R c1 R z:d1"
 +
/> = <hexboard size="3x4"
 +
  coords="none"
 +
  edges="none"
 +
  float="inline"
 +
  visible="a3 b2 c1 b3 c3 c2 d2 d1"
 +
  contents="R a:a3 R c1 R c3 R z:d1"
 +
/>
 +
Continuing in this manner, very large virtual connections can be constructed.
 +
 
 +
== Incompleteness ==
 +
 
 +
The AND and OR rules are not complete. Specifically, there are some virtual (or semi-) connections that cannot be proven to be virtual (or semi-) connections by the AND and OR rules from smaller connections. Perhaps the simplest example is the following:
 +
<hexboard size="5x5"
 +
  coords="none"
 +
  edges="none"
 +
  visible="area(a3,a4,b5,c5,e3,e2,d1,c1)"
 +
  contents="R a4--a3--c1 e2--e3--c5 B b3 c2 c4 d3 R x:a3 y:e3 E a:b4 b:d2"
 +
/>
 +
It is a semi-connection (Red makes the connection by playing at ''a'' and ''b'', in either order). However, it cannot be proven to be a semi-connection by the AND and OR rules.
 +
 
 +
Anshelevich gave a generalization of the AND and OR rules that is complete. However, that generalization requires the computation of handicap sets (sets of cells) and is computationally harder.
 +
 
 +
== Use in computer Hex ==
 +
 
 +
The AND and OR rules have been used in some computer Hex programs to search for virtual connections. Notably, they were used in Anshelevich's [[Hexy]].
 +
 
 +
== References ==
 +
 
 +
* Anshelevich, Vadim V. [https://www.aaai.org/Papers/AAAI/2000/AAAI00-029.pdf The Game of Hex: An Automatic Theorem Proving Approach to Game Programming]. In Proceedings of the 17th National Conference on Artificial Intelligence, Austin Texas, 2000.
 +
* Anshelevich, Vadim V. [http://home.earthlink.net/~vanshel/VAnshelevich-ARTINT.pdf  A hierarichical approach to computer Hex]. See section 3.
 +
* [[Jack van Rijswijck]].[http://hex.kosmanor.com/theory/y-hex.pdf Search and evaluation in Hex]. See section 2.1.
 +
 
 +
== External links ==
 +
 
 +
* Vadim Anshelevich's [http://home.earthlink.net/~vanshel/Publications.html publications page]. Some publications dealing with virtual connections and the And and Or rules.
 +
 
 +
[[category:Computer Hex]]
 +
[[category:Theory]]

Latest revision as of 19:01, 7 October 2023

The AND and OR rules are deduction rules that can be used to build virtual connections and semi-connections. They often make it possible to compute whether two distant groups are connected. These rules were published by Vadim Anshelevich in 2000 and 2002, see the references below. Anshelevich used these rules in his program Hexy.

Connections and semi-connections

The AND and OR rules are formulated from the viewpoint of one player. In this article, we take Red's point of view, although analogous rules can of course also be applied to Blue.

Consider two cells x and y and a set E of cells containing neither x nor y. Each of the cells x and y may either be empty or occupied by Red. We say that E is a virtual connection between x and y if Red has a second player strategy in the region E that results in x and y being connected. We say that E is a semi-connection if Red has a first-player strategy in E that results in x and y being connected. We say that x and y are the endpoints of the connection and E is its carrier.

In other words, a virtual connection is a connection that Red can guarantee even if Blue goes first, whereas a semi-connection is a connection that Red can guarantee if Red goes first. Red can turn any semi-connection into a virtual connection by placing one more stone in it. Conversely, any move by Blue in a Red virtual connection results in at least a semi-connection.

Here are some examples of virtual connections between x and y:

xy
xy
yx

And here are some examples of semi-connections:

xy
xy
yx

Schematically, we will represent a virtual connection by a red box, and a semi-connection by a white box, like this: Connections.png

AND rule

The AND rule is concerned with what happens when a connection E₁ from x to y and a connection E₂ from y to z are joined together "in sequence". Here, we assume that the two connections have disjoint carriers, or more precisely, that they do not have any empty cells in common.

The AND rule states that the connection from x to z is:

  • A virtual connection if E₁ and E₂ are virtual connections and y is occupied by Red.
  • A semi-connection if E₁ and E₂ are virtual connections and y is empty.
  • A semi-connection if one of E₁ and E₂ is a virtual connection, the other a semi-connection, and y is red.

In pictures:

And-rule.png


OR rule

The OR rule is concerned with what happens when two or more connections from x to y are joined together "in parallel". Here we do not assume that the carriers are pairwise disjoint, i.e., some of the carriers may overlap.

The OR rule states that if each of E₁, ..., Eₙ is a semi-connection from x to y, and if there is no empty cell that is common to all of their carriers, then their union forms a virtual connection from x to y.

In pictures:

Or-rule.png

Application of the rules

The rules can be applied repeatedly. The simplest kind of virtual connection is when two cells are directly next to each other.

yx

By the AND rule, we get a semi-connection from x to z:

yx
AND
zy
=
zyx

Combining this with another semi-connection, we get a virtual connection from x to z by the OR rule:

zx
OR
zx
=
zx

By the AND rule, we get a semi-connection from a to z:

ax
AND
zx
=
zax

Combining this with another semi-connection by the OR rule, we get a virtual connection from a to z:

za
OR
za
=
za

Continuing in this manner, very large virtual connections can be constructed.

Incompleteness

The AND and OR rules are not complete. Specifically, there are some virtual (or semi-) connections that cannot be proven to be virtual (or semi-) connections by the AND and OR rules from smaller connections. Perhaps the simplest example is the following:

bxya

It is a semi-connection (Red makes the connection by playing at a and b, in either order). However, it cannot be proven to be a semi-connection by the AND and OR rules.

Anshelevich gave a generalization of the AND and OR rules that is complete. However, that generalization requires the computation of handicap sets (sets of cells) and is computationally harder.

Use in computer Hex

The AND and OR rules have been used in some computer Hex programs to search for virtual connections. Notably, they were used in Anshelevich's Hexy.

References

External links

  • Vadim Anshelevich's publications page. Some publications dealing with virtual connections and the And and Or rules.