Conway's Game of Life
Simple mathematical rules to implement a cellular automaton.
Overview
This is a "game" devised by John Conway to simulate cellular life. He wanted to create a machine that could have a life of its own, continuously evolving and creating copies of itself using some very basic algorithms. It sounds a bit like Skynet, but it's more of a primordial Sims.
If you find fractals interesting then this sort of stuff will be right up your alley. The beauty lies in the richly complex behaviour that can arise from a deceptively simple set of mathematical rules.
The Rules
The game is played out on a rectangular grid of cells that can be alive or dead. Each turn of the game involves figuring out what happens to each cell. Does it remain in its current state? Does a dead cell spring to life? Does a living cell die? We determine this by looking at the cells' eight neighbours.
The classic implementation of Conway's Game of Life involves seeding the world with some living cells. This is the only aspect of the entire game that can be random. We then apply a small set of rules to determine what happens to a cell.
- Is the cell alive?
- If it has fewer than two living neighbours, it dies (it got too lonely or lacked breeding opportunities).
- If it has more than three living neighbours, it dies (overpopulation and a lack of resources to go around).
- Otherwise it just carries on living.
- Is the cell dead?
- If it has exactly three living neighbours, it comes to life (the surrounding population has spilled over to this cell).
- Otherwise it remains dead.
Observations
If we play this out one turn at a time, we see a mass of cells twinkling on and off. It appears chaotic in some places, where we witness a sea of population explosion and extinction. Yet in other places things seem to remain orderly, at least until a nearby group of cells strays too close and the order is disrupted.
It's the little pockets of order that are the most interesting. Using the set of rules above, we will quite often see a common set of patterns that spring from chaos but evolve in an entirely predictable way - at least until they collide with another group of cells.
Common Patterns
One of the most common of these patterns is called a Still Life. Once the cells are arranged in a certain way, the rules will always result in the same state for the next turn. They are like a little cluster of frozen cells, not dead but not evolving in any way.
A more interesting pattern is known as the Oscillator. A group of cells will cycle between two (or sometimes 3 or more) different arrangements. Without interruption they will keep doing this forever.
A variation of Oscillators that will actually move across the grid is referred to as a Spaceship, with the most common variant known as the Glider. What these guys are really doing is creating a copy of themselves in their neighbouring cells.
If you watch closely enough, you will observe other varieties such as Guns, Puffers and Rakes which will actually emit other shapes. Some of these are quite rare and not often seen in the wild.
Variations
The classic rules used for Life were devised because they result in population growth that is not too explosive but isn't prone to extinction. That doesn't mean we have to stick to them, in fact the numbers can be tweaked for some interesting behaviour. Oddly enough, predicting what sort of behaviour will arise given a different variation of the rules isn't as easy as it would seem. You really need to play it out to see what will happen. Luckily this can be done with a few mouse clicks...
Software
John Conway and others before him were able to watch Life play out by using nothing more than a pencil and paper. This isn't 1970 anymore so you can find Life implemented in software all over the web, including here which is my own implementation in Java. Some features of note:
- Seeding the grid is done in two ways - either randomly with control over the initial density, or clicking on a cell to set its state. This can be done at any time, even when the game is running.
- The grid isn't infinite, however each side will wrap around to the opposite side.
- The algorithm to use can be changed from the classic Conway Life rules to more exotic variants.
- The action can be paused and single stepped through if you want to carefully observe behaviours unfold.
- When cells die they don't disappear immediately, but rather fade away to present a ghosting effect.
I recommend just pressing the "Start" button to get things running, using the pre-seeded grid. You can then just sit back and watch your little cells come to life. Eventually the grid will reach a state of equilibrium, where nothing exists except a few Still Life patterns. Feel free to click and drag on the grid to inject some new life or set up some complex patterns of your own to experiment with.