Skip to content
Sample of 2-D Totalistic Cellular Automaton (Conway + variants)

reas_processing · wolframCA2D

2-D Totalistic Cellular Automaton (Conway + variants)

Each cell looks at its 8 Moore neighbors and applies a totalistic rule. Five built-in rules are included: Conway's Game of Life (B3/S23), HighLife (B36/S23), Day & Night, Seeds (B2/S), and Brian's Brain (3-state). Live cells age, so sustained activity drifts the palette from 'ink_color' toward the optional 'glow_color', visualizing persistent regions. Periodic re-seeding of small patches every 400 ticks keeps the system active.

Original: https://processing.org/examples/gameoflife

▶ Try the live demo (JS port) ▶ Run reference.py via Pyodide 10 formulas have instant JS ports. The Pyodide path runs the actual Python in your browser — first load is ~6 MB, then instant.

Family
reas_processing
Source
reas · processing
Evolution
cellular_automaton
Render
age_tinted_grid
Complexity
low
Agents
1
Year
1970
Author
John Conway (Life, 1970); Reas / Form+Code (creative-coding canon)

Math essence

nbr = sum(8 rolled neighbors). next_grid[dead & nbr in birth_set | alive & nbr in survive_set] = 1. Brian's Brain uses 3 states with refractory dying. All transitions are fully vectorized via numpy.roll on torus.

Parameters

Name Type Default Range Description
dim int 200 50–600 Grid side length (torus topology).
rule_name str conway — Rule: conway, highlife, day_and_night, seeds, brians_brain.
initial_density float 0.32 0.05–0.9 Probability a starting cell is alive.
bg_color tuple 240,235,225 —
ink_color tuple 30,30,50 —
glow_color tuple null — Optional hot color for live cells as age accumulates.
seed int null 0–999999

Reference

First 60 lines of reference.py. Full source: library_external/reas_processing/wolframCA2D/reference.py

from __future__ import annotations

from typing import ClassVar

import numpy as np


LIFE_RULES = {
    "conway": (3, (2, 3)),
    "highlife": (3, (2, 3)),
    "day_and_night": (3, (3, 4), (4, 6), (4, 7)),
    "seeds": (2, tuple()),
    "brians_brain": (2,),
    "wire_world": None,
}


class WolframCA2D:
    """Two-dimensional totalistic cellular automaton.

    Each cell on a torus looks at its 8 Moore neighbors and applies a
    totalistic rule: a birth rule (number of live neighbors required for
    a dead cell to come alive) and a survival rule (number of live
    neighbors required to keep a live cell alive). The canonical
    Conway's Game of Life is B3/S23, and other classics include
    HighLife (B36/S23), Day&Night, Brian's Brain, and Seeds. This is
    the standard 2-D CA referenced in Casey Reas's creative-coding
    curricula.
    """

    family: ClassVar[str] = "reas_processing"
    sketch: ClassVar[str] = "wolframCA2D"

    def __init__(
        self,
        dim: int = 200,
        rule_name: str = "conway",
        initial_density: float = 0.32,
        palette: str = "two_color",
        bg_color: tuple[int, int, int] = (240, 235, 225),
        ink_color: tuple[int, int, int] = (30, 30, 50),
        glow_color: tuple[int, int, int] | None = None,
        seed: int | None = None,
    ) -> None:
        self.dim = dim
        self.rule_name = rule_name
        self.initial_density = initial_density
        self._palette_mode = palette
        self.bg_color = np.array(bg_color, dtype=np.uint8)
        self.ink_color = np.array(ink_color, dtype=np.uint8)
        self.glow_color = (
            np.array(glow_color, dtype=np.uint8) if glow_color is not None else None
        )
        self._seed = seed
        self.reset()

    def _build_rule(self, name: str) -> tuple[set[int], set[int]]:
        if name == "conway":
            return {3}, {2, 3}
        if name == "highlife":

Try running it locally

The reference implementation is self-contained Python with numpy. Install the package and run:

python library_external/reas_processing/wolframCA2D/reference.py

Need help? See Learn for the standard environment setup, or Playground for an in-browser sketchbook.

More from reas · processing

See all reas_processing artworks →