programdemos/life-microscope/life-microscope.xtl

Conway's Life under the microscope: the whole rule is one line, u:l_ife, and every array it builds on the way is shown here, for a glider on a 6 by 6 board (the edges wrap around). Run it with "xetal run demos/life-microscope/life-microscope.xtl"; it prints the board, the nine shifted copies' shape, their sum, the next board, and the glider four generations on (moved one cell down and to the right). The live page draws these same arrays as it runs: https://softwarewrighter.github.io/X_eTaL-demos/life-microscope/

source

The rule

ᵘl̲ife : (Num a, Truthy a) => a -> a

function · line 19

u:l_ife board: the next generation of a 0/1 board, read right to left. Rotating ⍵ by every offset in -1 0 1 along both axes and summing gives S, each cell plus its eight neighbors (it counts the cell itself too, so "2 or 3 neighbors" becomes "S = 3, or alive and S = 4"); a cell lives next when S is 3, or when it is alive and S is 4.

ᵘl̲ife ← { ('+ r̲/₁₂ -1 0 1 o̲-₁₂ ⍵) { (⍺ = 3) + ⍵ × ⍺ = 4 } ⍵ }

A glider, one step at a time

b : Int

value · line 24

b: a glider in a 6 by 6 board.

b ← 6 6 r̲eshape 0 1 0 0 0 0  0 0 1 0 0 0  1 1 1 0 0 0  0 0 0 0 0 0  0 0 0 0 0 0  0 0 0 0 0 0

r : Int

value · line 31

r: the board rotated by every offset -1 0 1 along both axes: a 3 by 3 arrangement of shifted boards, one for each neighbor (and the cell itself). In the copy for offsets (dy, dx), each cell holds its neighbor at (dy, dx).

r ← -1 0 1 o̲-₁₂ b

s : Int

value · line 36

s: the nine copies added over the two offset axes: S, each cell plus its eight neighbors.

s ← '+ r̲/₁₂ r