(Kevin's) Conway's Game of Life

The Game of Life is a zero player game invented by John Conway in 1970. The rules are simple: start with a grid. Each square in the grid represents a cell, and a cell can be either alive or dead. There are only three rules that each cell must obey:

  • A cell becomes alive if it has exactly three neighbors.
  • Once alive, a cell remains alive as long as it has two or three neighbors.
  • A cell dies if it has less than two (loneliness) or more than three (overcrowding) neighbors.

Sprinkle some living cells on the grid and apply the rules, and you’ll get a new pattern. Apply the rules to that pattern, and the next, and so on, and in a few “generations” you could end up with a pattern completely unlike what you started with.

That sounds pretty simple, and maybe a little pointless, but the resulting patterns of cells can be unexpected, organized, and even beautiful. One of the most recognizable patterns is known as a glider because it looks like the pattern is flying across the grid, when in reality what you see is simply a result of applying the three rules over and over again.

a glider

The Game of Life mimics complex, real-life processes as the rules mirror real world principles of reproduction, starvation / loneliness, and overcrowding. The game also demonstrates one of my favorite ideas: emergence. Emergence is the concept of something complex resulting from seemingly simple interactions. Take an ant colony for example. A single ant is a pretty simple automaton, but if you get enough ants together, you’ll start seeing extremely complicated behaviors, systems, and social structures.

This idea can be seen in everything from ant hills all the way to the human brain. A single neuron isn’t very complex, but if you get enough of them together, you’ll start seeing- well, us. The way we are. The things we do. How we feel. Are we any more complicated than a collection of a bunch of simple structures obeying basic rules? Get a couple beers in me and this is one of my favorite things to talk about!

Anyway, the program includes a few starter patterns for you to check out, but the real fun comes from clicking around and creating your own.

If you feel like playing around with the source, it could be interesting to see what happens when you modify the rules- what if a cell came to life when it had a single neighbor as well? What if only cells with an even number of neighbors came to life? What kinds of patterns would you see? The possibilities are endless.

If I had more time to work on this, I would add support for grid-wrapping (if a glider goes off one side, it could appear on the other), more scalable grids (if a glider goes off one side, you could scroll over and follow it), or some kind of zoom feature. I could also add more patterns, which would be really easy with how I set them up.

There are also a few competitive versions of the Game of Life that could be implemented using this code as a starter. Maybe another program...

If this stuff sounds interesting to you, I'd recommend checking out the wikipedia pages on Conway's Game of Life, emergence and determinism. Or just ask me about it after a couple beers.