"Rhombic's Ant"

For discussion of other cellular automata.
Post Reply
User avatar
Rhombic
Posts: 1100
Joined: June 1st, 2013, 5:41 pm

"Rhombic's Ant"

Post by Rhombic »

Definitions:
Switching a state is basically turning the 0 into a 1 or the 1 into a 0.
Positions are defined like this, from the perspective of X:
701
6X2
543

Rules:
1) You start pointing upwards and everything is state 0. Each generation, you point towards your last movement's direction (ex. if you turn right, you are now facing towards that direction for the next turn).
2) If you are in a cell with state 0, move to your right. From this new position, switch the cells in 0,2,4,6 position.
3) If you are in a cell with state 1, move to your left. From this new position, switch the cells in 1,3,5,7 position.

I tried this with a paper and a pencil and it was quite interesting. I do not have the skills to code it so I would appreciate any attempt to do so.
SoL : FreeElectronics : DeadlyEnemies : 6a-ite : Rule X3VI
what is “sesame oil”?
User avatar
simsim314
Posts: 1828
Joined: February 10th, 2014, 1:27 pm

Re: "Rhombic's Ant"

Post by simsim314 »

Hey Rhombic's Ant it's not so hard to formulate rules in Golly.

I don't have time currently to formulate all the details but the rule generation is very simple:

1. You need to calculate number of states. For example your rule has 2 (for 0 -1 states in universe) + 2 (newly arrived ant, and old ant) * 4 (four directions) * 2 (was it 0 or 1 before the ant arrived on the cell). So in total you have 18 states.

2. Now you need to decide what state correspond to what:

0, 1 - state in universe
2, 3, 4, 5 - for four directions and newly arrived cell that was 0 before hand
6, 7, 8, 9 - for four directions and newly arrived cell that was 1 before hand

10, 11, 12, 13 - for four directions and old cell that was 0 before hand
14, 15, 16, 17 - for four directions and old cell that was 1 before hand


3. now you write the rules:

The rules in golly table rule is very simple:

It's ten numbers: x, 0, 1, 2, 3, 4, 5, 6, 7, y

where

X - is state of a cell
0-7 is the state of neighbors states
Y - is the new state

4. Notice you can also define variables like

var a = {0, 1} that means the rule works when it's 0 and 1.

so moving to the right will be formulated as two rules:

1. return the state of "old ant" to it's original:

var old0 = {10, 11, 12, 13}
var old1 = {14, 15, 16, 17}
var a, b, c, d, e, f, g, h = {0, 1} - see the correct syntax in some existing rule.

And now you write:

old0, a, b, c, d, e, f, g, h, 0
old1, a, b, c, d, e, f, g, h, 1

This will turn back the old ant into the original state.

Now the old ant will also move (that means someone that has a 10 ant to the left will be born as 2 or 6 - new ant to right)

0, a, b, c, d, e, f, 10, g, 2
1, a, b, c, d, e, f, 10, g, 6

etc.

Hope it was helpful, if not I'll try to make the full rule later.
User avatar
Rhombic
Posts: 1100
Joined: June 1st, 2013, 5:41 pm

Re: "Rhombic's Ant"

Post by Rhombic »

I'm afraid I'm not too experienced with RuleTables and such. I've only generated some and I do not feel exceedingly confident in creating them. I made an attempt and it clearly did not work since the cells did not change state.
SoL : FreeElectronics : DeadlyEnemies : 6a-ite : Rule X3VI
what is “sesame oil”?
wildmyron
Posts: 1572
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: "Rhombic's Ant"

Post by wildmyron »

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.

Code: Select all

x = 3, y = 3, rule = RhombicAnt
.A$ABA$.A!
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.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by speedydelete.

Semi-active here - recovering from a severe case of LWTDS.
User avatar
simsim314
Posts: 1828
Joined: February 10th, 2014, 1:27 pm

Re: "Rhombic's Ant"

Post by simsim314 »

wildmyron wrote: I used a different state encoding to simsim314 which requires only one generation for each ant movement.
Hey nice try. Just notice your ant flips and moves at the same time. Rhombic's Ant flips from the arrived location. This is not the same.
wildmyron
Posts: 1572
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: "Rhombic's Ant"

Post by wildmyron »

simsim314 wrote:
wildmyron wrote: I used a different state encoding to simsim314 which requires only one generation for each ant movement.
Hey nice try. Just notice your ant flips and moves at the same time. Rhombic's Ant flips from the arrived location. This is not the same.
This is why the ant has its own state which records the state of the cell it left. Which cells to flip is then decided by the ant's state, which corresponds to the state of the cell it came from. I'm sure this does correspond to the original description, except for the very first generation, which is why I proposed a starting state with the neighbours flipped.

In any case, starting state doesn't seem to have much impact on the final behaviour - the p8 oscillator is the only outcome I've discovered for a wide range of starting states. I'm curious if this corresponds to Rhombic's experience with pen and paper (which I suspect it doesn't - please elaborate on the discrepencies). I double checked the behaviour and it seems to be correct, but I haven't manually verified the evolution from gen 0 to p8 oscillator.
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by speedydelete.

Semi-active here - recovering from a severe case of LWTDS.
User avatar
Rhombic
Posts: 1100
Joined: June 1st, 2013, 5:41 pm

Re: "Rhombic's Ant"

Post by Rhombic »

That is funny... I did not get the oscillator with pen and paper, though I only did about 20 generations or so. It seems that I made a mistake or two while checking it. Unfortunately, I thought that it would be more interesting. I'll still check it anything useful or surprising can be developed by using this rule or similar ones.
Thank you, simsim314 and wildmyron, for helping me with understanding the nature of this rule and for writing the code for it.
SoL : FreeElectronics : DeadlyEnemies : 6a-ite : Rule X3VI
what is “sesame oil”?
wildmyron
Posts: 1572
Joined: August 9th, 2013, 12:45 am
Location: Western Australia

Re: "Rhombic's Ant"

Post by wildmyron »

Rhombic wrote:That is funny... I did not get the oscillator with pen and paper, though I only did about 20 generations or so. It seems that I made a mistake or two while checking it. Unfortunately, I thought that it would be more interesting. I'll still check it anything useful or surprising can be developed by using this rule or similar ones.
Thank you, simsim314 and wildmyron, for helping me with understanding the nature of this rule and for writing the code for it.
You're welcome. I can see a range of variations on this theme but I don't think you'd want to be manually writing rule tables for too many of them. Adapting the existing ant scripts is probably the way to go there.

When you say you made a mistake, have you confirmed that is the case, or are you assuming the long term behaviour of the rule I posted is correct?
The 5S project (Smallest Spaceships Supporting Specific Speeds) is now maintained by speedydelete.

Semi-active here - recovering from a severe case of LWTDS.
User avatar
Rhombic
Posts: 1100
Joined: June 1st, 2013, 5:41 pm

Re: "Rhombic's Ant"

Post by Rhombic »

wildmyron wrote:
Rhombic wrote:That is funny... I did not get the oscillator with pen and paper, though I only did about 20 generations or so. It seems that I made a mistake or two while checking it. Unfortunately, I thought that it would be more interesting. I'll still check it anything useful or surprising can be developed by using this rule or similar ones.
Thank you, simsim314 and wildmyron, for helping me with understanding the nature of this rule and for writing the code for it.
You're welcome. I can see a range of variations on this theme but I don't think you'd want to be manually writing rule tables for too many of them. Adapting the existing ant scripts is probably the way to go there.

When you say you made a mistake, have you confirmed that is the case, or are you assuming the long term behaviour of the rule I posted is correct?
I am assuming that yours works correctly, and since I did not see that long-term behaviour developing, I thought that I must have had some mistakes here and there.
SoL : FreeElectronics : DeadlyEnemies : 6a-ite : Rule X3VI
what is “sesame oil”?
Post Reply