Thursday 16 October 2014

Game of Life

Game of Life

While watching an episode of the Human Universe on BBC iplayer (http://www.bbc.co.uk/iplayer/episodes/p0276p50) the other day, Brian Cox was explaining how life and the universe is built around rules, from rivers to how Leopards get their spots, everything has simple rules. Life and indeed almost everything appears to be very complicated but he was demonstrating how a set of simple rules over time can produce very complex things.

This reminded me of one of the very first computer programs I wrote, or to be more accurate copied from a magazine, back in 1980 or 1981 which was called "Life" and devised by a British Mathematician called John Conway.

Put simply, Conway created a computer model which had a few very simple rules. Left to run for a while it would repeatedly apply these simple rules over and over again. Starting with a few random "cells" each cell would have 4 rules applied to it and over time what started with a random arrangement of cells could, and often did, arrange themselves into both simple and complex patterns. It was fascinating!

We hear a lot now about climate change, nature and our environment, and how scientists can run computer models to predict, or at least try to, the future of our actions. The game of life can be seen as a computer model running rules many times to see how the future may turn out.

The idea of applying rules over and over again is nothing new but with the Game of Life automation we can see how nature can produce complex patterns without the need for design. To me this is an important demonstration that most complex things can possibly or probably be reduced down to some basic rules. How plants grow and why they grow into the shapes they do can be seen as simply following a simple set of rules, does a cell have enough nutrients to reproduce etc. The shape it follows, a stem with a few off shoots and those off shoots split and split seems quite simple really. 

Recently I rewrote my version of "Life" and made a simple video that shows it. The cells are represented by the letter 'O' and to start Life going the program arranges a few random cells on the screen. The following rules are then applied:-

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.
5) Any cell over 40 generations old will die.

The 5th rule I added which is in addition to Conway's original set of rules. The colours are white (no cell or dead cell), black for a young cell, blue for a mature cell, and red for an old cell.

You'll need to view on full screen, and apologies for the video quality as I haven't managed to make them look that good :)






Apart from drawing a random number of cells to begin with the cells and patterns are simply generated from the basic rules mentioned above.



In the videos you can clearly see order coming from chaos and many patterns repeating. Often a symmetrical pattern of cells collides with another cell and chaos ensues. Some patterns can keep going for many generations while other groups of cells die out almost immediately. Some groups of cells walk across the screen as if they have developed legs. During the video I restart Life on many occasions and you can tell when this happens. The program also restarts automatically after 500 generations or when the cell count drops to only a few cells.

John Conway Videos





By starting the game with a different pattern, not random but one pre-chosen and by having a lot more cells  some amazing patterns can be seen. Some of them are absolutely stunning as in the following video...




No comments:

Post a Comment