greg mcshane

Conway’s game of life

The Game of Life is a cellular automaton devised by the mathematician John Horton Conway in 1970. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.


Summary of principles


Origins of life LOL

In late 1940, John von Neumann defined life as a creation (as a being or organism)

Stanislaw Ulam invented cellular automata

Conway chose his rules carefully, after considerable experimentation, to meet the following criteria:

  1. There should be no explosive growth.
  2. There should exist small initial patterns with chaotic, unpredictable outcomes.
  3. There should be potential for von Neumann universal constructors.
  4. The rules should be as simple as possible, whilst adhering to the above constraints.

Rules

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead, (or populated and unpopulated, respectively). Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

These rules can be condensed into the following:

Succinct version of rules

If one forgets the biological interpretation of the rules then they reduce to:

State of the cell :

live = true
dead = false

The state of a cell in the next generation is given by:

(S = 3) OU (E = 1 ET S = 2)

where


Using convolutions

I did this by myself but this guy had the same idea. He states that he wants to avoid

As I expected, the lines that checked whether a player had achieved a
five-in-a-row was a verbose series of nested for-loops checking a plethora of
cases. While they often seem like a natural course of action, in many settings
they are often unwieldy and slower than desirable. Luckily for my friend, the
code ran quite quickly, but I thought about whether there was a faster way.

My code from last year:

    H = signal.convolve2d( G, K, boundary='wrap')[1:-1,1:-1]

    H[H<=2] = 0 #dies
    H[(H==4)&(G==0)] = 0 # dies
    H[H>4] = 0 #dies 
    H[H>0] = 1 #lives
    G = H

Why these rules ?

Because I was thinking about death/life:

Better to copy

from here

L’état suivant d’une cellule est :

(S = 3) OU (E = 1 ET S = 2).

Avec :

    S = signal.convolve2d( E, K, boundary='wrap')[1:-1,1:-1]
    T = np.zeros_like(E)
    T[ (S==3) | ( ( S == 2) & (E == 1) )] = 1
    E = T

I had to change the kernel too but you will see that in the notebook.

conclusion

I can code the game of life in 4 LOC because

can u do better ?

this guy suggests changing the kernel.

what about

Or abelian sandpiles ?