bmat ← ##.life bmat ⍝ John Conway's "Game of Life". This version of John Conway's cellular automaton takes a boolean matrix argument representing a population of "creatures" and returns a boolean matrix of the succeeding generation. Each cell in the matrix may be occupied by a creature (1) or be empty (0). The two rules of life are: [1] An empty cell that has exactly 3 neighbouring occupied cells is "born" into in the next generation. [2] An occupied cell that has exactly 2 or 3 neighbouring occupied cells, sur- vives to the next generation. Otherwise, its occupant dies (of loneliness or overcrowding). In the following example, only the creature in the centre survives but new ones are born above and below it. The next generation thus has three creatures in a vertical line; the generation after that reverts to the horizontal; and so on. ┼───┼───┼───┼ ┼───┼───┼───┼ ┼───┼───┼───┼ │ · │ · │ · │ │ · │ ⍟ │ · │ │ · │ · │ · │ ┼───┼───┼───┼ ┼───┼───┼───┼ ┼───┼───┼───┼ │ ⍟ │ ⍟ │ ⍟ │ → │ · │ ⍟ │ · │ → │ ⍟ │ ⍟ │ ⍟ │ → ... ┼───┼───┼───┼ ┼───┼───┼───┼ ┼───┼───┼───┼ │ · │ · │ · │ │ · │ ⍟ │ · │ │ · │ · │ · │ ┼───┼───┼───┼ ┼───┼───┼───┼ ┼───┼───┼───┼ For more complex initial configurations, the sequence may develop for many gen- erations before repeating. The R-Pentomino is an example: ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ │ · │ · │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ · │ ⍟ │ · │ │ · │ · │ ⍟ │ · │ · │ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ │ · │ · │ ⍟ │ ⍟ │ · │ │ · │ ⍟ │ ⍟ │ ⍟ │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ ⍟ │ · │ │ ⍟ │ · │ · │ ⍟ │ · │ │ ⍟ │ ⍟ │ · │ ⍟ │ ⍟ │ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ │ · │ ⍟ │ ⍟ │ · │ · │ → │ · │ ⍟ │ · │ · │ · │ → │ ⍟ │ · │ · │ ⍟ │ · │ → │ ⍟ │ · │ · │ ⍟ │ · │ → │ ⍟ │ · │ · │ ⍟ │ · │ → │ ⍟ │ · │ · │ ⍟ │ · │ → ... ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ │ · │ · │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ │ · │ ⍟ │ ⍟ │ · │ · │ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ │ · │ · │ · │ · │ · │ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼ 2-manifolds ¯¯¯¯¯¯¯¯¯¯¯ In the coding in this workspace, the use of ⊖ and ⌽ render opposite edges of the creatures' rectangular universe adjacent. In effect, they live on the surface of a torus (doughnut). We illustrate this arrangement by using a little square dia- gram, which shows the orientations of the connections of corresponding edges: ┌─→─┐ torus: ⍋ ⍋ left side joined to right └─→─┘ lower edge joined to upper We can visualise the square, made from a very flexible material, being distorted so that the left and right sides are joined with their ⍋ arrows aligned to form a tube. We then stretch the tube and bend it to join its two circular ends with the → arrows aligned, to form a torus. To investigate universes (technically "2-manifolds") other than the torus, we can apply the life function under various operators, which adjust the edge con- nections. The possibilites are: plane←{ ⍝ ┌───┐ plane: ⍺⍺ block T block ⍵ ⍝ │ │ left and right disconnected } ⍝ └───┘ lower and upper disconnected cylinder←{ ⍝ ┌───┐ cylinder: ⍺⍺ join T block ⍵ ⍝ ⍋ ⍋ left and right joined } ⍝ └───┘ lower and upper disconnected torus←{ ⍝ ┌─→─┐ torus: ⍺⍺ join T join ⍵ ⍝ ⍋ ⍋ left and right joined } ⍝ └─→─┘ lower and upper joined möbius←{ ⍝ ┌─→─┐ möbius strip: ⍺⍺ block T twist ⍵ ⍝ │ │ left and right disconnected } ⍝ └─←─┘ lower and upper twist-joined klein←{ ⍝ ┌─→─┐ klein bottle: ⍺⍺ join T twist ⍵ ⍝ ⍋ ⍋ left and right joined } ⍝ └─←─┘ lower and upper twist-joined rp2←{ ⍝ ┌─→─┐ real projective plane: ⍺⍺ twist T twist ⍵ ⍝ ⍋ ⍒ left and right twist-joined } ⍝ └─←─┘ lower and upper twist-joined ⍝ where: join←{ ⍝ ┌─→─┐ identity operator: ⍺⍺ ⍵ ⍝ top and bottom joined } ⍝ └─→─┘ block←{ ⍝ ┌───┐ temporary 0-row: 1↓⍺⍺ 0⍪⍵ ⍝ top and bottom disconnected } ⍝ └───┘ (manifold-with-boundary) twist←{ ⍝ ┌─←─┐ temporary reversed rows: 1↓¯1↓⍺⍺(⌽¯1↑⍵)⍪⍵⍪⌽1↑⍵ ⍝ top and bottom twisted and } ⍝ └─→─┘ joined T←{⍉⍺⍺⍉⍵} ⍝ under transpose: column-wise <V>⍢⍉ So: glider ← 5 5↑ 3 3⍴ 0 0 1, 1 0 1, 0 1 1 show←{'·⍟'[⎕io+⍵]} ⍝ display function show glider ⍝ glider in small arena ··⍟·· ⍟·⍟·· ·⍟⍟·· ····· ····· Operator →traj← applies its operand cumulatively until a cycle is detected: show¨ life traj glider ⍝ life on a torus (default) ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│····⍟│⍟···⍟│⍟···⍟│⍟⍟··⍟│⍟⍟···│·⍟··⍟│·⍟⍟··│··⍟··│⍟·⍟··│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·⍟···│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│⍟···⍟│⍟····│⍟··⍟·│⍟····│····⍟│⍟····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│⍟··⍟⍟│⍟···⍟│⍟··⍟·│⍟⍟···│·⍟···│·⍟··⍟│·⍟···│⍟····│·⍟···│·····│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ To save typing, we can distil the above expression into a "try" operator: try←{show¨ ⍺⍺ traj ⍵} ⍝ repeat until cycle detected. life torus try glider ⍝ life on a torus. ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│····⍟│⍟···⍟│⍟···⍟│⍟⍟··⍟│⍟⍟···│·⍟··⍟│·⍟⍟··│··⍟··│⍟·⍟··│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·⍟···│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│⍟···⍟│⍟····│⍟··⍟·│⍟····│····⍟│⍟····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│⍟··⍟⍟│⍟···⍟│⍟··⍟·│⍟⍟···│·⍟···│·⍟··⍟│·⍟···│⍟····│·⍟···│·····│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ Now, spot the difference if we apply life under operator [plane]. As soon as the glider hits an edge, parts of it disappear and so it no longer flies: life plane try glider ⍝ life on a plane. ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│·····│·····│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│····⍟│····⍟│···⍟⍟│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│···⍟⍟│···⍟⍟│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ (the final ⍟⍟ is a stable configuration, as each cell has exactly 3 neighbours) ⍟⍟ life cylinder try 10 5↑glider ⍝ life on a cylinder. ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│⍟···⍟│⍟····│⍟··⍟·│⍟····│····⍟│⍟····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│⍟··⍟⍟│⍟···⍟│⍟··⍟·│⍟⍟···│·⍟···│·⍟··⍟│·⍟···│⍟····│·⍟···│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│····⍟│⍟···⍟│⍟···⍟│⍟⍟··⍟│⍟⍟···│·⍟··⍟│·⍟⍟··│··⍟··│⍟·⍟··│··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·⍟···│·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│⍟···⍟│⍟····│⍟··⍟·│⍟····│⍟···⍟│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│⍟··⍟⍟│⍟···⍟│⍟···⍟│⍟···⍟│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ (again the final configuration is stable as the ⍟s are adjacent across the edge) life möbius try 5 10↑glider ⍝ life on a möbius strip. ┌──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┐ │··⍟·······│·⍟········│··⍟·······│··········│··········│··········│··········│··········│··········│··········│··········│·····⍟····│····⍟⍟····│····⍟⍟····│···⍟⍟⍟····│···⍟⍟·····│···⍟·⍟····│··⍟⍟······│··⍟·······│··⍟·⍟·····│··⍟·······│···⍟······│··⍟·······│··········│··········│··········│··········│··········│··········│··········│··········│··········│ │⍟·⍟·······│··⍟⍟······│···⍟······│·⍟·⍟······│···⍟······│··⍟·······│···⍟······│··········│··········│··········│··········│··········│··········│··········│··········│····⍟·····│···⍟⍟·····│···⍟⍟·····│··⍟⍟⍟·····│··⍟⍟······│··⍟·⍟·····│·⍟⍟·······│·⍟········│·⍟·⍟······│·⍟········│··⍟·······│·⍟········│··········│··········│··········│··········│··········│ │·⍟⍟·······│·⍟⍟·······│·⍟⍟⍟······│··⍟⍟······│·⍟·⍟······│···⍟⍟·····│····⍟·····│··⍟·⍟·····│····⍟·····│···⍟······│····⍟·····│··········│··········│··········│··········│··········│··········│··········│··········│···⍟······│··⍟⍟······│··⍟⍟······│·⍟⍟⍟······│·⍟⍟·······│·⍟·⍟······│⍟⍟········│⍟·········│⍟·⍟·······│⍟·········│·⍟········│··········│··········│ │··········│··········│··········│··⍟·······│··⍟⍟······│··⍟⍟······│··⍟⍟⍟·····│···⍟⍟·····│··⍟·⍟·····│····⍟⍟····│·····⍟····│···⍟·⍟····│·····⍟····│····⍟·····│·····⍟····│··········│··········│··········│··········│··········│··········│··········│··········│··⍟·······│·⍟⍟·······│·⍟⍟·······│⍟⍟⍟·······│⍟⍟········│⍟·⍟·······│⍟·········│⍟·········│⍟⍟········│ │··········│··········│··········│··········│··········│··········│··········│···⍟······│···⍟⍟·····│···⍟⍟·····│···⍟⍟⍟····│····⍟⍟····│···⍟·⍟····│·····⍟⍟···│······⍟···│····⍟·⍟···│······⍟···│·····⍟····│······⍟···│··········│··········│··········│··········│··········│··········│··········│··········│·⍟········│⍟⍟········│⍟⍟········│⍟⍟········│⍟⍟········│ └──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┘ (notice how its direction changes as the glider crosses the lower edge) life klein try glider ⍝ life on a klein bottle. ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟···⍟│⍟···⍟│⍟⍟··⍟│·⍟··⍟│·⍟···│·⍟··⍟│⍟····│·⍟···│·····│·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│···⍟⍟│····⍟│⍟··⍟·│⍟····│⍟⍟···│⍟⍟··⍟│·⍟···│·⍟⍟··│··⍟··│⍟·⍟··│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│⍟····│⍟····│⍟····│⍟····│·····│⍟····│·····│·····│·····│·····│·····│·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│····⍟│·····│···⍟·│·····│····⍟│·····│⍟····│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·⍟···│·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·⍟···│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│····⍟│·····│···⍟·│·····│····⍟│·····│⍟····│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│⍟····│⍟····│⍟····│⍟····│·····│⍟····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│···⍟⍟│····⍟│⍟··⍟·│⍟····│⍟⍟···│⍟⍟··⍟│·⍟···│·⍟⍟··│··⍟··│⍟·⍟··│··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟···⍟│⍟···⍟│⍟⍟··⍟│·⍟··⍟│·⍟···│·⍟··⍟│⍟····│·⍟···│·····│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ life rp2 try 11 5↑glider ⍝ life on the real projective plane. ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│····⍟│····⍟│····⍟│·····│·····│ │⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│···⍟⍟│····⍟│···⍟·│·····│·····│·····│ │·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│····⍟│·····│···⍟·│·····│····⍟│·····│·····│ │·····│·····│·····│··⍟··│··⍟⍟·│··⍟⍟·│··⍟⍟⍟│···⍟⍟│··⍟·⍟│····⍟│·····│···⍟·│·····│····⍟│·····│·····│·····│·····│·····│·⍟···│·⍟⍟··│·⍟⍟··│·⍟⍟⍟·│··⍟⍟·│·⍟·⍟·│···⍟⍟│····⍟│··⍟·⍟│····⍟│···⍟·│····⍟│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│···⍟·│···⍟⍟│···⍟⍟│···⍟⍟│····⍟│···⍟·│·····│·····│⍟···⍟│⍟⍟···│⍟⍟···│⍟⍟⍟··│·⍟⍟··│⍟·⍟··│··⍟⍟·│···⍟·│·⍟·⍟·│···⍟·│··⍟··│···⍟·│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│····⍟│⍟···⍟│⍟···⍟│⍟⍟··⍟│⍟⍟···│·⍟··⍟│·⍟⍟··│··⍟··│⍟·⍟··│··⍟··│·⍟···│··⍟··│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟····│⍟····│⍟⍟···│·⍟···│·⍟···│·⍟···│⍟····│·⍟···│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟····│⍟····│⍟····│·····│⍟····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟····│⍟····│⍟····│·····│·····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│⍟····│⍟····│⍟····│⍟····│·····│ │·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│·····│⍟····│·⍟···│·····│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ Library ------- If you are viewing this page from an APL session, you can generate a boolean matrix argument for life from any of the following patterns using these steps: 1. While pressing the _right_ mouse button, select the area within a box. 2. From this edit window menu, select Edit->Copy. 3. Open a new edit window to receive the character matrix: )ed -pattern 4. Select Edit->Paste in the new window, then close it. 5. Test using, for example: {⎕←'─'⍪'·⍟'[⎕io+⍵] ⋄ ∇ life ⍵} 20 50↑pattern='⍟' R-Pentomino Glider Glider Gun (Gosper) ┌───┐ ┌───┐ ┌────────────────────────────────────┐ │·⍟⍟│ │··⍟│ │························⍟···········│ │⍟⍟·│ │⍟·⍟│ │······················⍟·⍟···········│ │·⍟·│ │·⍟⍟│ │············⍟⍟······⍟⍟············⍟⍟│ └───┘ └───┘ │···········⍟···⍟····⍟⍟············⍟⍟│ │⍟⍟········⍟·····⍟···⍟⍟··············│ Bistable states │⍟⍟········⍟···⍟·⍟⍟····⍟·⍟···········│ ┌───┐ ┌────┐ │··········⍟·····⍟·······⍟···········│ │⍟⍟⍟│ │·⍟⍟⍟│ │···········⍟···⍟····················│ └───┘ │⍟⍟⍟·│ │············⍟⍟······················│ └────┘ └────────────────────────────────────┘ Stable states The glider gun generates a stream of ┌──┐ ┌────┐ gliders. │⍟⍟│ │·⍟⍟·│ │⍟⍟│ │⍟··⍟│ └──┘ │·⍟⍟·│ └────┘ Technical note -------------- The expression for the next generation in the life game: ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ ⍝ Expression for next generation. is developed in real time in YouTube video: http://www.youtube.com/watch?gl=GB&hl=en-GB&v=a9xAKttWgP4&fmt=18 The YouTube expression differs very slightly: +/+⌿ instead of +/, ⌽¨⊂ instead of ∘.⌽⊂ but is essentially the same. Golfing ------- Sometimes, it's fun to look for a shorter expression to do the same job, even at the expense of clarity. This is known as "golfing" - trying to achieve the same result but with fewer strokes. For example +/, is one character shorter than +/+⌿ and ⌽¨⊂ is shorter than ∘.⌽⊂. We can transform our coding into a marginally shorter, if somewhat more complex, expression by observing that: ⍺ ⊖ ⍵ ←→ ⍉ ⍺ ⌽⍉ ⍵ thus: ⍺ ⌽ ⍺ ⊖ ⍵ ←→ ⍺ ⌽ ⍉ ⍺ ⌽⍉ ⍵ ←→ ⍺ ⌽∘⍉ ⍺ ⌽∘⍉ ⍵ ←→ ⍺ ⌽∘⍉⍣2 ⍵ resulting in: ↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.(⌽∘⍉)⍣2⊂⍵ ⍝ Expression for next generation. APL, which can be viewed as an array _notation_, offers many opportunities for such expression transformation. This would be more difficult in a scalar- processing language with explicit loops. Stencil ------- The introduction of primitive operator stencil (⌺) in Dyalog V16 presents more opportunities: lifeJF ← {3=s-⍵∧4=s←{+/,⍵}⌺3 3⊢⍵} ⍝ Jay Foad Roger Hui precomputes a vector of patterns: ⎕ ← U ← {3 3⍴(9⍴2)⊤⍵}¨ ⍸ {2 2⌷life 0,0,⍨0⍪0⍪⍨3 3⍴(9⍴2)⊤⍵}¨ ⍳512 ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ │0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│ │1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 0│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│0 1 1│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 0│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 0 1│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 0│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│1 1 1│ │0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│0 0 0│0 0 1│0 1 0│0 1 1│1 0 0│1 0 1│1 1 0│1 1 1│ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ leading to: lifeRH ← {B[{+/,A×⍵}⌺3 3⊢⍵]} where B ← (⍳2*9) ∊ 2⊥¨,¨U A ← 3 3⍴2*⌽⍳9 and Adám Brudzewsky uses the above definition of U in this train: lifeAB ← U∊⍨⊢∘⊂⌺3 3 Here is John Niss Hansen's coding: lifeJNH←{ s c←(+/,(4+⎕io)∘⊃),⍵ ⋄ s=3:1 ⋄ c=0:0 ⋄ s=4 }⌺3 3 Examples: {'·⍟'[⎕io+⍵]}¨life traj 5 8↑3 3⍴0 0 1 1 0 1 0 1 1 ⍝ Glider. ┌────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┐ │··⍟·····│·⍟······│··⍟·····│········│········│········│········│········│········│········│········│····⍟···│····⍟⍟··│····⍟⍟··│····⍟⍟⍟·│·····⍟⍟·│····⍟·⍟·│······⍟⍟│·······⍟│·····⍟·⍟│·······⍟│······⍟·│·······⍟│········│········│········│········│········│········│········│········│·⍟······│·⍟⍟·····│·⍟⍟·····│·⍟⍟⍟····│··⍟⍟····│·⍟·⍟····│···⍟⍟···│····⍟···│··⍟·⍟···│····⍟···│···⍟····│····⍟···│········│········│········│········│········│········│········│········│······⍟·│······⍟⍟│······⍟⍟│⍟·····⍟⍟│⍟······⍟│⍟·····⍟·│⍟⍟······│·⍟······│·⍟·····⍟│·⍟······│⍟·······│·⍟······│········│········│········│········│········│········│········│········│···⍟····│···⍟⍟···│···⍟⍟···│···⍟⍟⍟··│····⍟⍟··│···⍟·⍟··│·····⍟⍟·│······⍟·│····⍟·⍟·│······⍟·│·····⍟··│······⍟·│········│········│········│········│········│········│········│········│⍟·······│⍟⍟······│⍟⍟······│⍟⍟⍟·····│·⍟⍟·····│⍟·⍟·····│··⍟⍟····│···⍟····│·⍟·⍟····│···⍟····│··⍟·····│···⍟····│········│········│········│········│········│········│········│········│·····⍟··│·····⍟⍟·│·····⍟⍟·│·····⍟⍟⍟│······⍟⍟│·····⍟·⍟│⍟······⍟│⍟·······│⍟·····⍟·│⍟·······│·······⍟│⍟·······│········│········│········│········│········│········│········│········│··⍟·····│··⍟⍟····│··⍟⍟····│··⍟⍟⍟···│···⍟⍟···│··⍟·⍟···│····⍟⍟··│·····⍟··│···⍟·⍟··│·····⍟··│····⍟···│·····⍟··│········│········│········│········│········│········│········│········│·······⍟│⍟······⍟│⍟······⍟│⍟⍟·····⍟│⍟⍟······│·⍟·····⍟│·⍟⍟·····│··⍟·····│⍟·⍟·····│ │⍟·⍟·····│··⍟⍟····│···⍟····│·⍟·⍟····│···⍟····│··⍟·····│···⍟····│········│········│········│········│········│········│········│········│·····⍟··│·····⍟⍟·│·····⍟⍟·│·····⍟⍟⍟│······⍟⍟│·····⍟·⍟│⍟······⍟│⍟·······│⍟·····⍟·│⍟·······│·······⍟│⍟·······│········│········│········│········│········│········│········│········│··⍟·····│··⍟⍟····│··⍟⍟····│··⍟⍟⍟···│···⍟⍟···│··⍟·⍟···│····⍟⍟··│·····⍟··│···⍟·⍟··│·····⍟··│····⍟···│·····⍟··│········│········│········│········│········│········│········│········│·······⍟│⍟······⍟│⍟······⍟│⍟⍟·····⍟│⍟⍟······│·⍟·····⍟│·⍟⍟·····│··⍟·····│⍟·⍟·····│··⍟·····│·⍟······│··⍟·····│········│········│········│········│········│········│········│········│····⍟···│····⍟⍟··│····⍟⍟··│····⍟⍟⍟·│·····⍟⍟·│····⍟·⍟·│······⍟⍟│·······⍟│·····⍟·⍟│·······⍟│······⍟·│·······⍟│········│········│········│········│········│········│········│········│·⍟······│·⍟⍟·····│·⍟⍟·····│·⍟⍟⍟····│··⍟⍟····│·⍟·⍟····│···⍟⍟···│····⍟···│··⍟·⍟···│····⍟···│···⍟····│····⍟···│········│········│········│········│········│········│········│········│······⍟·│······⍟⍟│······⍟⍟│⍟·····⍟⍟│⍟······⍟│⍟·····⍟·│⍟⍟······│·⍟······│·⍟·····⍟│·⍟······│⍟·······│·⍟······│········│········│········│········│········│········│········│········│···⍟····│···⍟⍟···│···⍟⍟···│···⍟⍟⍟··│····⍟⍟··│···⍟·⍟··│·····⍟⍟·│······⍟·│····⍟·⍟·│······⍟·│·····⍟··│······⍟·│········│········│········│········│········│········│········│········│⍟·······│⍟⍟······│⍟⍟······│⍟⍟⍟·····│·⍟⍟·····│ │·⍟⍟·····│·⍟⍟·····│·⍟⍟⍟····│··⍟⍟····│·⍟·⍟····│···⍟⍟···│····⍟···│··⍟·⍟···│····⍟···│···⍟····│····⍟···│········│········│········│········│········│········│········│········│······⍟·│······⍟⍟│······⍟⍟│⍟·····⍟⍟│⍟······⍟│⍟·····⍟·│⍟⍟······│·⍟······│·⍟·····⍟│·⍟······│⍟·······│·⍟······│········│········│········│········│········│········│········│········│···⍟····│···⍟⍟···│···⍟⍟···│···⍟⍟⍟··│····⍟⍟··│···⍟·⍟··│·····⍟⍟·│······⍟·│····⍟·⍟·│······⍟·│·····⍟··│······⍟·│········│········│········│········│········│········│········│········│⍟·······│⍟⍟······│⍟⍟······│⍟⍟⍟·····│·⍟⍟·····│⍟·⍟·····│··⍟⍟····│···⍟····│·⍟·⍟····│···⍟····│··⍟·····│···⍟····│········│········│········│········│········│········│········│········│·····⍟··│·····⍟⍟·│·····⍟⍟·│·····⍟⍟⍟│······⍟⍟│·····⍟·⍟│⍟······⍟│⍟·······│⍟·····⍟·│⍟·······│·······⍟│⍟·······│········│········│········│········│········│········│········│········│··⍟·····│··⍟⍟····│··⍟⍟····│··⍟⍟⍟···│···⍟⍟···│··⍟·⍟···│····⍟⍟··│·····⍟··│···⍟·⍟··│·····⍟··│····⍟···│·····⍟··│········│········│········│········│········│········│········│········│·······⍟│⍟······⍟│⍟······⍟│⍟⍟·····⍟│⍟⍟······│·⍟·····⍟│·⍟⍟·····│··⍟·····│⍟·⍟·····│··⍟·····│·⍟······│··⍟·····│········│········│········│········│········│········│········│········│····⍟···│····⍟⍟··│····⍟⍟··│····⍟⍟⍟·│·····⍟⍟·│····⍟·⍟·│······⍟⍟│·······⍟│·····⍟·⍟│·······⍟│······⍟·│·······⍟│········│········│········│········│········│········│········│········│·⍟······│ │········│········│········│··⍟·····│··⍟⍟····│··⍟⍟····│··⍟⍟⍟···│···⍟⍟···│··⍟·⍟···│····⍟⍟··│·····⍟··│···⍟·⍟··│·····⍟··│····⍟···│·····⍟··│········│········│········│········│········│········│········│········│·······⍟│⍟······⍟│⍟······⍟│⍟⍟·····⍟│⍟⍟······│·⍟·····⍟│·⍟⍟·····│··⍟·····│⍟·⍟·····│··⍟·····│·⍟······│··⍟·····│········│········│········│········│········│········│········│········│····⍟···│····⍟⍟··│····⍟⍟··│····⍟⍟⍟·│·····⍟⍟·│····⍟·⍟·│······⍟⍟│·······⍟│·····⍟·⍟│·······⍟│······⍟·│·······⍟│········│········│········│········│········│········│········│········│·⍟······│·⍟⍟·····│·⍟⍟·····│·⍟⍟⍟····│··⍟⍟····│·⍟·⍟····│···⍟⍟···│····⍟···│··⍟·⍟···│····⍟···│···⍟····│····⍟···│········│········│········│········│········│········│········│········│······⍟·│······⍟⍟│······⍟⍟│⍟·····⍟⍟│⍟······⍟│⍟·····⍟·│⍟⍟······│·⍟······│·⍟·····⍟│·⍟······│⍟·······│·⍟······│········│········│········│········│········│········│········│········│···⍟····│···⍟⍟···│···⍟⍟···│···⍟⍟⍟··│····⍟⍟··│···⍟·⍟··│·····⍟⍟·│······⍟·│····⍟·⍟·│······⍟·│·····⍟··│······⍟·│········│········│········│········│········│········│········│········│⍟·······│⍟⍟······│⍟⍟······│⍟⍟⍟·····│·⍟⍟·····│⍟·⍟·····│··⍟⍟····│···⍟····│·⍟·⍟····│···⍟····│··⍟·····│···⍟····│········│········│········│········│········│········│········│········│·····⍟··│·····⍟⍟·│·····⍟⍟·│·····⍟⍟⍟│······⍟⍟│·····⍟·⍟│⍟······⍟│⍟·······│⍟·····⍟·│⍟·······│·······⍟│⍟·······│········│········│········│········│········│ │········│········│········│········│········│········│········│···⍟····│···⍟⍟···│···⍟⍟···│···⍟⍟⍟··│····⍟⍟··│···⍟·⍟··│·····⍟⍟·│······⍟·│····⍟·⍟·│······⍟·│·····⍟··│······⍟·│········│········│········│········│········│········│········│········│⍟·······│⍟⍟······│⍟⍟······│⍟⍟⍟·····│·⍟⍟·····│⍟·⍟·····│··⍟⍟····│···⍟····│·⍟·⍟····│···⍟····│··⍟·····│···⍟····│········│········│········│········│········│········│········│········│·····⍟··│·····⍟⍟·│·····⍟⍟·│·····⍟⍟⍟│······⍟⍟│·····⍟·⍟│⍟······⍟│⍟·······│⍟·····⍟·│⍟·······│·······⍟│⍟·······│········│········│········│········│········│········│········│········│··⍟·····│··⍟⍟····│··⍟⍟····│··⍟⍟⍟···│···⍟⍟···│··⍟·⍟···│····⍟⍟··│·····⍟··│···⍟·⍟··│·····⍟··│····⍟···│·····⍟··│········│········│········│········│········│········│········│········│·······⍟│⍟······⍟│⍟······⍟│⍟⍟·····⍟│⍟⍟······│·⍟·····⍟│·⍟⍟·····│··⍟·····│⍟·⍟·····│··⍟·····│·⍟······│··⍟·····│········│········│········│········│········│········│········│········│····⍟···│····⍟⍟··│····⍟⍟··│····⍟⍟⍟·│·····⍟⍟·│····⍟·⍟·│······⍟⍟│·······⍟│·····⍟·⍟│·······⍟│······⍟·│·······⍟│········│········│········│········│········│········│········│········│·⍟······│·⍟⍟·····│·⍟⍟·····│·⍟⍟⍟····│··⍟⍟····│·⍟·⍟····│···⍟⍟···│····⍟···│··⍟·⍟···│····⍟···│···⍟····│····⍟···│········│········│········│········│········│········│········│········│······⍟·│······⍟⍟│······⍟⍟│⍟·····⍟⍟│⍟······⍟│⍟·····⍟·│⍟⍟······│·⍟······│·⍟·····⍟│·⍟······│⍟·······│·⍟······│········│ └────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┘ ⍝ Conway's automaton is best viewed as an animation. ⍝ Here is a (pretty rough) gui front end: gui←{⎕io←0 ⍝ Life animation. show←{'·⍟'[⍵]} ⍝ formatting function. f←⎕ns'' ⍝ localise class 9 name. _←'f'⎕wc'form' ''(2 48)('OnTop' 1) ⍝ make a form. _←'f.t'⎕wc'Text'(show ⍵)(0 0) ⍝ make a text box. f.t.(FontObj BCol)←'Dyalog Std'(3/255) ⍝ font and white background. ⍺←500 ⍝ default 500ms delay. ⍺ ⍺⍺{ ⍝ _←⎕dl ⍺÷1000 ⍝ delay ⍺ ms. next←⍺⍺ ⍵ ⍝ next generation. f.t.Text←show next ⍝ display new generation. ⍺ ∇ next ⍝ ... and so on. }⍵ } ⍝ Fix this function and the glider_gun as described in "Library" above ⍝ and then try: 100 life gui 30 80↑glider_gun='⍟' ⍝ glider gun on torus. ⍝ But beware: a glider gun in a torus is doomed because it inevitably shoots ⍝ itself in the back. Artillery in a finite manifold is a dangerous business. ⍝ ⍝ Aficionados of the 1979 arcade game "Asteroids", which took place on a ⍝ torus, will recall that the manufacturers thoughtfully gave their canon ⍝ a range just short of the screen's circumferences. ⍝ See: http://en.wikipedia.org/wiki/Asteroids_(video_game) See also: traj See also: http://www.youtube.com/watch?gl=GB&hl=en-GB&v=a9xAKttWgP4&fmt=18 See also: http://www.jsoftware.com/papers/eem/life.htm Back to: contents Back to: Workspaces