cellular_automata.one_dimensional¶
Return an image of 16 generations of one-dimensional cellular automata based on a given ruleset number https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
Attributes¶
Functions¶
|
|
|
Convert the cells into a greyscale PIL.Image.Image and return it to the caller. |
|
Module Contents¶
- cellular_automata.one_dimensional.format_ruleset(ruleset: int) list[int] ¶
>>> format_ruleset(11100) [0, 0, 0, 1, 1, 1, 0, 0] >>> format_ruleset(0) [0, 0, 0, 0, 0, 0, 0, 0] >>> format_ruleset(11111111) [1, 1, 1, 1, 1, 1, 1, 1]
- cellular_automata.one_dimensional.generate_image(cells: list[list[int]]) PIL.Image.Image ¶
Convert the cells into a greyscale PIL.Image.Image and return it to the caller. >>> from random import random >>> cells = [[random() for w in range(31)] for h in range(16)] >>> img = generate_image(cells) >>> isinstance(img, Image.Image) True >>> img.width, img.height (31, 16)
- cellular_automata.one_dimensional.new_generation(cells: list[list[int]], rule: list[int], time: int) list[int] ¶
- cellular_automata.one_dimensional.CELLS = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]¶
- cellular_automata.one_dimensional.rule_num¶