Monday, April 16, 2007

Life hacks

Every programmer has implemented Conway's Game of Life at some point or another. In addition to the Javascript implementations [images, checkboxes] I did back in 1999, I also wrote a xscreensaver hack implementing a colorized life simulation back in 2003. Unfortunately, Jamie Zawinski rejected it for inclusion in the xscreensaver distribution with the response,
Well, my only problem is that I find almost all "life"-based savers pretty dull to look at :)

A number of my coworkers have humored me over the years and at least pretended to like my hack, so I've dusted off the files, updated them to xscreensaver 5.0, and put the files online. With the default settings, it looks like this:

Cells are born with a color based on the color of the three neighbor cells. Dead cells are drawn with a darker variant of the last living cell that occupied the space (causing "moving" clusters to leave trails). The trails can be disabled for a more pure Life experience. The hack also supports loading patterns from files in the Life 1.05 format, although the glider, bhept, and rabbits patterns are built-in if you don't have patterns of your own. To keep things interesting, if the simultation starts converging on a steady-state, a pattern of cells will be randomly added to the field.

Until I (or someone else) can convince Jamie Zawinski that Life isn't boring, the only way to install it for yourself is to:
  1. Download and extract the xscreensaver 5.01 source distribution.
  2. Copy clife.c and clife.man into the hacks subdirectory.
  3. Copy config/clife.xml into the hacks/config subdirectory.
  4. Patch Makefile.in using Makefile.in.diff.
  5. Finally, configure and build xscreensaver.

No comments: