The Game of Life
Get the Life implementation from the book by following the directions at right.
John Conway's Game of Life is probably the most widely implemented application in the universe. Here are some links to follow to get more information:
- There's a great introduction to Life on the math.com web site.
- Paul Calahan's Game-of-Life page has lots of links to Life-related information (and other life-related web sites). There's also a nice visual catalog of life patterns.
- Alan Hensel's applet implementation of Life, available at http://www.ibiblio.org/lifepatterns/, provides a fully-featured implementation of the game. (It's not the world's best Java, but it's a great implementation to use.) The buttons, below, fire off Hensel's applet.
- My favorite book about life is William Poundstone's The Recursive Universe. Unfortunately, it's out of print, but you can find copies on the usual used-book sites (Amazon, Alibris, Half.com, Book Finder, etc.)
I strongly recommend that you play with the game to get an understanding of how it works. To make things easy, the following buttons launch Hensel's applet, preloaded with a few of my favorite "seed" patterns. The main thing to keep in mind as you watch things work is that the behavior that you see is all "emergent." For example, the notion of a "glider" is not programmed into Life. All that is programmed is the behavior of an individual cell, which decides whether it will be alive or dead on the next clock tick based on the number of live neighbors on the current clock tick. These simple rules yield very complex and interesting behavior, however.
The notion of emergence is critical to OO thinking. You design (and build) around use-case scenarios, and you don't design for every possible scenario. Nonetheless, scenarios that you hadn't thought of are handled by the program. A good (layman's) introduction to emergence is Steve Johnson's Emergence: The Connected Lives of Ants, Brains, Cities, and Software (Scribner, 2002). As an interesting aside, Paul Rendell has constructed a Turing Machine in the Game of Life. Since a Turing machine can, in theory, model the behavior of any computer, you can infer from Rendell's work that Life can simulate the behavior of any computer program. That is, the behavior of all computer programs can be viewed as emergent behavior.
Clicking this button brings up the applet without any patterns preinstalled.
Click on a square to mark a cell as "alive." Click the "Go" to start the clock.
Click the "Open" button to select from a large list of patterns.
|Lightspeed looks like a firecracker exploding. It demonstrates how Life can simulate very natural, but chaotic, behavior.|
|This pattern shows you a few basic gliders, but it also demonstrates reflection (getting a glider to change direction, in this case by bouncing off another glider).|
|A "Gun" in life is a glider factory. A repeating pattern works in such a way that it generates a glider, which is ejected from the factory.|
|"Puf Train" is one of my favorite patterns. It starts out with a very simple seed, which moves off to the right creating a "smoke" trail behind it. There are more-complex trains, but this one nicely demonstrates a pattern that simulates a natural behavior.|
|The "Max" pattern was discovered only recently using computer analysis. It demonstrates growth. The original seed retains it's shape, but grows larger and larger. Eventually, it will occupy the entire "Universe."|
|A school of jellyfish swim across the screen.|
|Two large life forms move across the screen, creating and then activating glider-generating "guns."|
|A stable colony. Doesn't grow in size, but is very active within the boundaries of its world.|