Reversible Rule Generator

For scripts to aid with computation or simulation in cellular automata.
Post Reply
twinb7
Posts: 190
Joined: February 11th, 2014, 8:08 pm
Location: Ames, Iowa

Reversible Rule Generator

Post by twinb7 » November 27th, 2014, 1:52 pm

I want a code that translates any binary rule table into one using the second-order method. Essentially you calculate what the rule WOULD produce at a certain location, and xor it with the previous state of that cells. Of course Golly doesn't allow you to go two steps back in time, but we can store that information by creating two extra states. That way any binary rule (Just Friends, Life, Callahan's Hexagons) could be made reversible (though without the same behavior).

User avatar
codeholic
Moderator
Posts: 1147
Joined: September 13th, 2011, 8:23 am
Location: Hamburg, Germany

Re: Reversible Rule Generator

Post by codeholic » November 27th, 2014, 2:12 pm

twinb7 wrote:Essentially you calculate what the rule WOULD produce at a certain location, and xor it with the previous state of that cells.
Could you give an example?
Ivan Fomichev

EricG
Posts: 199
Joined: August 19th, 2011, 5:41 pm
Location: Chicago-area, USA

Re: Reversible Rule Generator

Post by EricG » November 27th, 2014, 2:16 pm

Awhile back, I posted a script that converts the three examples you gave (Life, Just Friends, and Callahan's non-totalistic hex rule), but it doesn't convert any arbitrary rule table. It only converts rules that can be expressed in totalistic B/S notation or Hensel's non-totalistic notation. See viewtopic.php?f=11&t=1293&hilit=reversi ... =75#p11153

twinb7
Posts: 190
Joined: February 11th, 2014, 8:08 pm
Location: Ames, Iowa

Re: Reversible Rule Generator

Post by twinb7 » November 30th, 2014, 1:06 pm

codeholic wrote:
twinb7 wrote:Essentially you calculate what the rule WOULD produce at a certain location, and xor it with the previous state of that cells.
Could you give an example?
With the second-order method we use the following state numbering to denote the current and previous state of the cell. To clarify, 'Golly State' will be the state golly uses, while 'state' will refer to the true state of the cell.

Code: Select all

Golly State | Previous State | Current State
0                  0                       0
1                  0                       1
2                  1                       0
3                  1                       1
Under the second-order rule, we calculate how the rule would update treating the cells as their current state (Treat zeroes and twos as off and treat ones and threes as on). XOR this with the previous state.


To put it simply and ignore the actual theory behind it:

Given a binary rule table, do the following.
1. Treat cells 0 and 2 as off and 1 and 3 as on.
2. Under survival conditions of the original table, 1 -> 3 and 3 -> 2.
3. Under birth conditions of the original table, 0 -> 1 and 2 ->0.
4. Under death conditions of the original table, 1->2, 3->3.
5. Under 'no birth' conditions of the original table, 0->0 and 2->1.

I'll post an example rule table.

twinb7
Posts: 190
Joined: February 11th, 2014, 8:08 pm
Location: Ames, Iowa

Re: Reversible Rule Generator

Post by twinb7 » November 30th, 2014, 1:13 pm

Code: Select all

@RULE ReversibleLife
@TABLE
n_states:4
neighborhood:Moore
symmetries:permute

#These states are treated as ‘on’.
var on_a = {1,3}
var on_b = {1,3}
var on_c = {1,3}
var on_d = {1,3}

#These states are treated as ‘off’.
var of_a = {0,2}
var of_b = {0,2}
var of_c = {0,2}
var of_d = {0,2}
var of_e = {0,2}

#These states indicate ‘any’.
var an_a = {0,1,2,3}
var an_b = {0,1,2,3}
var an_c = {0,1,2,3}
var an_d = {0,1,2,3}
var an_e = {0,1,2,3}
var an_f = {0,1,2,3}
var an_g = {0,1,2,3}
var an_h = {0,1,2,3}


#The birth rule: B3. Note that two states are considered as off: 0 and 2.
0,on_a,on_b,on_c,of_a,of_b,of_c,of_d,of_e,1
2,on_a,on_b,on_c,of_a,of_b,of_c,of_d,of_e,0

#The survival rule: S23. Note that two states are considered as on: 1 and 3.
1,on_a,on_b,an_a,of_a,of_b,of_c,of_d,of_e,3
3,on_a,on_b,an_a,of_a,of_b,of_c,of_d,of_e,2

#The scenario in which a cell dies, or a dead cell continues to be dead.

1,an_a,an_b,an_c,an_d,an_e,an_f,an_g,an_h,2
2,an_a,an_b,an_c,an_d,an_e,an_f,an_g,an_h,1
3,an_a,an_b,an_c,an_d,an_e,an_f,an_g,an_h,3 
#The final line can be omitted as, in unspecified situations, Golly retains cell state.



Post Reply