Game of Life

Cellular Automata
Python
Published

June 18, 2026

Starting From the Start

I first learned about cellular automata as most people do, with John Conway’s Game of Life. Since I am new to python I figured this would be as good a place as any to get started. It will let me get familiar with python syntax, array manipulation, and plotting/animation. It will also give me a chance to get better at adding code, figures, and videos to the blog.

John Conway’s Game of Life is a simple simulation (single player “game”) that takes place on a 2D grid world with discrete time. At any given time, each grid cell can either be alive or dead. Each cell follows rules that dictate whether they are alive or dead at the next time step. The rules are as follows

Image From: https://playgameoflife.com

The way the “game” works is you pick some initial set of living cells and then hit run. Thats it. What is amazing is that from just these basic rules, we get a wide range of interesting “life like” behavior from the cells. I didn’t really appreciate how cool this was when I first learned about it, but today I am very excited to see if I can recreate it. Lets begin!

Code Overview

When I start a project I am used to thinking in MATLAB. So for these first few projects I will try to outline my plans in pseudocode first so that I can get used to thinking more abstractly. Hopefully this makes it easier when I go to implement it in python too. Also, if you notice that I like putting things into functions with big blocky comments, you would be correct.

# ----- Define World Parameters -----
world_size = NxM
world_wrap = true
time_steps = 1000
etc...

# ----- User Defined Initial World State -----
world_state = NxM matrix of 0s and 1s

$ ----- Simulate Game -----
FOR EACH time IN timesteps

    FOR EACH cell_index in world_state

        updated_world_state(cell_index) = update_cell(world_state,cell_index)

    END

    world_state = updated_world_state

END

Note that we save the updated world state in a separate matrix so that all the cells can update “at once”. In other words, we don’t want the updates of one cell to be recorded until we compute the updates from all the cells.

I will post a link to a repository with my final python code soon. I am working on setting up a new Github account specifically for this blog so I don’t dox my self.

Initial Results

To test out the code, lets try running some of the famous Game of Life patterns.

Glider

Light Weight Space Ship (LWSS)

Bun

Gray Counter

Very cool! Looks like it is working. Here are some more examples of some more complex initial patterns. The first one is actually the result of an error when I was entering the initial state for the gray counter example above.

Broken Gray Counter

LWSS-LWSS Bounce

And just because I had to try, here are two examples of what happens when you initialize with a random state.

Random Initialization 1

Random Initialization 2