cellular_automata.elementary_cellular_automaton =============================================== .. py:module:: cellular_automata.elementary_cellular_automaton .. autoapi-nested-parse:: Elementary Cellular Automaton - Rule 30 --------------------------------------- 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 ---------- .. autoapisummary:: cellular_automata.elementary_cellular_automaton.generations Functions --------- .. autoapisummary:: cellular_automata.elementary_cellular_automaton.generate_rule_30 cellular_automata.elementary_cellular_automaton.rule_30_step Module Contents --------------- .. py:function:: 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 .. py:function:: 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] .. py:data:: generations