I gave this a go, but to make my head hurt less I reformulated to an equivalent definition: When the ant moves it faces forward and moves left if on cell of state 0, or right if on cell of state 1. I used a different state encoding to simsim314 which requires only one generation for each ant movement. Instead, the ant remembers the state of the cell it was on previously. Here is the ruletable:
Code: Select all
@RULE RhombicAnt
Rhombic's Ant moves on a grid of cells with value of either 0, or 1.
The ant moves either left or right depending on the state of cell it is on.
The ant remembers the state of the cell it moved from.
At each turn four cells swap state. These are either the four orthogonally
or diagonally adjacent cells, depending on the ant's own state.
Start with all cells off (0) and a single ant facing N.
Movement directions have been modified to remove the confusing direction
reversal in the original description.
1) Flip cell states:
a) if ant state is 0: swap state of four orthogonally adjacent cells
b) if ant state is 1: swap state of four diagonally adjacent cells
2) Ant movement:
a) if ant is in cell with state 0: ant state becomes 0 and move left
b) if ant is in cell with state 1: ant state becomes 1 and move right
Ant states format: 0b S A Dir
S: 1 bit indicating current cell state
A: 1 bit indicating ant's remembered state
Dir: Two bits indicating ant's current direction
N: 0b00, E: 0b01, S: 0b10, W: 0b11
States (Background states inserted before 16 ant states):
0 Background cell, state 0
1 Background cell, state 1
2, 3, 4, 5 Current cell state 0, ant state 0
6, 7, 8, 9 Current cell state 0, ant state 1
10,11,12,13 Current cell state 1, ant state 0
14,15,16,17 Current cell state 1, ant state 1
@TABLE
n_states:18
neighborhood:Moore
symmetries:none
var a={0,1}
var b={a}
var c={a}
var d={a}
var e={a}
var f={a}
var g={a}
var h={a}
var i={a}
var ant00 = { 2, 3, 4, 5}
var ant01 = { 6, 7, 8, 9}
var ant10 = {10,11,12,13}
var ant11 = {14,15,16,17}
var ant0X = { 2, 3, 4, 5, 6, 7, 8, 9} # Ant on state 0 cell
var ant1X = {10,11,12,13,14,15,16,17} # Ant on state 1 cell
var antX0 = { 2, 3, 4, 5,10,11,12,13} # Ant with state 0
var antX1 = { 6, 7, 8, 9,14,15,16,17} # Ant with state 1
# Compact version - doesn't work as expected in Golly 2.7 ?
# var ant0X = {ant00, ant01} # Ant on state 0 cell
# var ant1X = {ant10, ant11} # Ant on state 1 cell
# var antX0 = {ant00, ant10} # Ant with state 0
# var antX1 = {ant00, ant11} # Ant with state 1
# Ant movement
# Swap current state of cell ant moves to when ant state is 0
# Ant to the north
0,5,b,c,d,e,f,g,h,12
0,9,b,c,d,e,f,g,h,4
1,5,b,c,d,e,f,g,h,4
1,9,b,c,d,e,f,g,h,12
0,11,b,c,d,e,f,g,h,16
0,15,b,c,d,e,f,g,h,8
1,11,b,c,d,e,f,g,h,8
1,15,b,c,d,e,f,g,h,16
# Ant to the east
0,a,b,2,d,e,f,g,h,13
0,a,b,6,d,e,f,g,h,5
1,a,b,2,d,e,f,g,h,5
1,a,b,6,d,e,f,g,h,13
0,a,b,12,d,e,f,g,h,17
0,a,b,16,d,e,f,g,h,9
1,a,b,12,d,e,f,g,h,9
1,a,b,16,d,e,f,g,h,17
# Ant to the south
0,a,b,c,d,3,f,g,h,10
0,a,b,c,d,7,f,g,h,2
1,a,b,c,d,3,f,g,h,2
1,a,b,c,d,7,f,g,h,10
0,a,b,c,d,13,f,g,h,14
0,a,b,c,d,17,f,g,h,6
1,a,b,c,d,13,f,g,h,6
1,a,b,c,d,17,f,g,h,14
# Ant to the west
0,a,b,c,d,e,f,4,h,11
0,a,b,c,d,e,f,8,h,3
1,a,b,c,d,e,f,4,h,3
1,a,b,c,d,e,f,8,h,11
0,a,b,c,d,e,f,10,h,15
0,a,b,c,d,e,f,14,h,7
1,a,b,c,d,e,f,10,h,7
1,a,b,c,d,e,f,14,h,15
# Ant always moves
ant0X,a,b,c,d,e,f,g,h,0
ant1X,a,b,c,d,e,f,g,h,1
# Swap state of ant neighbours
# If the ant is moving to this cell, one of the previous rules will match instead
# Ant state is 0 - swap state of orthogonal neighbours
0,antX0,b,c,d,e,f,g,h,1
1,antX0,b,c,d,e,f,g,h,0
0,a,b,antX0,d,e,f,g,h,1
1,a,b,antX0,d,e,f,g,h,0
0,a,b,c,d,antX0,f,g,h,1
1,a,b,c,d,antX0,f,g,h,0
0,a,b,c,d,e,f,antX0,h,1
1,a,b,c,d,e,f,antX0,h,0
# Ant state is 1 - swap state of diagonal neighbours
0,a,antX1,c,d,e,f,g,h,1
1,a,antX1,c,d,e,f,g,h,0
0,a,b,c,antX1,e,f,g,h,1
1,a,b,c,antX1,e,f,g,h,0
0,a,b,c,d,e,antX1,g,h,1
1,a,b,c,d,e,antX1,g,h,0
0,a,b,c,d,e,f,g,antX1,1
1,a,b,c,d,e,f,g,antX1,0
@COLORS
0 0 0 0
1 0 127 0
2 127 0 0
3 127 0 0
4 127 0 0
5 127 0 0
6 127 0 127
7 127 0 127
8 127 0 127
9 127 0 127
10 127 127 0
11 127 127 0
12 127 127 0
13 127 127 0
14 127 127 127
15 127 127 127
16 127 127 127
17 127 127 127
I've added colours which indicated current cell state and ant state, but not the direction the ant is facing. You could add icons from Langton's Ant rule, but that's a bit tedious.
Because all transitions happen in a single generation, the first generation swaps the state of four cells - which isn't a part of your definition. The corresponding starting state for this rule has the four orthogonal neighbours with state 1. From there, the behaviour should be identical.
Unfortunately this settles in to a period 8 oscillator very quickly. I tried a range of different starting conditions and the behaviour is frequently similar. I'm not sure if I've made a mistake in writing the table, but I am fairly sure the behaviour should be equivalent.
An alternative to writing out the table like this - especially if you want to try out variations on the idea - is to adapt the scripts which come with Golly for making various Ant rules, e.g. Langtons-Ant-gen.py under Scripts/Python/Rule-Generators
I hope this at least helps by showing the method to translate a definition into a rule table.