Saturday, July 17, 2010

The Game of Life



BoingBoing twigged me to this neat mathematical game called, "Conway's Game of Life".



Sort of like the game "Mine Sweeper" every square on the grid can have a element in it; each element has rules governing it's behavoiur. For example, when one pushes the 'GO' button with only one square filled in black, the one element by it self will disappear, or die (as per the rules of the algorithm) - "as in life" says the info section. Two or three side by side will stay...

The instructions in the game itself explain it best:

Welcome to sixfoottallrabbit's implementation of John Conway's Game of Life, using the HTML 5 canvas element.

The Game of Life is a cellular automaton, which means that it consists of a grid of cells which can be in one of a finite number of states. Given any state, there are rules that govern what the next state of the grid will be.

Each cell in a grid can be either dead or alive. To find the next state of the grid, the following rules are observed:
  • Any living cell with 0 or 1 neighbours dies, as if by underpopulation
  • Any living cell with 4 or more neighbours dies, as if by overpopulation
  • Any living cell with 2 or 3 neighbours survives, yay
  • Any dead cell with 3 or more neighbours becomes alive, as if by reproduction

You can make some pretty cool patterns just by doodling all over the grid and hitting 'Go'. Or there are some examples all over the net of clever states. Try importing Gosper's Glider Gun:


I played with it for a couple of minutes and came up with a sustaining function on my third configuration. After one pushes the 'GO' button the pattern on the left becomes the function on the right. The four out-lying elements (three boxes in a line), are spinning forever, like wheels; while the pattern in the centre remains stable.



When I Push the 'GO' button the left configuration does about 200 machinations and then becomes the "Perpetual Wheely Gidget" (my term) :)



I found it interesting that circle like configurations tend to have long life cycles and spawn continuous, stable functions. Lines on the other hand - no matter if even numbered or odd - tend to flash out quickly leaving nothing; functioning or dead.

Follow the links to the "Glider Gun" article in Wikipedia ---> and then to "Turning Machine", for a full explanation.



mh

No comments:

Post a Comment