Gliders of Life: The natural occurrence of gliders in Conway’s Game of Life

I’ve always been fascinated by Conway’s Game of Life and other cellular automata. It’s amazing how a simple set of rules and primitives can give rise to enormous complexity and even emergent “life”!

For the uninitiated, Conway’s Game of Life consists of a grid of cells and a set of rules. A cell is either dead or alive and its state changes based on the state of its neighbouring cells. Quoting Wikipedia:

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies, as if by overcrowding.
4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Applying these rules repeatedly to a randomly populated grid can lead to an animated frenzy of patterns. The simplest patterns are just static “still lifes”, like a 2 by 2 block of live cells, that remain in the same state after the rules are applied. Other patterns oscillate between two states forever. Wikipedia goes into much more detail, so I encourage you to read the page for more information.

The glider pattern in its various states as it moves across the grid

The glider pattern in its various states as it moves across the grid

One of the most interesting patterns, however, is the “glider”. A simple 4 by 4 pattern that actually moves across the grid in a diagonal path. These gliders are actually quite common on a randomly populated grid but they can be hard to spot as they flit in and out of existence on a busy grid.

I’ve written a bit of JavaScript to help remedy that. The code uses brute force to scan the grid for the patterns that identify a glider. It then renders the gliders in a different color and keeps track of statistics that reveal just how prevalent gliders are. Press the start button below to see it in action.

View the source code in my “Gliders of Life” project on GitHub.

Being able to detect gliders on a grid allows for some interesting applications. For instance, you could count the number of gliders and use that count as a measure of “interesting” activity in a grid. You could also try to determine the optimal conditions for glider generation.

  • Sondre Andersen

    Nice! One big flaw with this is that the grid is supposed to be infinite, and random (finite) patterns therefore have a tendency to produce gliders moving on an escape trajectory, these would therefore accumulate and push the “gliders (total)” way up.
    But still, nice!

    • Brian Peiris

      Thanks! Although, the grid actually is wrapped around the edges, so if a glider moves “out” of screen, it just appears on the other side! You can see this more easily if you clear the grid with “clear” button and then construct a glider near an edge by clicking on the grid (the grid is editable). Click “start” and you should see the glider wrap to the other side of the grid.

      However! I don’t actually track gliders across frames at the moment, so a glider that appears in frame 0 counted again in frame 1. That causes the large total glider count.