# Computing Reversible CA with CellularAutomaton

This computes and plots 127 steps of the evolution of 150R (the reversible version of rule 150).

ArrayPlot[
CellularAutomaton[{Mod[Total[Flatten[#]], 2] &, {}, {{-1,
0}, {0, -1}, {0, 0}, {0, 1}}, 2}, {{{1}, {1}}, 0}, 127]]


This example appears as part of the documentation of CellularAutomaton. How can I compute the evolution of other reversible rules, like 37R, 90R, etc.?

Edit: Below is an image showing the transition functions of both rule 150 and 150R.

rule 150 rule 150R Rule 150R does a XOR between the regular output of rule 150 for $t+1$ and the state of the cell at $t-1$. Other reversible CA have the same bit-flip behavior when $t-1$ is 1.

• What is the rule for said cellular automata? It is also not clear to me how it will help you if we implement cellular automata x, it won't be more instructive than the example you already have. – C. E. Jun 2 '15 at 5:15
• Oh, the question is how "150" was specified here. The rule is the same as ECA rule 150, flipping the value generated by 150 in t+1 if the cell was '1' in t-1. I'll include this in an image. – andandandand Jun 2 '15 at 13:56
• Another question then: why can't you solve it? You have an example of how to do what you want to do. What specifically is it that you are having trouble with? Are the rules for other cellular automata more complicated? – C. E. Jun 2 '15 at 18:08
• The question is how was the transition function for 150R specified here: "{Mod[Total[Flatten[#]], 2] &, {}, {{-1, 0}, {0, -1}, {0, 0}, {0, 1}}, 2}" Other reversible CA have the same bit-flip behavior when t-1 is 1. – andandandand Jun 3 '15 at 15:14

The higher order CellularAutomaton is not well documented. Anyway, this is my attempt to define 37R automaton. I am not completely sure if it works correctly, but for me, for a while, it works OK.

First I define the function that gives the new cell depending on two 3-cell neighborhoods. The 37R rule function is defined by

    d37 = IntegerDigits[37, 2, 8]
Clear[f]
f[1, 1, 1] = d37[];
f[1, 1, 0] = d37[];
f[1, 0, 1] = d37[];
f[1, 0, 0] = d37[];
f[0, 1, 1] = d37[];
f[0, 1, 0] = d37[];
f[0, 0, 1] = d37[];
f[0, 0, 0] = d37[];
g[x_] := Mod[f[x[][], x[][], x[][]] + x[][],2]


Here x is a list of the current and of the previous step 3-neighborhoods.Then I can plot the time evolution starting, for instance, from {{0,1,0},{0,1,0}} surrounded by zeros

    ArrayPlot[CellularAutomaton[{g[#] &, {}, 1, 2}, {{{1}, {1}}, 0}, 200]] Probably it can be simplified and adapted for other ECA. The rule 150 (with Total) from the documentation is not a good example for a general reversible automaton function.