Wolfram Research

Function Repository Resource:

AggregationSystem

Source Notebook

Evolve a 2D array of cells by randomly adding new cells at positions with certain neighborhood configurations

Contributed by: Kabir Khanna and Jonathan Gorard

ResourceFunction["AggregationSystem"][rule,init,t]

generates a list representing the evolution of the aggregation system with the specified rule from initial condition init for t steps.

Details and Options

This uses the generalized aggregation model from A New Kind of Science Chapter 7.
Neighborhood configurations are as specified by an outer totalistic cellular automaton rule.
While entering the rule number, one must make sure that "Dimension" is set to 2.
Possible forms for rule are:
{n,{2,1},{1,1}} 9-neighbor totalistic rule
{n,{2,{{0,1,0},{1,1,1},{0,1,0}}},{1,1}} 5-neigbbor totalistic rule
{n,{2,{{0,2,0},{2,1,2},{0,2,0}}},{1,1}} 5-neighbor outer totalistic rule
The following keys can be used to specify a rule given as an association:
"TotalisticCode" n totalistic code
"OuterTotalisticCode" n outer totalistic code
"Dimension" d overall dimension (always 2)
"Neighborhood" type neigborhood
"Range" r range of rule
"Colors" k number of colors
"GrowthCases" { g 1 , g 2 , } make a cell 1 when gi of its neighbors are 1
"GrowthSurvivalCases" { { g 1 , } , { s 1 , } } 1 for gi neighbors; unchanged for si
"GrowthDecayCases" { { g 1 , } , { d 1 , } } 1 for gi neighbors; 0 for di
Possible settings for "Neighborhood" include:
5 or "VonNeumann"
9 or "Moore"
The number of possible aggregation system rules is as follows:
2D general rules 2512
2D 9-neighbor totalistic rules 210
2D 5-neighbor totalistic rules 26
2D 5-neighbor outer totalistic rules 210
2D outer totalistic rules 217+1
The initial condition specification should be of the form aspec, {aspec,bspec} or {{{aspec1,off1},{aspec2,off2},,{aspecn,offn}},bspec} (for n>0). Each aspec must be a non-empty array of rank 2 whose elements at level 2 are integers i in the range 0≤i≤"Colors"-1 ("Colors"=2 by default).
t should be a natural number. If t is specified as a list of a certain depth, then the first element of the flattened list will be taken as the input.

Examples

Basic Examples

Run outer totalistic code 4 for 4 steps :

In[1]:=
ResourceFunction[
 "AggregationSystem"][<|"OuterTotalisticCode" -> 4, "Dimension" -> 2|>,
  CenterArray[1, {1, 1}], 4]
Out[1]=

Run totalistic code 18 for 500 steps from a single 1 on a background of 0s:

In[2]:=
ArrayPlot@
 ResourceFunction[
  "AggregationSystem"][<|"TotalisticCode" -> 18, "Dimension" -> 2|> , CenterArray[1, {1, 1}], 500]
Out[2]=

Use RulePlot to visualize an outer totalistic rule specification:

In[3]:=
RulePlot[CellularAutomaton[<|"OuterTotalisticCode" -> 466, "Dimension" -> 2|>]]
Out[3]=

Scope

Run outer totalistic code 4 for 5000 steps using the default (Moore) neighborhood:

In[4]:=
ArrayPlot@
 ResourceFunction[
  "AggregationSystem"][<|"OuterTotalisticCode" -> 4, "Dimension" -> 2|> , CenterArray[1, {1, 1}], 5000]
Out[4]=

Run the same outer totalistic rule for 10000 steps using the von Neumann neighborhood:

In[5]:=
ArrayPlot@
 ResourceFunction[
  "AggregationSystem"][<|"OuterTotalisticCode" -> 4, "Dimension" -> 2, "Neighborhood" -> 5|> , CenterArray[1, {1, 1}], 10000]
Out[5]=

An evolution with three colors:

In[6]:=
ArrayPlot@
 ResourceFunction[
  "AggregationSystem"][<|"TotalisticCode" -> 258, "Dimension" -> 2, "Colors" -> 3|> , CenterArray[1, {1, 1}], 10000]
Out[6]=

A rule specified using growth cases:

In[7]:=
ArrayPlot[
 ResourceFunction[
  "AggregationSystem"][<|"Dimension" -> 2, "GrowthCases" -> {3, 6, 2}|>, {{1, 1, 1, 1, 1} {1, 0, 1, 1, 1}, {1,
     0, 0, 1, 1}}, 20000]]
Out[7]=

An evolution with a specified color function:

In[8]:=
ArrayPlot[
 ResourceFunction[
  "AggregationSystem"][<|"TotalisticCode" -> 344, "Dimension" -> 2, "Colors" -> 4|> , CenterArray[1, {1, 1}], 1000], ColorRules -> {1 -> Red, 2 -> Blue}]
Out[8]=

Resource History

Source Metadata