Jeff C. Mercer - Portfolio
jlife - Documentation
Background
When I decided to do my own Java project, I chose a favorite topic of mine,
cellular automa. More specifically, I decided to write a Java implementation
of "The Game of Live", originally conceived and described by John H. Conway,
mathematician.
In the April, 1970 issue of Scientific American (p. 120), Mr. Conway
wrote about a sort of mental game or exercise involving a checkerboard.
The game involves having pieces placed in just some squares on the checkerboard
(or any grid, for that matter). Any square with a piece in it is said to
be "alive" while the other squares (or cells) are "dead". Each square has
eight adjacent squares or "neighbors". In his article, Mr. Conway establishes
three simple rules for Life:
-
Any occupied (live) cell that has less than 2 or more than 3 "live" neighbors,
dies. Loneliness or over-crowding.
-
A living cell with exactly 2 or 3 neighbor survives.
-
Any empty cell that has exactly 3 neighbors is a "birth" cell and
becomes occupied.
By following these three rules and applying them simultaneously
over the playing field, it takes only several turns (or generations) before
interesting patterns begin to emerge. Of course, trying to play this game
in one's head is a bit difficult, and doing it with an actual checkerboard
and checker pieces takes some time. But when Mr. Conway's rules of Life
were applied in computer programs, the results were breathtaking. Over
the decades, many unusual patterns (a collection of living cells in a particular
arrangement) have been discovered which move, oscillate, and even seem
to attack other patterns.
Since John Conway originally described his game, it has been written
up in numerous articles (and even gets significant mention in Piers Anthony's
SF novel "0X") and turned into literally hundreds of computer programs
on all manner of platforms. My own Java implementation of Life is most
certainly not the only one, though it is all original code.
I wrote jlife using Sun's free Java
Development Kit v1.1.8 and the Windows 95 Notepad text editor. Initial
testing of the applet was done using the appletviewer tool included
with the JDK, then final tests were done with Netscape 4.6 for Windows
95 as well. Additional beta testers have run it under a variety of platforms
including Linux, FreeBSD, Solaris, and MacOS 8.5. While Netscape for MacOS
does not seem able to run the applet, one tester was able to get the jlife
applet to run quite nicely using the MacOS applet viewer.
How To Use jlife
Once you jump to the jlife applet, you will get
a display like this:
- Picture of jlife applet -
The black and white static is actually a randomly generated sequence
or "seed pattern". If the area was just blank then the simulation would
not produce any visual effect. Also notice the statistical data readouts:
-
Population - Shows the current population of living cells.
-
Generation - Displays the current generation's number. The initial
or seed generation is always zero, each new generation increments the value.
-
Average age - This displays the average age of the living cells
in the current generation. Each living cell that survives ages another
unit. Over time the average age will go up as more and more stable patterns
appear.
When the jlife applet starts, nothing will happen until you (the user)
presses one of the buttons at the top. The button functions are as follows:
-
Start - Starts the Life simulation running in an indefinite loop.
This produces a pleasing animated effect, and also continually updates
the statistical information.
-
Stop - If the simulation is currently running, this button will
stop it. Otherwise it has no effect.
-
Step - Pressing this button causes a single generation to pass and
then simulation stops. You can press it repeatedly for a "slow motion"
effect. This also has the effect of stopping any currently running simulation.
-
Reset - If things get boring or you just want to play around, pressing
this button resets the simulation. A new "seed generation" is created and
all statistical data is reset accordingly. This will not effect the current
simulation run status.
-
Flame! - Not part of the standard Conway life program, this button
acts as a toggle. It simply turns on or off the Flame effect which produces
a vivid, colorful streaking during simulation. Looks best when simulation
is running. You can toggle the flame effect on and off to your heart's
content, it doesn't change the Life simulation itself, just the display.
System Requirements
Because this is a Java applet and thus can potentially run on dozens of
different computer platforms, I will not attempt to give minimum system
requirements for all of them. In simple outline, you will need to have
a computer system capable of:
-
A high resolution display with at least 256 colors at one time (preferably
more),
-
Relatively fast processing power, comparable to an Intel Pentium 100 MHz
or faster.
In addition your web browser must support Sun's specification for
Java 1.1, or the applet will not run. Older web browsers such as Netscape
3.x and Internet Explorer 2.0 do not have Java 1.1 support and thus can't
run the jlife applet. Netscape 4.5 and higher should have support for Java
1.1, though some platform-specific or language-specific versions may lack
it.
Known Issues
-
Does not seem able to run in Netscape 4.x under MacOS. I think this is
because I use multiple classes in separate files rather than a single applet
class file.
-
Runs very slowly in Netscape 4.x under various unix platforms. I
suspect the unix version of the Netscape JVM lacks the optimizations that
the Windows 32-bit version has.
-
Hitting the Reset button in the applet while the simulation is running
may have only a partial affect. This may be due to the way I've utilized
threads.
-
If the population stabilizes the simulation will continue to run steadily,
rather than stopping or restarting. This was done deliberately.
-
Statistical read-out values may potentially overflow if the simulation
is allowed to run long enough.
Additional Links
Here are some links for further reading on Conway's Life and cellular automa
in general.
[Return to jlife main page]
[My Resume] [My
Portfolio] [News&Info]
[Contact Me]
Updated on 8/21/99 by Jeff Mercer <jcm@vaxer.net>