# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Evolve a block cellular automaton

Contributed by:
Wolfram Research

ResourceFunction["BlockCellularAutomaton"][ generates a list of states and phases representing the evolution of the block cellular automaton with the specified | |

ResourceFunction["BlockCellularAutomaton"][ gives the result of evolving { | |

ResourceFunction["BlockCellularAutomaton"][ is an operator form of BlockCellularAutomaton that affects one step of evolution. | |

ResourceFunction["BlockCellularAutomaton"][ provides legacy support for previous input/output format, assuming | |

ResourceFunction["BlockCellularAutomaton"][ provides legacy support with an initial | |

ResourceFunction["BlockCellularAutomaton"][ provides legacy support for one step evolution assuming |

Possible forms for *rule* are:

{in_{1}→out_{1},in_{2}→out_{2},…} | A list of rules |

Dispatch[{in_{1}→out_{1},…}] | An optimized list of rules |

Association[in_{1}→out_{1},…] | A lookup dictionary |

{rule, dim} | with rule any of the above, and dim equals block length |

Specification by Association may lead to the fastest calculations, but it requires comprehensive list of inputs without any usage of pattern matching or RuleDelayed. Lists of rules may lead to slightly slower calculations, but are more flexible by allowing for pattern matching. The Dispatch usage should not be much slower than the Association usage.

ResourceFunction["BlockCellularAutomaton"] allows one extra rule specification {*rule*,{2,2}} for evolutions through two spatial dimensions, which alternate between *phase* values 0 and 1 with {2,2} block offset along the diagonal. This is sometimes referred to as the "Margolus neighborhood". More algorithm design regarding phases and offsets remains to be done to implement full dimensional generalization of ResourceFunction["BlockCellularAutomaton"].

Possible forms for time *t* are:

t | all steps 0 through t |

{t} | a list containing only step t |

{{t}} | step t alone |

{t_{1},t_{2}} | steps t_{1} through t_{2} |

{t_{1},t_{2},dt} | steps t_{1},t_{1}+dt, … |

List items in the output of ResourceFunction["BlockCellularAutomaton"] take the form {*state*_{i}, *phase*_{i}}, where *phase* goes from 0,1,…,*dim-1* and *dim* is the fixed block length. To obtain an ArrayPlot of a time evolution, simply discard *phase* information by combining Map and First, as in examples given below.

The length of *init* should be commensurate with the block size *dim*.

Previous versions of this code used a different phase convention, *phase* ∈{1,2,…, *dim*}. Backwards compatible usage expects a *phase* in the previous convention and automatically subtracts one to convert to the present convention.

Evolve a block cellular automaton for three steps:

In[1]:= |

Out[1]= |

Plot the same block cellular automaton evolving over 20 steps:

In[2]:= |

Out[2]= |

Evolve a block cellular automaton for one step:

In[3]:= |

Out[3]= |

Find the state of a block cellular automaton after 100 time steps:

In[4]:= |

Out[4]= |

Use the operator form to evolve a block cellular automaton by one step:

In[5]:= |

Out[5]= |

Apply the same operator to all possible length-6 inputs and produce a state transition Graph:

In[6]:= |

Out[6]= |

BlockCellularAutomaton allows block lengths greater than 2, and variable rules:

In[7]:= |

Out[7]= |

BlockCellularAutomaton has a special use case for rules on the Margolus neighborhood such as this "billiards" example:

In[8]:= |

Out[8]= |

BlockCellularAutomaton is backwards compatible with previous input/output forms:

In[10]:= |

Out[10]= |

Backwards compatibility also allows initializing with a phase:

In[11]:= |

Out[11]= |

Backwards compatibility also allows one-step evolution assuming initial *phase*=0:

In[12]:= |

Out[12]= |

Block size must divide the length of the initial condition:

In[13]:= |

Out[13]= |

Rules must have equal block size:

In[14]:= |

Out[14]= |

Find a periodic solution of the "billiards" block cellular automaton shown above and plot the cycle:

In[15]:= |

Out[15]= |

Plot a block cellular automaton that seems to do something prime-like along its right edge:

In[16]:= |

Out[16]= |

Plot first differences of the semi-hypotenuse lengths:

In[17]:= |

Out[17]= |

Compare continuation of the integer sequence (not in OEIS!) with the Primes (the icon contains a 2 minute data run computed using the code above):

In[18]:= |

Out[18]= |

- 2.0.0 – 07 November 2022
- 1.0.0 – 12 August 2020

This work is licensed under a Creative Commons Attribution 4.0 International License