▦ MATRIX THINKING

GAME LAB 07 · A RULE FOR THE WHOLE WORLD

One matrix rule.
A world of behaviour.

No instructions tell a glider to move. Apply the same rule to every cell, at once, and movement emerges. Follow the matrices that produce it.

01 / WORLD W · CURRENT GENERATION

Blue = alive (1) · pale = dead (0). Click while paused to edit. The yellow outline selects a cell for inspection.

02 / N · SUM OF EIGHT SHIFTED MATRICES

03 / BOOLEAN MASKS · BIRTH OR SURVIVAL

Yellow B = birth · teal S = survival · 0 = neither. The two masks cannot overlap.

04 / NEXT · THE WHOLE NEXT WORLD

Birth OR survival. This is a preview until the simultaneous update replaces W. No cell reads a partly updated neighbour.

EIGHT SHIFTS, ONE SUM

Add neighbours
for every cell.

The arrows identify which neighbour is copied into each destination cell. Select a direction to inspect one whole shifted matrix below. The centre is excluded.

NUMPY · OPERATIONS ON WHOLE ARRAYS

# Finite world: outside cells are zero.
padded = np.pad(W, 1, mode="constant")
N = np.zeros(W.shape, dtype=np.uint8)
for dy, dx in offsets:  # eight directions
    N += padded[1+dy:1+dy+H,
                1+dx:1+dx+WIDTH]

birth = (~W) & (N == 3)
survive = W & ((N == 2) | (N == 3))
next_world = birth | survive
W = next_world  # one simultaneous update

W is a Boolean matrix; N is an integer matrix. The loop visits eight directions, not individual cells. Each addition and comparison operates on an entire array.

The same rule can be written compactly:

next_world = (N == 3) | (W & (N == 2))

JavaScript simulation; the NumPy code explains the equivalent array operations. This finite 16 × 24 world has a dead exterior and does not wrap. Patterns may disappear at an edge. Conway’s rules: a living cell survives with 2 or 3 neighbours; a dead cell is born with exactly 3.

We describe the behaviour of the world.

We do not program a blinker to oscillate or a glider to travel. We define how the world changes from one matrix to the next. The same local rule, applied everywhere, creates larger patterns.

Try the blinker with One matrix operation. Watch eight shifts build N, then form the masks, then commit the new world. Compare this with Play, where those same operations repeat automatically.