Cellular Automata Laboratory

The JC Program

JC shows cellular automata in medium-resolution graphics (320×200 pixels). JC will work on any PC which has a graphics card. If your graphics card is a CGA or EGA, you'll see 4 colors, and if your card is VGA or a PS/2 card with VGA monitor, you can see as many as 256 colors. JC is an MS-DOS program; if you're running Windows, you can run it in an MS-DOS window, ideally in full screen mode (use Alt-Enter to flip back and forth between full screen and desktop window modes). Windows users may prefer to ignore JC entirely and proceed directly to CelLab for Windows, a Windows-based program which is 100% compatible with JC but runs under the Windows environment, using menus and dialogue boxes instead of JC's keystroke commands.

How It Works

If you haven't watched JCdemo yet, please do so before reading any further (see Demo of JC). Watching JCdemo is like watching a series of selected short subjects at the movies, but what you see are not movies. In computer graphics terminology, a "movie" is a sequence of pictures which have been saved one by one in the computer memory, and then displayed in rapid succession--like a slideshow. But when you watch JCdemo you see a festival of one-act computer "plays," where a "play" is something that is happening right now in realtime inside your machine. Live action that you can reach into and alter.

Even to call our little vignettes "plays" is a bit misleading. Traditionally, a play has a script which specifies everything that will happen. But when you invent a cellular automaton rule you do not know, in any very detailed sense, what is going to happen at all. The demos may be plays, but they do not have scripts. No, the way we specify a demo is simply by describing i) Cast, ii) Scenery, and iii) Lighting.

Cast: Rule Selection.

The cast of a JC play really has but one character. You might call him/her EveryCell. EveryCell's personality this time around is specified by a ruleprogram which is used to describe in a general way how EveryCell will behave. The ruleprogram is written in BASIC, Pascal, or C, and when this program is run (only once, normally) it creates a permanent ruletable with the extension .JC. The ruletable is a lookup table which specifies in exhaustive detail how EveryCell will react to every possible specific situation.

How many situations can EveryCell distinguish? EveryCell has 8 bits of personal state (memories, predilections, outside noise), and EveryCell can see one bit of each of his/her eight neighbors. So an EveryCell situation consists of 16 bits: 8 bits of personal state and 8 bits of neighborhood information. Each bit can be either 0 or 1, so this means that there are 216 = (26) × (210}) = 64K situations. (Never forget that 210 is around a thousand--1024 exactly, but close enough to a thousand to be called "K" for "kilo".)

So I can specify EveryCell's personality in wrackingly omniscient detail by listing a long table which gives the value of a variable we call "JCRule" as a function of EveryCell's personal eight-bit "OldState" and of the eight neighborhood bits--one bit from each neighbor--which EveryCell can see. Why can't EveryCell see all eight bits of each neighbor? Hey, dude, get real. How much do you know about your neighbors? ¹

So a .JC lookup table can be thought of as having 64K lines something like the following:

OldState NW N NE E SE S SW W JCRule

00000000 0 0 0 0 0 0 0 0 00000000
. . .
00000000 0 0 0 0 0 1 1 1 00000001
. . .
10000010 1 0 0 1 0 1 0 1 10000111
. . .
11111111 1 1 1 1 1 1 1 1 00001111

As the index lines are always the same, all that the .JC table really needs to store are the JCRule values; so a .JC ruletable file codes up 64K bytes. In practice, JC uses a compression scheme, so that most of the .JC tables are substantially smaller than 64K. A simple rule like Brain has a table that compresses down to 648 bytes; a rule like FredMem which keeps track of EveryCell's last seven states takes 33,792 bytes.

If you press the L key and then press Enter you will see a list of the available .JC ruletables in the current directory. If you want to find out how many bytes the various .JC ruletables occupy press Q twice to exit JC, and then enter "dir *.jc" at the DOS prompt.

Scenery: Pattern Selection.

Some of the rules are capable of self-organizing an interesting configuration from a random start. They build their own scenery. VoteDNA, Brain, and Hodge are rules like this. Other rules will only look interesting if their starting pattern is something simple, like a square or a line drawing. They need a prop to work with. FredMem, TimeTun and HeatWave are mildly demanding rules like this. Still other rules are primadonnas that need very special scenery to work right. The Perfume rules and the Den... rules are examples of this; in these rules, the starting scene has random particles to act like gas molecules, and fixed shapes to act like walls or objects. An invisible aspect of the starting Perfume pattern is that a checkerboard pattern is loaded into bits #4 and #5.

JC comes with a diverse selection of start patterns that you can load directly. You can also create your own customized start patterns by a) drawing them with the JC screen editor, b) letting them evolve, or c) importing them from AutoCAD or AutoSketch® . Pressing the E key from the main menu gets you into the screen editor; we'll say more about its functions below. Option (b), of simply saving an attractive screen as a start pattern, is used to show off the JC Rug rule in JCdemo. Once you have a pattern you want on screen, you save it by pressing Ctrl-F4. When you do this, a pattern file is created with extension .JCP (For JC Pattern). The technique of importing detailed drawings from AutoCAD or AutoSketch is discussed below.

The JC screen consists of 320×200 pixels, with one byte (eight bits) of state information per pixel, so a .JCP file codes up 64,000 bytes of information (about the same amount as a 64K .JC ruletable). JC uses data compression to reduce the size of the files where possible; FaderEgg.JCP needs only 23 bytes and Tim.JCP takes 23,457.

If you press the P key and then press Enter, you will see a list of the available .JCP files in your current directory. To find out how big the files are, leave JC by pressing Q twice, and then enter "dir *.jcp" at the DOS prompt.

Aside from the pattern part of the "scenery," JC also lets you set the topology. In particular, you can turn screenwrap on and off. In wrap mode, a pattern which moves off the screen's right will come back on the screen's left. The JC menus refer to wrap mode as "torus screen" because a torus is a doughnut shape, and if you were to actually paste the screen's left side to its right side and its top side to its bottom side you would get an inner-tube torus shape. The JC menus call the nowrap mode "open" or "plane" screen because when there is no wrap and the edges are set to zero, it is as if the screen is a patch in an endless surrounding plane of blank cells. There are also some one dimensional topologies, where the "torus" and "plane" become the "ring" and the "line."

Lighting: Colorpalette Selection.

Each pixel's color corresponds to the current state of the cell it stands for. Watching the patterns go by, you are comprehending the behavior of a system with 64,000 independent elements. Although cellular automata do not absolutely need to be presented as graphics displays, this method takes advantage of human vision's excellent pattern-recognition abilities. Choosing the right lighting, or colorpalette, can bring out different structures and details of a rule. The process is akin to staining a slide to be looked at through a microscope.

EveryCell can have any state value from 0 to 255, and you can select any color you like for each of the 256 states. On CGA and EGA machines, of course, there are only four colors to choose from, but on VGA machines you can select from some quarter million different colors for your colorpalette. ¹

JC has colorpalette files with extension .JCC (for JC Color). You can create a colorpalette by using Alt-F9 to change individual state colors, and then using Ctrl-F5 to save the colorpalette. More commonly, you use a word processor to look into and edit a .JCC file. Typically you copy an existing ASCII .JCC file onto your own New.JCC, edit New.JCC, and save New.JCC.

Colorpalette files are saved in a 7K readable ASCII format or in an incomprehensible compressed binary 700 byte format. To save space on the distribution disks, all our .JCC files are compressed binary. To reconstitute one of them, use Ctrl-F5 to save one in the default (uncompressed ASCII) format. Answer "Yes" when JC asks if you want to overwrite the old one. Then go in there with your word processor and work out.

The default colorpalette Default.JCC, which is used if nothing different is requested, looks like this:

3;R    G    B   CGA
  0    0    0    0    ;   0
  0   63    0    2    ;   1
  0    0   63    3    ;   2
 63    0    0    1    ;   3
 63   63    0    2    ;   4
  0   63   63    3    ;   5
 63    0   63    1    ;   6
 63   63   63    2    ;   7
  .    .    .    .        .
 63    0    4    2    ; 253
 63    0    3    2    ; 254
 63    0    1    2    ; 255

Each row of a .JCC file represents the color for one state. The first three columns show the intensity of Red, Green, and Blue to use in VGA mode, and the fourth column shows the color value to use in CGA and EGA modes. Anything to the right of a semicolon is a comment, which JC ignores. The initial "3" of Default.JCC means that this file has colorpalette information for both the VGA and CGA.

One of the key uses of colorpalette files is to make a particular rule's "bookkeeping" bits invisible. For instance, in a rule which uses some of the bits to keep track of which cycle it is in, you want to make sure that the alternation of the cycle bits is "invisible." If, for example, your bit #7 alternates between 0 and 1 to tell EveryCell which cycle it is in, then you want to have a colorpalette whose top half (states 128-255) is a copy of its bottom half (states 0-127), so that a cell's color is unaffected by whether or not its bit #7 is 0 or 1.

More creative uses of colorpalettes are also possible, particularly in connection with rules such as Faders or Rug, which cycle through many states.

It is possible to look at the spectrum of a given colorpalette by pressing the following keys in JC:



You start up JC by entering jc:

ca Enter

You interact with JC by pressing keys and by entering names of rules, patterns, and colorpalettes. Unlike RC, JC is not case-sensitive. We sometimes use capital letters for the names of the keys, but in practice you will use the corresponding lowercase keys. JC shows menu screens that summarize the commands.

JC comes up with its main menu screen showing. At the upper right of the screen is the rulebox, which shows the name of the current rule along with the number of generations that have been run since a rule or pattern file was last loaded or since the screen was last randomized.

When you first start JC, the rulebox will say:

Rule: Identity
Generation: 0
"Identity" is a do-nothing JC rule that always sets a cell's new state equal to its old state. A status line below the rulebox gives some further information. When you start up JC, the status line may read:

World: Torus      Screen: CGA      Texture: None

The World entry indicates whether the world on the JC screen is being treated as a 2D "torus" world with wrap, as a 2D "plane" world with no wrap, as a 1D "ring" world with wrap or as a 1D "line" world with no wrap.

The Screen entry tells whether JC is ready to run in four-color CGA mode or in the 256 color VGA mode. If your computer is not equipped with VGA or MCGA®, your only option is CGA.

The Texture entry tells if the current rule does anything special to any of the eight bitplanes. If not, the texture entry reads "None," otherwise the texture entry will have eight symbols, one for each of the planes 7 down through 0, where

means no texture
means horizontal texture
means vertical texture
means checkerboard (horizontal and vertical) texture
means plane is randomized each generation
means plane is randomized at first generation

Below the rulebox and the status line is the menu screen. The rulebox and the status line show with each menu. There are four menu screens in all: the Main menu, the Ctrl menu, the Alt menu, and the Edit menu. We print them at the end of this subsection, and we describe their individual keys in the four subsections to follow. Keep in mind that the rulebox and the status line will show unchanged on every menu screen.

JC is controlled by entering the single-keystroke commands listed on the menu screens. Lowercase and uppercase keys do the same things. Note that it is not always actually necessary to see a menu screen in order to enter a command. Experienced users frequently enter many commands in sequence, and it is distracting when the screen flips to a menu and you are required to manually flip back. For this reason, many of the single-key commands do not flip back to the menu screen, even when they request further input (such as a plane number). Major commands, such as those that load rules and patterns, do flip to the text screen automatically.

When you get stranded on the text screen, remember that F1 will always flip screens back to graphics for you. Conversely, if you get lost when entering commands blind, you can flip to the text screen at any time by pressing F1 to check the currently pending prompt. The four menu screens are as follows:

The Main Menu

Enter  Free run               Arrows   Scroll screen
Space  Stop/single step       End      Toggle 1 bit scroll
Q      Quit

L      Load rule              ?        Random rule
P      Load pattern           R        Random pattern
C      Load color palette     G        Graph population  +- Scale graph

B      Buffer save/restore    F1       Flip screen
I      Initialize planes      F2       Toggle silent running
O      Logical operations     F3       Toggle open/closed
E      Edit pattern           F4       Replay movie
Free run. JC applies the current rule over and over, displaying successive generations on the graphics screen.

If Enter is pressed on the menu screen (except at the end of an answer to a prompt for the name of a rule, pattern, or colorpalette), JC will flip to the graphics screen and enter a free run. So when you are answering dialogues about things like the buffer or logical operations, don't be too fast to press Enter if you don't want to flip back out of the menu. It takes JC a second to "eat" inputs about the buffers and operations, so just wait instead of pressing Enter, or you'll lose the menu before you're ready. Of course F1 will always get the menu back.

Single step or stop. If a rule is running, pressing spacebar stops the run. If JC is not running, each press of the spacebar updates the screen by one generation.

Arrow Keys
Scroll. The arrow keys scroll in the indicated direction. If an arrow key is pressed while on the text screen, the display flips to the graphics screen. These keys behave differently in toroidal and plane worlds. In toroidal mode, the screen wraps around as you scroll; in plane mode, the material scrolled off the edge of the screen disappears and zeroes scroll in from the other side of the screen.

Scroll speed. The arrow keys initially scroll the bitmap ten cells at a time. The End key toggles a mode in which the keys scroll only a single cell at a time. Press End to precision scroll the screen, then press it again to restore the original fast scrolling.

Buffer operations. JC provides eight buffers, each able to store the contents of one entire bit plane. You can store, recall, and exchange data between the simulator's bitplanes (representing the state of the cells in the automaton) and these buffers. Pressing B elicits the query:

Operation (S = Store, R = Recall, X = Exchange):

Select the desired operation. Store places the contents of the cell state bit planes into buffer bit planes, destroying the previous contents of the buffer. Recall copies the buffer bit planes into the cell bit planes, destroying the bit plane's previous contents. Exchange interchanges the contents of the buffer planes and the cell planes (handy to see what's in a buffer without losing any information). After you've selected the operation, you get the question

Plane number (0 to 7), All or Mask:

If you choose Mask, then you must specify a hexadecimal number between 00 and FF to say which planes you want to operate on. The idea behind a mask is that if you write it out as an eight digit binary number, the positions with 1s (instead of 0s) are the positions of the planes you want to operate on. If you aren't familiar with hexadecimal, it's helpful to know that a, b, c, d, e, and f stand for the numbers 10, 11, 12, 13, 14, and 15. Thus f0 would stand for the binary number 11110000, meaning planes #4-#7.

If you enter a plane number (0 to 7) rather than All or a Mask, you're asked:

Buffer Number (0 to 7):

In single plane buffer operation you can move data between any plane and buffer. For All and Mask, data always move between like-numbered planes and buffers.

Load colorpalette. The C command asks for the name of a colorpalette to be loaded. Type the name of the colorpalette file, then press Enter. If you decide you don't want a color palette after all, press "." and hit Enter. To list all colorpalette files in the current directory just press Enter. If you want a colorpalette that's in another directory, you must prefix the colorpalette name with the path name of the directory.

Edit pattern. This calls up the Pattern Editor menu, which is described in later in this section.

Graph population. In some simulations the number of cells in each state is more important than the pattern on the screen. The G command toggles the display back and forth between a display of the cells and a histogram showing the number of cells in each state, with the bars colored the same as the corresponding cells in the map. If the color palette ignores certain planes (for example, those containing texture and cycle counters), they will not figure in the histogram display. While the population histogram is displayed, pressing + increases the scale of the bars and - decreases the scale. If a bar is too high to fit on the screen, it is displayed with black horizontal dashes. For more detailed analysis of population statistics, create a population history log file, which records the number of cells in each state as the simulation runs.

Initialize planes. The I command provides several ways of initializing the eight bit planes. You're asked:

Plane (0 to 7, A=All, M=Mask,
       D to set random density):

Specifying a number 0 through 7 selects an individual plane to be initialized. Specifying A selects all planes, and selecting M allows you to choose a mask specified by giving the hexadecimal name of the eight-digit binary number which has 1s in the spots corresponding the planes you want to hit on. You are then presented with the choices:

Action (0=clear, 1=set, I=Invert, R=Randomize):

Enter the form of initialization you want, and the action will occur. Invert means convert all zero bits into ones and vice versa. Randomize fills the selected plane(s) with bits from the random number generator, using the most recently selected random density.

If you answer D to the original prompt, you get the response:

Random map density (1 to 7, was old):

Your reply chooses the density of one bits produced by the random number generator. This affects the bits generated for random initialization by the I command. The sparsest density, about 12% ones, is chosen by entering 1; the most dense, about 50% ones, by entering 7.

Load rule. When you press L, JC asks for the name of the rule you want to load. Simply type the name of the rule file, then press Enter. If you press Enter without typing anything, JC will list the names of the rules in the current directory. If you decide not to load a new rule after all, press "." and hit Enter.

You can list all rule files in some other directory by typing the name of the directory followed by a question mark. For example, to display the names of all rule files in the directory c:\cellab\newrules, you'd answer the prompt with c:\cellab\newrules?. Just typing a question mark or pressing Enter lists the rule files in the current directory. To load a rule from another directory, you must prefix the rule name with the directory path name. Thus to load a rule called cadelic from c:\cellab\newrules, you would request the rule c:\cellab\newrules\cadelic.

It is also possible to load certain special rules with standardized names in certain stereotyped ways, as follows.

You can load one-bit totalistic rules by specifying their rule number, as in the RC Vote rulestyle. Simply enter t(number), where number can range from 0 up to 1023. If you enter th(number), the totalistic rule with the same number will be entered and run in plane 0, and the rule's "echo" will be saved in plane 1. h thus has the effect of the e key in RC's Vote.

You can also load rules by specifying their "NLUKY" number, as in the RC Brain rulestyle. Simply enter n(NVal LVal UVal KVal YVal). Don't put spaces between the numbers. NVal can range from 0 to 127, and the other numbers can range from 0 to 9. In general LVal should be <= UVal and KVal <= YVal.

You can load random semitotalistic 4 bit rules as in the RC Random rulestyle by entering r(sparseness) where sparseness is between 0 and 100. Sparseness specifies the percent of entries in the rule's little 16×9 lookup table that ought to be zero on the average.

Finally, you can load own code evaluators by entering * followed by the .JCO file's name. Thus if you request *laplace, you will get the Laplace averaging rule included as an example of own code. To find out what .JCO evaluators are available, enter "*?".

Operate on planes. The O command performs various logical operations on pairs of bit planes. You're asked:

Destination plane (0 to 7), or S to swap 0 and 1:

If you respond with S, the contents of the low two bit planes are interchanged (whatever was in Plane 0 becomes the contents of Plane 1 and vice versa). This is handy for reversing a rule like TimeTun which has one active bit and one bit of memory. If you specify a plane number, you're asked for a source plane number between 0 and 7:

Source plane (0 to 7):

and then you are asked for an:

Operator (= Copy, & And, | Or, ^ Xor, S Swap):

Enter the operation OP you want performed, and the destination plane will be replaced by Dest OP Source. Thus, if I pick destination 2, source 4, and operation |, then each cell's Bit #2 is replaced by (Bit #2 OR Bit #4). This command, in conjunction with the eight buffers available through the B command, provides a "bitmap desk calculator" which allows you to compose patterns from various pieces.

Load pattern. The P command asks for the name of a pattern file to be loaded. Type the name of the pattern file (which can include drive and directory specifications), then press Enter. If you decide you don't want a new pattern after all, press "." and hit Enter. To list all pattern files in the current directory just press Enter when it asks which one. To list all pattern files in a directory, type the name of the directory followed by a question mark. For example, to display the names of all pattern files in the directory \brainsim\pats, you'd answer the prompt with \brainsim\pats?. You don't have to load a pattern before running a rule. If you do not load a pattern, a standard initial random pattern is used. This standard pattern consists of 50% ones in plane #0 and all zeroes in planes #1 through #7. Loading a pattern always sets all eight planes, but you can combine planes from different patterns by saving individual planes in buffers with the B command, then restoring them as you wish.

Quit to DOS. The Q command (or Esc), asks you to confirm that you really want to leave the simulator. If you confirm by typing Q, Y, or Esc, the simulator exits to the DOS command prompt.

Randomize Pattern. This is a single-keystroke command which randomizes all eight bitplanes. Each plane is set to 50% ones. See the I command for a larger set of options for initializing planes.

Write population history log entry. If you've used Ctrl-F7 to open a population history log file and entered 0 for the frequency to select manual dumps, the W key, pressed while the simulation is running, will dump the current population to the log file.

Increase population histogram scale. When you've used the G key to display a population histogram instead of the cell map, the + key increases the scale of the graph. Any bars which run off the top of the screen are drawn with black dashes across them.

Decrease population histogram scale. When you've used the G key to display a population histogram instead of the cell map, the - key decreases the scale of the graph.

Randomize Rule. This is a single-keystroke command which loads a new randomly selected four-bit semitotalistic rule into the current lookup table. These are exactly the same class of rules that you see in RC's Random rulestyle when you repeatedly press n. Most of the rules you get this way look bad, though a few of them are interesting. Generally a random rule will look better on a simple start pattern, like Square, tending then to generate radical mandalas. If you want to search through a lot of these random rules, it's a good idea to store something like the square in the first four planes of your buffers and keep pressing the three-key sequence B, R, A for Buffer-Restore-All.

Random rules usually look better if they have a pretty high "sparseness," meaning proportion of zero-valued entries. In RC, we set the sparseness by pressing the v key or by going to the control panel. But in JC, we set the sparseness by pressing L for load rule, and then requesting the rule r(n), where n is a desired percentage (from 0% to 100%) of zero entries. Once you set the sparseness by requesting an r(n) rule, each further press of ? will produce a new random rule of the same sparseness. JC starts up with the sparseness set to 68 (68% of table entries are forced to 0).

Flip screen. The display is flipped between the text and graphics screens. If the simulator is running with updates being shown on the graphics screen, F1 stops the simulator as well as flipping to the text screen.

Silent running. Normally each time a new generation is calculated, it is shown on the graphics screen, flipping from the text screen if required. F2 toggles "silent running." While silent running is in effect, if you single step the automaton with the space bar or let it free run by pressing Enter, the bit planes are updated, but the graphics screen is not. The text screen remains active, and only the incrementing generation counter in the upper right corner of the screen indicates progress. The screen type in the status line is shown as "Silent" to indicate silent running in effect. You may restore the normal display of updates by pressing F2 again. Updating the screen for each generation takes time, so if you want to run a large number of generations, you can use silent running to speed things up. The speed increase depends upon how fast your computer is and what kind of graphics hardware you have: the gain is rarely dramatic.

Toggle Open/Closed. This key toggles the world between open no-wrap planar and closed wraparound toroidal. The worldtype name on the text screen status line is updated.

Replay movie. F4 replays movie files made with Ctrl-F6. These movies store a record of all the screen updates in a given pattern run. They gobble up humongous amounts of disk space (you can hit several meg in a matter of minutes), but for special productions they have a strong high speed impact. When a movie is playing back, it accesses the hard disk for every screen. This makes a somewhat frightening noise inside your computer, but it is in fact not particularly bad for your hard disk. The sound you hear is the motion of the magnetic solenoid which moves the disk's read-head back and forth. These repeated reads do not turn the disk on and off, nor do they cause the head to touch the disk; all that is happening is that the read head is moving horizontally back and forth. Despite how it sounds, your disk is not being chewed up. Movies made in CGA mode can be projected in either CGA or VGA mode, but movies made in VGA mode cannot be projected on a CGA. Although VGA movies are not CGA-viewable, if you have a VGA, you will want to make VGA movies, as they show more color and run faster than CGA movies. Press Enter to see what, if any, movies are available in the current directory.

You can list all movie files in a different directory by typing the name of the directory followed by a question mark. For example, to display the names of all movie files in the directory c:\cellab\bonkers, you'd answer the prompt with c:\cellab\bonkers? To request a movie called, say, tintoy from the bonkers directory you would call for c:\cellab\bonkers\tintoy.

File Output: The Ctrl Menu

                             File Output                             

     F1  Flip screen
     F2  Save rule
     F3  Save experiment
     F4  Save pattern
     F5  Save colorpalette
     F6  Make / end movie
     F7  Generate population history log file

When you hold down the Ctrl key, the Ctrl menu appears. Ctrl plus any of the "function" keys F1-F6 creates various kinds of JC output.

Flip screen. Same as usual. You might use this combination if you know you need a Ctrl "output" key but don't remember which one; hold down Ctrl and press F1.

Save rule. This is useful if you happen to accidentally find an interesting rule by using the ? control or one of the rule-number entry possibilities for L.

Save experiment. This saves the current rule, pattern, and colorpalette. If you've been hacking like mad, chaining together rules and patterns and screen edits, and you suddenly see something great start happening onscreen, this is the command to use. If you can't remember a rarely used command like this, it's always safe to use F1 to get out to the menu screens and then press Ctrl and Alt until you see the command you want. The pattern and rule will wait for you on the graphics screen. A save experiment command has the effect of creating a rulefile with a built in PalReq and PatReq. If your current pattern happens to be intricate, the .JC file's size can approach 64K.

Save Pattern. This saves the current pattern. This is useful for instance if you have used the screen editor to create a useful starting pattern. Alternatively this can be useful with a rule such as Zhabo, which takes quite a few generations to start looking really good. You can run the rule till it settles into its groove, save the pattern, and then use this pattern as a PatReq of the rule. ¹

A lot of effort went into making our demo .JCPs as small as possible so we could include a lot of them with CelLab. One thing we learned is that if a rule has texture settings, you can make the size of your saved pattern smaller by turning off the textures before you do the save, letting the rule call up the textures on its own. If texture is on, even the compressed pattern will be about 64K. If your pattern requires some random bits at the start, you can reduce the size of your startup pattern file by writing your rule program so as to use the RSeedB and RSeedN commands to start certain planes with random bits in them. In order that DenTea, for instance, looks good, we need the rule to start up with random "gas bits" in plane 0. But to save a start pattern consisting of the teapot plus the random gas bits would make a .JCP file that is 40 or 50K. So instead, TEAPOT.JCP is just a teapot, and the Dendrite.PAS program that uses it includes the statements RSeedB:=0 and RSeedN:=1, meaning "at startup, randomize one bitplane, starting at bitplane #0."

Save Colorpalette. This saves the current colorpalette. This is useful if you have been using the Alt-F9 key to set specific colorpalette colors or disable certain planes. Ctrl-F5 is also good for getting a palette into uncompressed ASCII form. JC's default format for colorpalette save is ASCII. In this format, a colorpalette can be opened and edited with a word processor. An ASCII-saved colorpalette occupies about 7K of disk space. If you have no intention of reediting a colorpalette, you can save it in compressed binary form by prefixing the colorpalette name with a "*". A binary-saved color palette takes only about 700 bytes of memory. In the event that you ever do want to edit a binary-saved colorpalette, you can get it back into ASCII format by loading it in to JC and then using Ctrl-F5 to resave it in ASCII form.

Make/End Movie. If you'd like to see your rule run much faster than the generation time your computer delivers, you can record a "movie" consisting of consecutive frames calculated at normal speed, then replay the movie at high speed. Ctrl-F6 asks you to name a file into which the movie will be written. After you specify the file (which is given a file type of ".JCT"), record mode is activated. The movie file being written is shown in the status line on the text screen. Every time the graphics screen is updated, its contents are compressed and written to the movie file. Pressing Ctrl-F6 again concludes recording of the movie.

Note that you can change rules, patterns, and colorpalettes in the course of recording a movie, creating quite dramatic effects. While a movie is recording, the program runs more slowly because it has to keep pausing to write each screen to disk. Movies recorded while in CGA display mode are far more compact that those made while the VGA display is active, and can be replayed on both the CGA and the VGA. Movies made in VGA mode replay faster on the VGA, but cannot be shown on a CGA screen.

Generate population history log file. In some work with cellular automata, for example simulating predator-prey relationships in an ecosystem, the pattern of cells is not as important as the population histogram: how many cells are in a given state at successive moments in time. The G command on the main menu allows viewing a population histogram on the screen as the simulation runs, but for serious analysis it's better to write a historical log in a file you can process with separate analysis software.

Ctrl-F7 prompts you for the name of a population history log (.jch). After entering the file name, you're asked for the Population dump frequency: how many generations of the simulation should elapse between dumps of the population statistics. The default, 1, lets you track the population at every step, but slows down the simulation to a crawl and consumes large amounts of disk space. Larger values give periodic snapshots at the specified interval. Enter 0 to select a manual dump; the population will be dumped only when you press the W key while the simulation is running. To end logging and close the population log file, press Ctrl-F7 again. The format of population log files is given in the File Formats chapter.

Configurations: The Alt Menu Screen


             Screen                              World
     F1  Flip Screen               F8        Open/Closed
     F2  Select CGA/VGA            0         Two dimensional
     F3  Alternate CGA colors      1         1D, 8 neighbors
                                   2         1D, 4 neighbors
         Pseudo-Neighbors          3         1D, 2 neighbors
     F4  Off
     F5  Horizontal texture                 Color Palette
     F6  Vertical texture          F9   Set color palette entry
     F7  Random input              F10  Load color palette file

If you hold down the Alt key, the Alt menu appears. Alt plus a number 0 to 3 or a function key F1 to F10 changes JC's present configuration.

Flip screen. If you know you want an Alt key press Alt and F1 to get the Alt menu. Once you see the command you want, keep the Alt key pressed down and use F1 to go back to the graphics screen. Then, with Alt still down, press the function key you wanted. Thus, for example, you can find and use Alt-F3 to toggle the CGA color.

Select CGA/VGA. The simulator supports both the CGA display board and the VGA analogue display board. A PS/2 is the archetypal VGA, though now many clones are equipped with VGA as well. The EGA is supported as a CGA--using EGA mode for JC would have no benefits and be slower. When started, the simulator inquires what hardware is available and, if a VGA is found, assumes that VGA operation is desired. The current screen type is shown in the status line (unless silent running is underway). If you have a VGA and you'd like to switch to CGA before recording a movie file using Ctrl-F6 in the more compact CGA mode, or to fix up an experiment for a friend who has no VGA, or maybe just to gloat, pressing Alt-F2 flips the screen to CGA mode. You can do this even while running a simulation. Pressing the key a second time flips back to the VGA. If you have only a CGA, pressing Alt-F2 will cover the graphics screen with a blown-up copy of one of the menus; it's ugly and you won't want to do it often. We don't disable Alt-F2 if the system says there's no VGA because there is no completely reliable and documented way to determine what hardware is present. We use a sneaky trick to test for the VGA, which may not work on all computers. So, if you have a VGA but we don't think you do, you can still activate it by pressing Alt-F2.

Alternate CGA Colors. This key toggles between the two CGA colorpalettes, green-red-brown and cyan-magenta-white. The difference between them is that the colors in the second palette all have blue added. "Cyan and magenta" are printers' gobbledygook for "aqua and purple." JC defaults to the second palette because it is brighter. If you use the first palette, turn up the brightness on your monitor and it will look better. On some machines, Alt-F3 can also show a third CGA colorpalette: green-red-yellow, a brighter version of the first palette.

Alt-F4, Alt-F5, Alt-F6, Alt-F7
Plane assignments. The bitplanes can be assigned special functions which provide the rule external information. Normally any special assignment of planes will be made by the rule definition, but you can override the rule's specification with Alt-F4, Alt-F5, Alt-F6, and Alt-F7. The keys for setting textures are as follows:

Alt-F4 No texture
Alt-F5 Horizontal texture
Alt-F6 Vertical texture
Alt-F7 Random texture.

You can keep track of the texture setting by watching the status bar at the top of the menu. Alt-F4 simply turns off all textures and requires no further inputs. The keys Alt-F5, Alt-F6, and Alt-F7 give the prompt:

Starting plane (0 - 7) or N to disable:

If you press N, all texture of the chosen type is removed, and no further answers are necessary. If you press a plane number, then you get the prompt something like:

How many planes of horizontal phase (1 to 8):

If I select one plane of horizontal phase, that means that the plane is going to have alternating vertical stripes of 0s and 1s. But if I select, say, 3 planes of horizontal phase at plane 2, that means that for all the cells, bit #2, bit #3, bit #4 are going to hold a pattern that cycles through the combinations 000, 001, 010, 011, 100, 101, 110, 111 from left to right. One thing this is useful for is viewing your colorpalette. If I select Alt-F5, press 0, press 8, and then press F1 to flip to the graphics screen, I will see vertical stripes holding state values that, from left to right, go from 0 up through 255, back to 0, and back up through 64. Pressing the C key and selecting different colorpalettes will show you what they look like. In CGA this exercise is not particularly interesting because there are so few possible colors, but on a VGA it can show you a lot. It's fun to feed one of these "shower-curtain" patterns to a rule. RugLap with plane worldtype is good here, as is Hodge. Seed Hodge by using E followed by Ins and E to alter one pixel.

Vertical texture works the same as horizontal texture, except it makes horizontal lines. Both vertical and horizontal texture bits will be erased and swept away if the rule being run does something to the bits where these texture bits live. These bits are most commonly used to provide persistent domains where differing variants of a cell rule can apply. XTC and the Perfumes are examples of this.

Random texture is different; random texture means that the plane with that texture is randomized at each and every generation. This randomization takes precedence over anything a rule can do. Sublime is a rule which uses random texture.

Open/closed. This toggles between plane and torus worldtypes just like F3 on the main menu.

Set colorpalette entry. This allows you to set the color of a specific state number. In CGA, the colors are given simply by specifying an index from 0 to 3 (0 is black, 1 is green or aqua, 2 is red or purple, and 3 is brown or white). In VGA you can use a rather wide range of color names, ¹ or you can specify the intensity values wanted for the Red, Green and Blue components of the color being "mixed." For extensively doctoring a colorpalette, it is best to go out into DOS, copy an uncompressed ASCII colorpalette to a new colorpalette file with the .JCC extension, and then use a word processor to go into the colorpalette and change the numbers.

Load Colorpalette File. Does the same thing as C on the main menu.

Alt-0, Alt-1, Alt-2, Alt-3
Change WorldType. These allow you to choose between a 2D world or various sorts of 1D worlds. In a 1D rule, only the top line of the screen is updated, and the history of that line is scrolled down the screen. Aurora is an example of a rule like this. As JC's rule tables are designed to work with 8 bits of cell state plus 8 bits of neighborhood state, a 1D rule has the option of looking at 2 neighbors L and R and four bits of each (Alt-1), at 4 neighbors LL, L, R, and RR and two bits of each (Alt-2), or at 8 neighbors LLLL, LLL, LL, L, R, RR, RRR, and RRRR and one bit of each (Alt-3). It's interesting (but usually disappointing) to take a rule that runs in one worldtype and try running it in another simply by pressing Alt and a number from 0 to 3. Three combinations that work are Dendrite plus Alt-1, Life with Alt-2, and Faders with Alt-3. Alt-0 puts you back to 2D.

Pattern Editor Menu

                            Pattern Editor                             

     Arrows   Move Cursor        End     Toggle 1 bit move
     B        Box                X + CR  Make mark
     C        Close polygon      INS     Draw point
     D        Disc               DEL     Erase point
     E        End editing        R       Ring
     F        Filled polygon     S       Set color
                                 U       Undo last mark
     0-9      Set state 0-9      W       Wipe all marks
     G        Get state here     P       Paint region
     F1       Flip screen
                 Drawing State: dec (0xhex)

When you tap E to call up the pattern editor, the running of the cellular automaton rule stops and a cursor appears on screen. Don't hold the E key down, or JC will flip rapidly in and out of edit mode. You can select the state you are going to edit into the pattern by pressing S. Keep in mind that putting a 1 in plane #0 corresponds to State 1, while putting a 1 in plane #1 corresponds to State 2. Putting 1s in both plane #0 and plane #1 means using state 3, and so on. The state is the number whose binary expansion has ones exactly in the plane numbers you are writing in.

When you are done editing the pattern, you must tap E to exit the editmode before pressing Enter to restart the rule.

Arrow Keys and End
Move cursor. The arrow keys move the cursor around. The cursor will not move offscreen, which comes in handy when you want to get it out to the edge. To start with, the cursor jumps ten pixels per keypress. When you want to fine-tune the cursor position, press End and the cursor will start moving only one pixel at a time. Pressing End again toggles back to big steps.

Ins and Del
Draw point. Ins draws a point where the cursor is; Del deletes a point there.

Box. B draws a hollow box, or rectangle, with corners at two marks you have made. If you have made more than two marks, B won't do anything. If you have made only one mark, B will assume that you mean your second mark to be at the present cursor location.

Closed polygon. C draws a closed polygonal line through all the marks made so far, and connects the last mark to the first mark. If you have made only two marks, then C will draw a line connecting them.

Disc. D draws a filled ellipse which fits inside the box defined by two marks onscreen. If there are more than two marks, D uses only the first two to define the ellipse. If there is but one mark, D assumes the cursor position is the second Mark.

End Editing. Terminates editmode and enables you to save the pattern you've made or to run the rule on it.

Filled Polygon. Acts like C, but fills in the polygon. If only two marks have been made, a filled rectangle with the two marks as corners is drawn. If only one mark is present, F assumes you want a second mark at the present cursor location.

Get color. G sets the drawing state to the state value of the cell at the cursor's cross-hairs. This is useful if you don't know the state value of a color. (This can easily happen if you don't know the details of the rule and of the colorpalette being used.)

Open Polygon. O draws a polygonal line through all the marks made so far. If you have made only two marks, then O will draw a line connecting them.

Paint. Does a floodfill.

Ring. R acts just like Disc, except it draws a hollow ellipse that fits in the box made by two marks.

Set Color. S toggles you to the editor menu screen and asks the number of the state you want to color. You can set the state to a decimal value just by typing the number, to a hexadecimal value by preceding it with "0x," or to a binary value by preceding it with "0b." The specifications 163," "0xA3," and "0b10100011" are equivalent. Once S is set, the cross-shaped cursor is the color of S. For a state between 0 and 9, you can set that color state without leaving the graphics screen simply by pushing the appropriate number key. Another way of setting the state without going to the menu is to use the G key.

Undo last mark. Erases the last mark made.

Wipe all marks. Removes all marks.

Make mark. Pressing X makes a temporary mark where the cursor is. These temporary marks are used by the B, C, D, F, O, and R commands. The editor draws temporary lines connecting the successive marks. The editor is configured to remember as many as twenty marks at a time. If you should need a pattern with more than twenty marks you can draw it in several pieces.

Number keys 0-9
Cursor State. This is a way of changing the cursor color-state without leaving the graphics screen. If you need a state with value higher than 9 you have to use S and enter the number on the edit menu screen.

Command Line Arguments

JC is usually invoked just by typing its name. For special applications, arguments can be supplied on the command line that invokes the simulator. The general form of the simulator command line is:

JC [rulefile [patternfile [colorpalettefile]]] options

where options are chosen from the following table.

Argument Function
-BBatch (non-interactive) mode. Go directly to graphics screen and run.
-CUse CGA screen regardless of hardware available.
-DnDeterministic random seed n.
-GnStop after n generations.
-MUse monochrome characters on text screen.
-PcCGA only. Set background color to c, 0-15.
-Pr,g,bVGA only. Set background color to r,g,b: 0-255.
-RfileDump regression test to file.
-TnStop after n seconds.
-UPrint help message.
-VUse VGA screen regardless of hardware available.

You may name an initial rule, pattern, and colorpalette by specifying the rulefile, patternfile, and colorpalettefile arguments. You must specify a rule in order to specify a pattern file. In some cases, just a rule is enough, as in ca bob -b.

To run the rule TimeTun on pattern BillBord for 200 generations without user interaction, you'd specify:

ca  timetun billbord -g200  -b

You can also specify colorpalettes, as in:

ca faders faderegg autocad -b

Defining Rules

Pattern Design

The JC Rules

Next Previous Contents