Rule:Squaredance
@RULE Squaredance
@TABLE
n_states:9 neighborhood:Moore symmetries:rotate4
- Expanding and shrinking rectangular loops
- Dean Hickerson, 12/15-31/2010
- Start with a hollow rectangle of cells in states 1 and 2. Change
- one cell to state 3 and its clockwise neighbor to state 5 or 6.
- The two changed cells will move counterclockwise around the loop,
- causing it to grow or shrink whenever they reach a corner.
- States #############################
- b0 and b1 are bits 0 and 1 in rectangular loop.
- H is head of looper.
- H3 is used to detect a width 3 rectangle.
- Tail of looper is T0 or T1.
- Out and In shift edge.
var b0 = {1} # 0-bit in loop var b1 = {2} # 1-bit in loop var H = {3} # head var H3 = {4} # head detecting width 3 var T0 = {5} # tail with 0-bit var T1 = {6} # tail with 1-bit var Out = {7} # shift edge outward var In = {8] # shift edge inward
- Variables ###########################
var bit = {b0,b1} var bita = {bit} var bitb = {bit} var bitc = {bit} var bitd = {bit} var notbita = {0,H,H3,T0,T1,Out,In} var notbitb = notbita var notbitc = notbita var shift = {Out,In} var bitorshift = {bit,shift} var bitor0 = {bit,0} var head = {H, H3} var T = {T0,T1} var bitor0orT = {bitor0,T} var xa = {0,1,2,3,4,5,6,7,8} var xb = {xa} var xc = {xa} var xd = {xa} var xe = {xa} var xf = {xa} var xg = {xa} var xh = {xa}
- Rules ####################
- Bit touching exactly 2 others becomes their XOR
- straight
b0,b0,xa,notbita,xb,b0,xc,notbitb,xd,b0 b0,b0,xa,notbita,xb,b1,xc,notbitb,xd,b1 b0,b1,xa,notbita,xb,b0,xc,notbitb,xd,b1 b0,b1,xa,notbita,xb,b1,xc,notbitb,xd,b0 b1,b0,xa,notbita,xb,b0,xc,notbitb,xd,b0 b1,b0,xa,notbita,xb,b1,xc,notbitb,xd,b1 b1,b1,xa,notbita,xb,b0,xc,notbitb,xd,b1 b1,b1,xa,notbita,xb,b1,xc,notbitb,xd,b0
- bent
b0,b0,xa,b0,xb,notbita,xc,notbitb,xd,b0 b0,b0,xa,b1,xb,notbita,xc,notbitb,xd,b1 b0,b1,xa,b0,xb,notbita,xc,notbitb,xd,b1 b0,b1,xa,b1,xb,notbita,xc,notbitb,xd,b0 b1,b0,xa,b0,xb,notbita,xc,notbitb,xd,b0 b1,b0,xa,b1,xb,notbita,xc,notbitb,xd,b1 b1,b1,xa,b0,xb,notbita,xc,notbitb,xd,b1 b1,b1,xa,b1,xb,notbita,xc,notbitb,xd,b0
- bit touching 3 others becomes b0 (irrelevant bit)
bit,bita,xa,bitb,xb,bitc,xc,xd,xe,b0
- XOR rule also applies if one neighbor is a tail cell
bit,T0,xa,xb,xc,b0,xe,xf,xg,b0 bit,T0,xa,xb,xc,b1,xe,xf,xg,b1 bit,T0,xa,xb,xc,0,xe,xf,xg,b0 bit,T1,xa,xb,xc,b0,xe,xf,xg,b1 bit,T1,xa,xb,xc,b1,xe,xf,xg,b0 bit,T1,xa,xb,xc,0,xe,xf,xg,b1
- Head moves into loop cell
bit,H,T,0,bita,bitb,0,0,0,H3 # Detect width 3 bit,head,xa,xb,xc,xd,xe,xf,xg,H
- Head becomes tail ...
- on edge
H,0,0,T,0,0,0,b0,0,T0 H,0,0,T,0,0,0,b1,0,T1
- approaching corner
H,0,0,T,0,0,bit,b0,0,T0 H,0,0,T,0,0,bit,b1,0,T1
- at corner
H,0,0,T,0,b0,0,0,0,T0 H,0,0,T,0,b1,0,0,0,T1
- leaving corner
H,T,bit,0,0,b0,0,0,0,T0 H,T,bit,0,0,b1,0,0,0,T1
- leaving corner on length 3 edge
H3,T,bit,0,bita,b0,0,0,0,T0 H3,T,bit,0,bita,b1,0,0,0,T1
- Otherwise H3 dies.
- This allows H3's to be used as transient labels.
- H's can be used as permanent ones.
H3,xa,xb,xc,xd,xe,xf,xg,xh,0
- Tail becomes b0 (irrelevant bit) ...
- on edge
T0,0,0,bitorshift,0,0,0,H,0,b0 T1,0,0,bitorshift,0,0,0,H,0,b0
- before corner
T0,0,0,bit,0,0,bita,H,0,b0 T1,0,0,bit,0,0,bita,H,0,b0
- leaving corner
T0,bitorshift,bita,0,bitor0,H,0,0,0,b0 T1,bitorshift,bita,0,bitor0,H,0,0,0,b0
- Tail becomes shift at corner
T0,0,0,bit,0,H,0,0,0,In T1,0,0,bit,0,H,0,0,0,Out T,0,0,bit,0,H3,0,0,0,Out
- Shift travels along edge
bit,0,0,bita,bitor0,0,bitor0orT,shift,0,shift
- Out becomes bit or 0
Out,0,0,bit,0,T,0,0,0,bit # at start corner Out,0,0,bit,0,0,bita,bitb,bitc,0 # next to start corner Out,0,0,bit,0,0,0,0,bita,0 # on edge Out,0,0,bit,bita,0,0,0,bitb,0 # before end corner Out,0,0,bit,bita,0,bitb,bitc,bitd,0 # before end corner on length 3 edge
- Out moves edge outward (irrelevant bit)
0,0,0,0,bit,Out,0,0,0,b0 # at start corner 0,0,0,0,bit,Out,bita,bitb,0,b0 # next to start corner 0,0,0,0,bit,Out,0,bita,0,b0 # on edge
- Corner fills in at end of outward shift
0,0,0,0,0,bit,0,bita,0,b0 # (irrelevant bit)
- In becomes 0
In,0,0,bit,0,T,0,0,0,0 # at start corner In,0,0,bit,0,0,bita,0,0,0 # on edge In,0,0,bit,bita,0,bitb,0,0,0 # next to end corner
- In moves edge inward (irrelevant bit)
0,In,bit,0,0,0,T,bita,0,b0 # next to start corner 0,In,bit,0,0,0,0,bita,0,b0 # on edge 0,In,bit,bita,bitb,0,0,bitc,0,b0 # next to end corner 0,In,bit,bita,bitb,0,T,bitc,0,b0 # next to end corner on length 3 edge
- Corner dies at end of inward shift
bit,0,0,0,0,bita,bitb,0,0,0
- Bit touching exactly 1 other becomes it
bit,bita,xa,notbita,xb,notbitb,xc,notbitc,xd,bita