Two dimensional Cellular Automata

Life-Like Cellular Automata

CellularAutomata.LifeType
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. born contains counts that activate a dead cell; survive contains counts that preserve a live cell.

Keyword arguments

  • radius: Radius of the default Moore neighborhood. Defaults to 1. Ignored if neighborhood is passed explicitly.
  • neighborhood: An AbstractNeighborhood, such as Moore(radius) (default) or VonNeumann(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  0
source

Neighborhoods

CellularAutomata.MooreType
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.

source
CellularAutomata.neighborhood_offsetsFunction
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.

source