Conway's Game of Life
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:
- 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
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 = [Imperative]
b = bl;
for (c in (1..n))
a = goL(b);
b = a;
// Initial Configuration
x = 20;
y = 26;
allPnt = Point.ByCoordinates((0..x)<1>,(0..y)<2>);
flsPnt = List.Flatten([allPnt[y-3],allPnt[y-4],allPnt[y-(2..4)]],-1);
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)),
Dynamo Version 2.9