Applets
ON THIS PAGE:
OTHER PAGES:
Applets are small pieces of JavaTM program written to work inside a browser page. All the examples on these pages use two applets that I wrote to illustrate Cellular Automata:
LifeApplet
An applet to illustrate the Game of Life
CAApplet
An applet to illustrate 1-Dimension 2-State CA
This is based loosely on a program I wrote about 20 years ago for the original IBM PC (that program was itself based on an earlier one on the IBM 370 mainframe, and I would like to acknowledge the colleague from that time who suggested the outline of the algorithm, except that I've forgotten his name — sorry).
The PC program used CGA graphics to write to the screen, and that's the way I've thought of Life ever since — green on black. So those are the colors I chose as defaults for the applet.
If you want to include the applet in your own pages, try the following HTML:
<applet code="net.pwall.ca.LifeApplet.class"
        codebase="http://pwall.net/applet"
        width="360" height="360">
    <param name="name" value="value">
</applet>
The parameters are:
Name Description Default
cellsize Number of pixels per cell 3
cycle Milliseconds per cycle 100
start Starting pattern r-pentamino
empty Color for empty cells (in #xxxxxx form) black
filled Color for filled cells (see above) green
text Color for text (see above) black
bg Color for background (see above) white
The applet will adapt to whatever width and height parameters are supplied on the applet element, and will take sensible defaults for all values. The alternatives for start are:
block
a 2x2 block to illustrate a stable configuration
blinker
a three-in-a-row blinker
grid
a grid of blocks filling the whole area, with one missing in the middle to make things interesting
This applet was written to illustrate my commentary on Stephen Wolfram's book A New Kind Of Science.
If you want to include this applet in your own pages, use the following HTML:
<applet code="net.pwall.ca.CAApplet.class"
        codebase="http://pwall.net/applet"
        width="361" height="361">
    <param name="name" value="value">
</applet>
The parameters are:
Name Description Default
ruleset The rule set in Wolfram's numbering scheme 110
cycle Milliseconds per cycle 20
max Maximum number of cycles varies
array Size of array 3201
empty Color for empty cells (in #xxxxxx form) white
filled Color for filled cells (see above) black
The applet will adapt to whatever width and height parameters are supplied on the applet element, and will take sensible defaults for all values. Odd widths (and array sizes) are preferred since that means symmetrical patterns will appear symmetrical on the page.
The starting position is always a single black cell, usually in the center of the array. For rule set 110, which always expands to the left but not to the right, the starting cell is positioned one place in from the extreme right-hand edge.
The default number of cycles will vary according to the width and the rule set, and will always be set to stop just before edge effects (see below) start to kick in.
You are welcome to use either of these applets, provided you prominently acknowledge the source of the applets, acknowledge my copyright in the applets and include a reference to this page. Please notify me (see email link at the top of this page) if the applets are used in any publicly-accessible pages.
A word here about edge effects. Both Life and the 1-Dimension Cellular Automata discussed here presuppose an infinite "universe" — in the case of Life, an infinite plane, and for a 1-D CA, an infinite line. The Java applets operate on finite arrays, which means that the results are not strictly correct.
In the case of Life, the applet operates as if the visible area is surrounded by dead cells, and that these can never give birth. The effect on a glider which hits the edge is to turn it into a block. (The original pattern in the main example on the previous page was positioned so that no other edge effects would distort the result).
For the 1-D CA, this approach wasn't very successful. The edge effects came into play much earlier than for Life, and made it difficult to get useful results. So for these, I chose to make the array many times larger than is visible on the screen, and by default, the applet stops cycling the CA before edge effects can take place.
Valid HTML 4.0! Valid CSS! Last modified:
6 August 2005
Links
The links in this column go to external sites and I am not responsible for their content. The presence of a link here does not constitute a recommendation or endorsement of the site.