cellular_automata.elementary_cellular_automaton

A one-dimensional cellular automaton introduced by Stephen Wolfram. Each cell’s next state depends on its current state and its two immediate neighbors.

Reference:

https://en.wikipedia.org/wiki/Rule_30

Attributes

generations

Functions

generate_rule_30(→ list[list[int]])

Generate multiple generations of Rule 30 automaton.

rule_30_step(→ list[int])

Compute the next generation of a one-dimensional cellular automaton

Module Contents

cellular_automata.elementary_cellular_automaton.generate_rule_30(size: int = 31, generations: int = 15) list[list[int]]

Generate multiple generations of Rule 30 automaton.

Args:

size (int): Number of cells in one generation. Default is 31. generations (int): Number of generations to evolve. Default is 15.

Returns:

list[list[int]]: A list of generations (each a list of 0s and 1s).

Example:
>>> len(generate_rule_30(15, 5))
5
cellular_automata.elementary_cellular_automaton.rule_30_step(current: list[int]) list[int]

Compute the next generation of a one-dimensional cellular automaton following Wolfram’s Rule 30.

Each cell’s next state is determined by its left, center, and right neighbors.

Args:
current (list[int]): The current generation as a list of 0s (dead)

and 1s (alive).

Returns:

list[int]: The next generation as a list of 0s and 1s.

Example:
>>> rule_30_step([0, 0, 1, 0, 0])
[0, 1, 1, 1, 0]
cellular_automata.elementary_cellular_automaton.generations