Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Run an adaptive search for cellular automata
ResourceFunction["AdaptiveCellularAutomaton"][<|"AdaptiveIterations"→n|>] returns n steps in an adaptive search, starting from the 3-color null rule and searching for rules that give longer finite length patterns. | |
ResourceFunction["AdaptiveCellularAutomaton"][<|"AdaptiveIterations"→n, "InitialRule"→{0,k,r}|>] returns n steps in an adaptive evolution, starting from the k-color null rule and searching for rules that give longer finite length patterns. | |
ResourceFunction["AdaptiveCellularAutomaton"][evospec,"FinalState"] returns only the final iteration in the adaptive evolution. | |
ResourceFunction["AdaptiveCellularAutomaton"][evospec,"BreakthroughStates"] returns only the breakthrough iterations in the adaptive evolution. | |
ResourceFunction["AdaptiveCellularAutomaton"][evospec,sequencespec,"Plot"] returns the plotted cellular automata for each step specified by the sequence specification. | |
ResourceFunction["AdaptiveCellularAutomaton"][evospec,sequencespec,"Fitness"] returns only the fitness values. | |
ResourceFunction["AdaptiveCellularAutomaton"][evospec,sequencespec,propertyspec] returns all the information specified by the property specification. |
| All | (default) returns all the iterations in the evolution |
| "FinalState" | returns the final iteration in the evolution |
| "BreakthroughStates" | returns the breakthrough iterations in the evolution |
| "RuleChanges" | returns the iterations where the rule was changed in the evolution |
| t | returns iteration t in the evolution |
| {t1…} | returns the iterations specified in the list |
| t1;;t2;;td | returns the iterations t1 through t2 with step size d |
| All | Association with all the properties listed below |
| "BestRule" | most fit rule found so far |
| "BestInitialCondition" | most fit initial condition found so far |
| "BestFitness" | highest fitness value found so far |
| "Rule" | rule that was tried at each step |
| "InitialCondition" | initial condition that was tried at each step |
| "Fitness" | fitness at each step |
| "Lifetime" | number of steps before the automaton reaches the all-white state |
| "Width" | maximum length non-zero range in the pattern |
| "AspectRatio" | "Width" metric divided by the "Lifetime" |
| "Index" | iteration index |
| "MutationDistance" | the edit distance from the initial rule to the current best rule |
| {"BestRule", "BestFitness"} | (default) returns an Association with best rule and fitness found so far |
| {propertyspec1, propertyspec2 , propertyspecn } | Association with the specified properties |
| "InitialRule" | {0, 3, 1} | the initial rule, and the color-space and radius to use |
| "InitialCondition" | {{1}, 0} | the initial condition |
| "MaxSteps" | 100 | the number of steps to search to determine if the rule halts |
| "AdaptiveIterations" | 1000 | the number of iterations to do in the search |
| "MutationFunction" | 1 | the type and number of mutations to do |
| "FitnessFunction" | "Lifetime" | the fitness function to use |
| "SelectionFunction" | #1>=#2& | the selection function to use |
| "Lifetime" | evolve to a longer finite lifetime |
| "Width" | evolve to a wider pattern that still halts |
| "AspectRatio" | evolve to a larger aspect ratio defined as the width over the lifetime |
| type→target | evolve to a target value for the given fitness type |
| fun | function taking the rule and initial condition and returning the fitness to assign |
| n | randomly mutate n cases in the rule |
| {n, "Symmetric"-> True} | only allow rule mutations that maintain symmetry |
| "Rule" -> n | randomly mutate n cases in the rule |
| "InitialCondition" -> n | randomly mutate a single bit in the initial condition |
| fun | a function taking the rule and returning the mutated version |
| <|"Rule"→funrule, "InitialCondition"→funic|> | mutates the rule and initial condition using the specified functions |
| "InitialRule" | {0, 3, 1} | the initial rule, and the color-space and radius to use |
| "InitialCondition" | {{1}, 0} | the initial condition |
| "MaxSteps" | 100 | the number of steps to search to determine if the rule halts |
| "AdaptiveIterations" | 1000 | the number of iterations to do in the search |
| "MutationFunction" | 1 | the type and number of mutations to do |
| "FitnessFunction" | "Lifetime" | the fitness function to use |
| "SelectionFunction" | #1>=#2& | the selection function to use |
| "PlottingRegion" | "Lifetime" | accepts any time and offset specification for the CellularAutomaton function |
| "PlotSizingFunction" | ({Automatic,30Sqrt[#Height]}&) | takes arguments "Height" and "Width" and returns an ImageSize specification |
| "PlottingFunction" | Automatic | takes arguments from the state and returns a plot |
| "HorizontalPadding" | 1 | the number of white cells to add on either side of the pattern |
| "PlotLabels" | None | takes "Lifetime", "Width", "AspectRatio" or a function that is applied to the state |
| "VerticalPadding" | 1 | the number of blank rows to add to the bottom of the pattern |
| "LabelSize" | 11 | size of the labels given to the Style function |
| "WhileCondition" | None | condition to continue the search |
Run an evolution for 3 steps starting from the null k=3, r=1 rule and return every step in the search:
| In[1]:= |
| Out[1]= |
Return only the final state of the evolution:
| In[2]:= |
| Out[2]= |
Return the final best rule of the evolution:
| In[3]:= |
| Out[3]= |
Evolve for 500 steps and plot the breakthrough mutation steps:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
Plot the progressive fitness values showing the mutations that weren't selected:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Plot the progressive fitness values for 10 evolutions:
| In[6]:= | ![]() |
| Out[6]= | ![]() |
Plot the final states of 10 different evolutions:
| In[7]:= | ![]() |
| Out[7]= | ![]() |
Evolve a k = 4 cellular automata:
| In[8]:= | ![]() |
| Out[8]= | ![]() |
Evolve for longer automata using "MaxSteps":
| In[9]:= | ![]() |
| Out[9]= | ![]() |
Evolve to a specific target lifetime:
| In[10]:= | ![]() |
| Out[10]= | ![]() |
10 separate evolutions to a target lifetime of 50:
| In[11]:= | ![]() |
| Out[11]= | ![]() |
See the fitness progressions:
| In[12]:= | ![]() |
| Out[12]= | ![]() |
Evolve the initial conditions of a cellular automata:
| In[13]:= | ![]() |
| Out[13]= | ![]() |
The default selection function accepts neutral mutations by default, make it so that it accepts mutations that decrease fitness by 1:
| In[14]:= | ![]() |
| Out[14]= | ![]() |
Use a fitness function that looks for repeating automata rather than terminating ones:
| In[15]:= | ![]() |
| Out[15]= | ![]() |
Use a fitness function that selects automata with more and more colored cells:
| In[16]:= | ![]() |
| Out[16]= | ![]() |
Write a mutation function that has a higher probability flipping a rule to white or blue:
| In[17]:= | ![]() |
| Out[17]= | ![]() |
You can also use index values for the sequence specification:
| In[18]:= | ![]() |
| Out[18]= | ![]() |
A list of indices will return a list with the result at each respective state:
| In[19]:= | ![]() |
| Out[19]= | ![]() |
You can also use a span specification, here is the result every 100 steps:
| In[20]:= | ![]() |
| Out[20]= | ![]() |
Combining this with a list of property specifications will return a list of associations with keys and values for the given specifications:
| In[21]:= | ![]() |
| Out[21]= | ![]() |
You can generate fitness progressions in a memory-efficient way using "Index":
| In[22]:= | ![]() |
| Out[22]= | ![]() |
You can also track the mutation distance of the current rule from the initial rule over time:
| In[23]:= | ![]() |
| Out[23]= | ![]() |
The evolution specification "RuleChanges" will return only the iterations in the evolution where the rule changed:
| In[24]:= | ![]() |
| Out[24]= | ![]() |
Use a custom plot sizing function:
| In[25]:= | ![]() |
| Out[25]= | ![]() |
When "Plot" is specified AdaptiveCellularAutomaton will use any ArrayPlot options given:
| In[26]:= | ![]() |
| Out[26]= | ![]() |
Plot with a specified region:
| In[27]:= | ![]() |
| Out[27]= | ![]() |
Specify the width and height of the region:
| In[28]:= | ![]() |
| Out[28]= | ![]() |
The adaptive search will terminate when the criterion for "WhileCondition" is no longer true:
| In[29]:= | ![]() |
| Out[29]= | ![]() |
This enables more efficient parallel searches:
| In[30]:= | ![]() |
| Out[30]= | ![]() |
Argument specifications for evolving 2D totalistic cellular automata:
| In[31]:= | ![]() |
| Out[31]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License