Function Repository Resource:

 AutomataNetworkRun

Source Notebook

Evolve an automata network in which each automaton updates its state from the states of other automata

Contributed by: Eric James Parfitt

ResourceFunction["AutomataNetworkRun"][{{rules1,inputs1,label1},{rules2,inputs2,label2},…},init,t]

gives the states at each of t steps of the automata network in which each automaton labeli updates its state by applying the rules rulesi to the states of the automata inputsi, starting from the states init.

ResourceFunction["AutomataNetworkRun"][{{{rules1,s1},inputs1,label1},{{rules2,s2},inputs2,label2},…},t]

gives the complete network at each of t steps, where si is the current state of the automaton labeli.

Details

An automata network is a set of automata, each of which has a state. At each step, each automaton computes its new state from the current states of certain automata in the network, called its inputs.
rulesi is a list of rules of the form {x1,x2,…}→y. At each step, the first rule whose left-hand side matches the list of the current states of the automata inputsi gives the new state y.
inputsi is a list of labels of automata. It can include labeli itself, and it can contain the same label more than once.
Labels can be any expressions, such as integers or strings. They are used only to refer to automata in inputsi, and do not have to match the positions of the automata in the list.
All automata are updated at the same time, using the states from the previous step. This is known as parallel or synchronous updating.
States can be any expressions. rulesi can use patterns, conditions and RuleDelayed.
init is a list of initial states, in the same order as the automata. Each element of the result gives the states in that order.
In ResourceFunction["AutomataNetworkRun"][network,t], each automaton has the form {{rulesi,si},inputsi,labeli}. The result is a list of t+1 networks of the same form, in which only the states si change.

Examples

Basic Examples (2) 

Get the complete network at each step for an automaton that gives the NOT of its own state:

In[1]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{{0} -> 1, {1} -> 0}, 0}, {1}, 1}}, 3]
Out[1]=

Define a Boolean network of three automata where automaton 1 gives the NOT of automaton 3, automaton 2 gives the AND of automata 1 and 3, and automaton 3 gives the XOR of automata 1 and 2:

Evolve the network for 8 steps, starting with every automaton in state 0:

In[2]:=
ResourceFunction["AutomataNetworkRun"][network, {0, 0, 0}, 8]
Out[2]=

Scope (6) 

Three automata with states 0, 1 and 2 are given by tables of rules:

Automaton 1 uses the state of automaton 2 twice:

In[3]:=
ResourceFunction[
 "AutomataNetworkRun"][{{rules1, {2, 2, 3}, 1}, {rules2, {1, 3}, 2}, {rules3, {2}, 3}}, {1, 2, 0}, 3]
Out[3]=

Labels can be strings:

In[4]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{0} -> 1, {1} -> 0}, {"b"}, "a"}, {{{x_, y_} :> Max[x, y]}, {"a", "b"}, "b"}}, {0, 0}, 4]
Out[4]=

Labels do not have to match positions, so the states in the result are in the order of the automata in the list:

In[5]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{x_} :> x}, {1}, 2}, {{{0} -> 1, {1} -> 0}, {1}, 1}}, {0, 0}, 4]
Out[5]=

This automaton counts modulo 4 using its own state as an input:

In[6]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{x_} :> Mod[x + 1, 4]}, {1}, 1}}, {0}, 6]
Out[6]=

Use expression-based states to create an automata network modeling a pedestrian signal that follows a traffic light:

In[7]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{"red"} -> "green", {"green"} -> "yellow", {"yellow"} -> "red"}, {1}, 1}, {{{"red"} -> "walk", {_} -> "wait"}, {1}, 2}}, {"red", "wait"}, 5]
Out[7]=

By using patterns and conditions in the rules we create a ring of automata where each becomes 1 when at least two of itself and its two neighbors are 1:

In[8]:=
ResourceFunction["AutomataNetworkRun"][
 Table[{{{x__} :> Boole[Total[{x}] >= 2]}, {Mod[i - 2, 6] + 1, i, Mod[i, 6] + 1}, i}, {i, 6}], {1, 1, 0, 1, 0, 0}, 3]
Out[8]=

Applications (3) 

The state transition graph of the Boolean network from Basic Examples links each list of the states to the next one:

In[9]:=
network = {{{{0} -> 1, {1} -> 0}, {3}, 1}, {{{1, 1} -> 1, {_, _} -> 0}, {1, 3}, 2}, {{{x_, y_} :> Mod[x + y, 2]}, {1, 2}, 3}};
stateGraph = Graph[# -> ResourceFunction["AutomataNetworkRun"][network, #, 1][[2]] & /@ Tuples[{0, 1}, 3], VertexLabels -> Automatic]
Out[9]=

Every evolution of this network ends in the same cycle of five states, which is its only attractor:

In[10]:=
FindCycle[stateGraph, Infinity, All]
Out[10]=

Model a synchronous 3-bit binary counter where automaton 1 is the lowest bit, and each bit flips when all lower bits are 1:

In[11]:=
ResourceFunction["AutomataNetworkRun"][counter, {0, 0, 0}, 8]
Out[11]=

Read the bits as binary numbers:

In[12]:=
FromDigits[Reverse[#], 2] & /@ ResourceFunction["AutomataNetworkRun"][counter, {0, 0, 0}, 8]
Out[12]=

Simulate a random Boolean network (as used by Kauffman to model gene regulation) where each of 40 automata has 2 random inputs and a random Boolean function:

In[13]:=
SeedRandom[1234];
In[14]:=
randomNetwork = Table[{Thread[Tuples[{0, 1}, 2] -> RandomInteger[1, 4]], RandomInteger[{1, 40}, 2], i}, {i, 40}];
In[15]:=
evolution = ResourceFunction["AutomataNetworkRun"][randomNetwork, RandomInteger[1, 40], 60];
In[16]:=
ArrayPlot[evolution]
Out[16]=

Find the lengths of the transient and of the cycle that the network settles into:

In[17]:=
Length /@ FindTransientRepeat[evolution, 2]
Out[17]=

Properties and Relations (3) 

A network in which each automaton on a ring uses its left neighbor, itself and its right neighbor gives the same evolution as CellularAutomaton:

In[18]:=
rule30 = Thread[Tuples[{1, 0}, 3] -> IntegerDigits[30, 2, 8]];
ring = Table[{rule30, {Mod[i - 2, 11] + 1, i, Mod[i, 11] + 1}, i}, {i, 11}];
ResourceFunction["AutomataNetworkRun"][ring, CenterArray[1, 11], 10] ===
  CellularAutomaton[30, CenterArray[1, 11], 10]
Out[18]=

Reordering the automata reorders the states in the result but does not change the evolution:

In[19]:=
network = {{{{0} -> 1, {1} -> 0}, {3}, 1}, {{{1, 1} -> 1, {_, _} -> 0}, {1, 3}, 2}, {{{x_, y_} :> Mod[x + y, 2]}, {1, 2}, 3}};
Reverse /@ ResourceFunction["AutomataNetworkRun"][Reverse[network], {1, 0, 1}, 5] === ResourceFunction["AutomataNetworkRun"][network, {1, 0, 1}, 5]
Out[19]=

With finitely many states every evolution eventually repeats; use FindTransientRepeat to find the transient and the repeating cycle:

In[20]:=
network = {{{{0} -> 1, {1} -> 0}, {3}, 1}, {{{1, 1} -> 1, {_, _} -> 0}, {1, 3}, 2}, {{{x_, y_} :> Mod[x + y, 2]}, {1, 2}, 3}};
FindTransientRepeat[
 ResourceFunction["AutomataNetworkRun"][network, {0, 1, 0}, 20], 2]
Out[20]=

Possible Issues (5) 

If no rule matches the states of the inputs then the new state is the list of those states:

In[21]:=
ResourceFunction["AutomataNetworkRun"][{{{{0} -> 1}, {1}, 1}}, {1}, 2]
Out[21]=

Add a rule with a general pattern at the end to give a default state:

In[22]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{0} -> 1, {_} -> 0}, {1}, 1}}, {1}, 2]
Out[22]=

Each automaton must have at least one input:

In[23]:=
ResourceFunction["AutomataNetworkRun"][{{{{} -> 1}, {}, 1}}, {0}, 2]
Out[23]=

For an automaton with a constant state one can use its own state as the input:

In[24]:=
ResourceFunction["AutomataNetworkRun"][{{{{_} -> 1}, {1}, 1}}, {0}, 2]
Out[24]=

If a label in inputsi does not belong to any automaton, then the state becomes a list that contains Missing, and no message is issued:

In[25]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{0} -> 1, {1} -> 0}, {2}, 1}}, {0}, 2]
Out[25]=

If several automata have the same label then the first of them is used as the input:

In[26]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{x_} :> x}, {1}, 1}, {{{x_} :> x}, {1}, 1}}, {"a", "b"}, 2]
Out[26]=

init must have one state for each automaton. Otherwise, a message is issued and the result is not evaluated:

In[27]:=
ResourceFunction[
 "AutomataNetworkRun"][{{{{x_} :> 1 - x}, {1}, 1}}, {0, 1}, 2]
Out[27]=

Neat Examples (2) 

Rewire a few inputs of a rule 90 cellular automaton on a ring and compare the evolutions:

In[28]:=
GraphicsRow[
 ArrayPlot[
    ResourceFunction["AutomataNetworkRun"][
     Table[{rule90, #[[i]], i}, {i, 61}],
      CenterArray[1, 61],
      60]] & /@
  {ringInputs, rewired}]
Out[28]=

Evolution of some Boolean networks in which each automaton has three inputs:

In[29]:=
networks = Table[Table[{Thread[Tuples[{0, 1}, 3] -> RandomInteger[1, 8]], RandomInteger[{1, 40}, 3], i}, {i, 40}], 3];
In[30]:=
GraphicsRow[
 ArrayPlot[
    ResourceFunction["AutomataNetworkRun"][#, RandomInteger[1, 40], 40]] & /@ networks]
Out[30]=

Publisher

Eric James Parfitt

Version History

  • 1.0.0 – 05 October 2026

Source Metadata

Related Resources

License Information