~/morgan_herlocker

abouttwittergithubother posts

Playing with the Game of Life

Let me start this post by saying that if you have been around the block, you will probably find this pretty mundane. That said, I want to go over a classic game/hack/algorithm that every generation rediscovers.

In 1970, mathematician John Horton Conway devised a simulation called the the Game of Life. It is a deceptively simple cellular automaton, that allows complex designs to arise from simple seed patterns.

game of life gif

The beauty of this algorithm is in its simplicity. There are only a few rules:

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

From this, "creatures" will often emerge; the most well known being the glider. With these seed points...

  0
  0
  0  0  0

...we end up with a pattern that will move across the grid until it runs into another set of live cells.

game of life gif

Conway's Game of Life has been a mainstay of weekend hacks for ~45 years, and shows no signs of slowing down. There are countless variations, and new patterns are continuously being explored. One of the most impressive variations is SmoothLife, an implementation that modifies the rules to allow for continuous values, instead of the classic discrete rules.

Here is the source for my rough implementation that generated the first two gifs above. If you have never implemented it yourself, I highly recommend taking an hour or two sometime to write your own version from scratch.

WARNING: you will likely become obsessed with this game, and in extreme cases, may even find the urge to build an implementation of GOL within a mechanical computing machine running inside of the game Dwarf Fortress, a game that is itself, a sort of souped up version of GOL. You have been warned. \PSA


6/17/2014