Two dimensional Cellular Automata
Life-Like Cellular Automata
CellularAutomata.Life — Type
Life(life_description; radius=1, neighborhood=Moore(radius))Construct a Life-like cellular-automaton rule using Golly birth/survival notation.
Arguments
life_description:(born, survive)neighbor counts.borncontains counts that activate a dead cell;survivecontains counts that preserve a live cell.
Keyword arguments
radius: Radius of the defaultMooreneighborhood. Defaults to 1. Ignored ifneighborhoodis passed explicitly.neighborhood: AnAbstractNeighborhood, such asMoore(radius)(default) orVonNeumann(radius).
Examples
julia> using CellularAutomata
julia> life = Life(((3,), (2, 3)); radius=1);
julia> blinker = [0 0 0 0 0; 0 0 1 0 0; 0 0 1 0 0; 0 0 1 0 0; 0 0 0 0 0];
julia> next_state(life, blinker)
5×5 Matrix{Int64}:
0 0 0 0 0
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0Neighborhoods
CellularAutomata.AbstractNeighborhood — Type
AbstractNeighborhoodSupertype for two-dimensional neighborhood shapes, used to enumerate the cells around a given cell (excluding the cell itself).
Subtypes must implement neighborhood_offsets and neighborhood_radius.
CellularAutomata.Moore — Type
Moore([radius = 1])Square neighborhood: every cell within Chebyshev distance radius, excluding the center. This is the classic Game-of-Life neighborhood and the default for Life.
CellularAutomata.VonNeumann — Type
VonNeumann([radius = 1])Diamond neighborhood: every cell within Manhattan distance radius, excluding the center.
CellularAutomata.neighborhood_offsets — Function
neighborhood_offsets(neighborhood::AbstractNeighborhood)Return an iterable of (row_offset, column_offset) tuples describing the cells in neighborhood. The center offset (0, 0) must not be included.
Custom AbstractNeighborhood subtypes must implement this method.