Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Evolve a cellular automaton with changes to certain cells
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec] finds one random location within the body of the automaton and flips the color randomly. | |
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec,n] finds n random locations within the body of the automaton and flips the color randomly. | |
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec,{tpert,xpert}] flips the cell specified by {tpert, xpert} to a random bit within the number of colors. | |
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec,{{tpert1,xpert1}...}] flips all cells in the list of perturbations specifications to a random bit within the number of colors. | |
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec,{tpert,xpert}→newbit] flips the cell at indexes specified by {tpert, xpert} to the bit specified by newbit. | |
ResourceFunction["PerturbedCellularAutomaton"][rule,init,txspec,{{tpert1,xpert1}→newbit1...}] flips the cell at indexes {{tpertn, xpertn}...} to bit specified by newbitn. |
t | perturbs at position t |
{t1…} | perturbs at position tn in sorted order |
ts;;te | perturbs at position specified by span in sorted order |
f | perturbs at indices given by the result running f on the list of possible indices |
b | sets value of cell to integer b |
{"AddValue", b} | adds previous value of cell with integer b, modulo the number of colors |
f | sets value of cell to the result of running f[prev, k] for k colors |
"Body" | False | whether the indexes given refer to indexes within the body, the body is defined by |
"ReturnPerturbations" | True | whether to return the performed perturbations, if False, just a list of lists will be returned |
Run a cellular automaton with a random perturbation for 2 steps, here the first cell of the second row is flipped to 0:
In[1]:= | ![]() |
Out[1]= | ![]() |
Specify that same perturbation:
In[2]:= | ![]() |
Out[2]= | ![]() |
See the differences based on the perturbation above:
In[3]:= | ![]() |
Out[3]= | ![]() |
Draw an arrow to the perturbed cell:
In[4]:= | ![]() |
Out[4]= | ![]() |
Do two random perturbations:
In[5]:= | ![]() |
Out[5]= | ![]() |
Visualize it:
In[6]:= | ![]() |
Out[6]= | ![]() |
Use those same perturbation locations but set them both to white:
In[7]:= | ![]() |
Out[7]= | ![]() |
Do a range of three perturbations at timestep two:
In[8]:= | ![]() |
Out[8]= | ![]() |
Visualize it:
In[9]:= | ![]() |
Out[9]= | ![]() |
Perturb the third cell at timestep one and two:
In[10]:= | ![]() |
Out[10]= | ![]() |
Visualize it:
In[11]:= | ![]() |
Out[11]= | ![]() |
Perturb a random sample of three at the second timestep:
In[12]:= | ![]() |
Out[12]= | ![]() |
Visualize it:
In[13]:= | ![]() |
Out[13]= | ![]() |
Perturb the last cell at every timestep:
In[14]:= | ![]() |
Out[14]= | ![]() |
With larger k-values, you can use "AddValue" for the bit specification to make a deterministic change. Here yellow always gets flipped to white:
In[15]:= | ![]() |
Out[15]= | ![]() |
Setting "ReturnPerturbations" to False makes it so that only evolution of the automata is returned:
In[16]:= | ![]() |
Out[16]= | ![]() |
Setting "Body" to true makes it so that the specified index is interpreted as the index within the non-zero range of the automata:
In[17]:= | ![]() |
Out[17]= | ![]() |
Evolve a rule with perturbations:
In[18]:= | ![]() |
Plotting our robust automaton:
In[19]:= | ![]() |
Out[19]= | ![]() |
Ten sample perturbations:
In[20]:= | ![]() |
Out[20]= | ![]() |
Plot the lifetime distribution of one thousand different random single perturbations:
In[21]:= | ![]() |
Out[22]= | ![]() |
Obtain the mortality curve:
In[23]:= | ![]() |
Out[23]= | ![]() |
When you specify an index outside the range of the body, an empty perturbation is returned:
In[24]:= | ![]() |
Out[24]= | ![]() |
The tspec uses the same indexing as in CellularAutomaton, so the initial row is perturbed using zero:
In[25]:= | ![]() |
Out[25]= | ![]() |
Because the automata are stitched together, using All or Automatic as an xspec is not allowed. If no xspec is given, or All or Automatic are given, xspec defaults to {-25,25}:
In[26]:= | ![]() |
Out[26]= | ![]() |
Doing many perturbations sometimes results in the body dying out, with no perturbations left to perform:
In[27]:= | ![]() |
Out[27]= | ![]() |
Running the function on an empty list or association returns the unperturbed cellular automaton:
In[28]:= | ![]() |
Out[28]= | ![]() |
Rules that "age" are particularly robust to perturbations:
In[29]:= | ![]() |
Out[29]= | ![]() |
They can also be healed easily. Here we apply a therapeutic perturbation:
In[30]:= | ![]() |
Out[30]= | ![]() |
With random perturbations you can see the beginning of self-reproduction in very simple rules:
In[31]:= | ![]() |
Out[32]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License