These patterns are made by cellular automata: rows of squares that are either on (1) or off (0). Each new row is worked out from the row above using a tiny rule. Different rule numbers make wildly different patterns, from neat triangles to total chaos.
















Make one yourself
This Python program draws rule 90 with # for on and . for off. Each new cell looks at three cells above it, turns them into a number from 0 to 7, and uses that number to pick a bit from the rule. Rule 90 makes a famous triangle pattern called SierpiĆski’s triangle!
rule = 90
cells = [0] * 15 + [1] + [0] * 15
for step in range(16):
print("".join("#" if c else "." for c in cells))
new = []
for i in range(len(cells)):
left = cells[i - 1]
middle = cells[i]
right = cells[(i + 1) % len(cells)]
pattern = left * 4 + middle * 2 + right
new.append((rule >> pattern) & 1)
cells = new
When you run it, it prints:
...............#............... ..............#.#.............. .............#...#............. ............#.#.#.#............ ...........#.......#........... ..........#.#.....#.#.......... .........#...#...#...#......... ........#.#.#.#.#.#.#.#........ .......#...............#....... ......#.#.............#.#...... .....#...#...........#...#..... ....#.#.#.#.........#.#.#.#.... ...#.......#.......#.......#... ..#.#.....#.#.....#.#.....#.#.. .#...#...#...#...#...#...#...#. #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
