Game of Life with random lattice and first iterations

I would like to generate a random 100 x 100 Lattice, plot this and then, say, the first 3 iterations of Conway's Game of Life.

How can I do this with Mathematica?

I only came up with:

gameOfLife = {224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}};
board = RandomInteger[1, {100, 100}];
ArrayPlot[board]
ArrayPlot[Last[ CellularAutomaton[gameOfLife, board, {{0, 1}}]] ]


Does this show the first iteration?

• Why RandomInteger and not for instance ConstantArray? Speed-wise there's not much of a difference, and both generate packed arrays (contrary to Table which is 5 times faster), but I can imagine that 'random' may be confusing to the reader. Mar 25, 2021 at 13:13

This shows the 10 first iteration for a simple starting configuration: board:

board = ConstantArray[0, {100, 100}]; board[[50 ;; 52, 50 ;; 53]] = 1;
ArrayPlot /@ CellularAutomaton["GameOfLife", board, 10]


• I do njot understand what board = RandomInteger[0, {100, 100}]; board[[50 ;; 52, 50 ;; 53]] = 1; is doing.
– C.D.
Mar 25, 2021 at 13:27
• It simply sets up a board 100x100 with all zeros (aka dead cells) and some pixels in the center (aka life cells) to one. Mar 25, 2021 at 13:30
• Sorry I was simply too lazy and took your code and changed it in the simplest way possible. I corrected the answer. Mar 25, 2021 at 13:39
• Now, I get what you did, thanks. But why not starting with a random table consisting of zeros and ones? I want to start with a random setup.
– C.D.
Mar 25, 2021 at 13:42
• That's o.k., but I wanted to see the if the evolution works o.k. and that can be easier done with a simple pattern. Mar 25, 2021 at 17:07