Cellular Automation

Conway's Game of Life

Conway's Game of Life, also known as the Game of Life or simply Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton.

The "game" is actually a zero-player game, meaning that its evolution is determined by its initial state, needing no input from human players. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.

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. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  1. Any live cell with fewer than two live neighbours dies (referred to as underpopulation or exposure[1]).

  2. Any live cell with more than three live neighbours dies (referred to as overpopulation or overcrowding).

  3. Any live cell with two or three live neighbours lives, unchanged, to the next generation.

  4. Any dead cell with exactly three live neighbours will come to life.

The initial pattern constitutes the 'seed' of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed — births and deaths happen simultaneously, and the discrete moment at which this happens is sometimes called a tick. (In other words, each generation is a pure function of the one before.) The rules continue to be applied repeatedly to create further generations.

Conway's Game of Life
// Conway's Game of Life
def goL(l1:bool[]..[])
{
mdRw = 0..List.FirstItem(List.Count(l1<1>))-1;
bln1 = List.GetItemAtIndex(List.ShiftIndices(l1,[1,0,-1])<1><2>,List.ShiftIndices(mdRw,[1,0,-1]));
bln2 = List.Flatten(List.Transpose(List.Transpose(List.Transpose(bln1<1><2>))<1>)<1><2>,-1);
tru1 = List.CountTrue(bln2<1><2>);
bln3 = List.GetItemAtIndex(bln2<1><2>,4) ? (tru1<3 || tru1>4 ? false : true) : (tru1==3 ? true :false);
return bln3;
};// Iterations
// Iterations
def GoL(bl:bool[]..[],n:int)
{
return = [Imperative]
{
b = bl;
for (c in (1..n))
{
a = goL(b);
b = a;
}
return b;
}
};
// Initial Configuration
x = 20;
y = 26;
allPnt = Point.ByCoordinates((0..x)<1>,(0..y)<2>);
//Glider
flsPnt = List.Flatten([allPnt[1][y-3],allPnt[2][y-4],allPnt[3][y-(2..4)]],-1);
//Booleans
blnLst = List.Contains(flsPnt,allPnt<1><2>);
pnt1 = List.FilterByBoolMask(allPnt,GoL(blnLst,n));
gol1 = [GeometryColor.ByGeometryColor(List.Clean(Cuboid.ByLengths(pnt1["in"],1,1,1),false),Color.ByARGB(255,255,153,51)),
GeometryColor.ByGeometryColor(List.Clean(Sphere.ByCenterPointRadius(pnt1["out"],0.5),false),Color.ByARGB(255,76,153,0))];