morphogen.automata.rules

Transition rules of binary cellular automata (states 0 and 1).

A rule maps the state of the lattice to the next one. Most rules depend on the number n of neighbours in state 1 (outer-totalistic rules):

life (B.../S...)

birth of a cell in state 0 when n is in the birth set, survival of a cell in state 1 when n is in the survival set (Conway’s Game of Life is B3/S23 in 2D).

majority

the cell takes the state of the majority of its neighbourhood, itself included (voting rule): sharp interfaces of positive curvature retreat.

anneal

twisted majority (Vichniac 1984): the outcome is inverted when the vote is closest to a tie. Interfaces then move with their mean curvature, as in the annealing of a binary alloy: domains coarsen into bicontinuous patterns.

conserved

majority with a conserved volume fraction: the cells with the highest local density of phase 1 (random tie-breaking) take state 1, exactly as many as before. Domains coarsen at constant volume fraction (spinodal-like patterns).

probabilistic

birth and survival probabilities depending on n.

activator_inhibitor

Young’s (1984) model of Turing patterns: a cell weighs the active cells of a near disc or ball (activation) against those of a surrounding annulus or shell (inhibition); spots, stripes or labyrinths of a characteristic wavelength emerge.

class morphogen.automata.rules.LatticeContext(offsets: ndarray, periodic: bool = True, boundary: int = 0, dims: int = 3)[source]

Bases: object

Neighbourhood and boundary of the lattice on which a rule acts.

property n_neighbours: int
counts(state: ndarray) → ndarray[source]
class morphogen.automata.rules.Rule[source]

Bases: ABC

Transition rule of a binary automaton.

conserves_fraction = False

whether the volume fraction is conserved (synchronous updates only)

abstractmethod next_state(state: ndarray, lattice: LatticeContext, rng: Generator) → ndarray[source]

State after one synchronous update of every cell.

describe() → str[source]
class morphogen.automata.rules.LifeRule(birth, survival)[source]

Bases: Rule

Outer-totalistic rule B<birth>/S<survival>.

Counts are written as digits (B5678/S45678) or as comma-separated numbers and ranges for 3D neighbourhoods (B13-14,17-19/S13-26).

next_state(state, lattice, rng)[source]

State after one synchronous update of every cell.

describe() → str[source]
class morphogen.automata.rules.MajorityRule(twist: bool = False)[source]

Bases: Rule

Majority vote over the neighbourhood and the cell itself; twist inverts the outcome of the two votes closest to a tie (Vichniac’s annealing rule).

With an odd number of neighbours (triangles across their edges, some Penrose rhombi across their vertices), the cell’s own vote counts twice, so that the number of votes stays odd: ties keep the state of the cell.

next_state(state, lattice, rng)[source]

State after one synchronous update of every cell.

describe() → str[source]
class morphogen.automata.rules.ConservedMajorityRule(fraction: float)[source]

Bases: Rule

Majority with a conserved number of cells in state 1 (fraction of the cells): the cells of highest local density of phase 1 win, ties broken at random (the density is the fraction of phase 1 in the neighbourhood and the cell when neighbourhoods differ in size).

conserves_fraction = True

whether the volume fraction is conserved (synchronous updates only)

n_ones(n_cells: int) → int[source]
next_state(state, lattice, rng)[source]

State after one synchronous update of every cell.

describe() → str[source]
class morphogen.automata.rules.ProbabilisticRule(p_birth, p_survival)[source]

Bases: Rule

Birth with probability p_birth[n] and survival with p_survival[n] (arrays indexed by the number n of neighbours in state 1).

next_state(state, lattice, rng)[source]

State after one synchronous update of every cell.

describe() → str[source]
class morphogen.automata.rules.ActivatorInhibitorRule(activation_radius: float, inhibition_radius: float, weight: float | None = None, fraction: float | None = None, dims: int = 3)[source]

Bases: Rule

Young’s (1984) activator-inhibitor automaton.

The score of a cell is the number of active cells within activation_radius (itself included) minus weight times the number of active cells at distances in (activation_radius, inhibition_radius] (Euclidean distances in cells). The cell becomes active if the score is positive, inactive if negative. With a fraction, the cells of highest score are active instead (conserved volume fraction). The default weight balances the two regions (a uniform state scores 0); on tilings whose discs differ from cell to cell (Penrose), it is balanced cell by cell.

tiling_kernels(lattice: TilingContext)[source]

Discs (CSR, the cell included), rings (CSR) and weights on a tiling.

score(state, lattice) → ndarray[source]
next_state(state, lattice, rng)[source]

State after one synchronous update of every cell.

describe() → str[source]
morphogen.automata.rules.NAMED_RULES = {'anneal': <function <lambda>>, 'clouds': <function <lambda>>, 'life': <function <lambda>>, 'majority': <function <lambda>>}

Named rules. clouds is a 3D Moore rule known to turn noise into cave-like structures (B13-14,17-19/S13-26).

morphogen.automata.rules.make_rule(rule, *, fraction: float | None = None) → Rule[source]

A rule from a name (majority, anneal, conserved, life, clouds), a B.../S... string, or a Rule.