CLCA: Color Linear Cellular Automata by John H. DuBois III Usage: clca [-a] [-b] [-g] [-i] [-m] [-p] [-r] [-s] [-w] This program calculates and displays succeeding generations of linear cellular automata. LCA are related to the Game of Life, but are one- rather than two-dimensional. Also, while in the Game of Life each cell is in one of two states (alive or dead), LCA may have many states. In this implementation, the number of states is set to four since that is the number of colors that can be simultaneously displayed on a CGA monitor in medium- resolution mode. To use this program you must have a CGA display. The state of each cell is refered to here as its value. Each cell has a value between zero and three. To find the value of the cell in the next generation, its current value and the current values of the cells on either side are added together. The result is used to select a "rule". There is one rule for each possible result. Thus, since each cell has four possible values (0-3), the sum of the three cells will be between 0 and 9, and there are ten rules. Each rule is a value which will be the new value of the cell. For example, if the values of a cell, its left neighbor, and it right neighbor are 2, 0, and 3, and the value of rule 5 is 1, then the value of the cell in the next generation will be 1. The cells are arranged in a circular configuration; that is, the leftmost and rightmost cells are taken to be neighbors. To display the cells, a color is associated with each value, and a generation of cells is displayed as a row of pixels. Succeeding generations of cells are printed on succeeding rows. The two- dimentional, ongoing pattern produced by succeeding generations of cells can be extremely interesting. The following arguments are used to determine the nature of the LCA and the way they are displayed. In all cases the initial '-' is optional. -p : p is followed by 0 or 1, to select the corresponding palette. The colors associated with each cell value for the two palettes are these: Palette 0: 0 = background color; 1 = Green; 2 = Red; 3 = Brown. Palette 1: 0 = background color; 1 = Cyan; 2 = Magenta; 3 = White. The default palette is 1. -b : b is followed by a number from 0 to 15, to select the background color. The background colors are these: 0 = black; 1 = blue; 2 = green; 3 = cyan; 4 = red; 5 = magenta; 6 = brown; 7 = light grey; 8 = dark grey; 9 = light blue; 10 = light green; 11 = light cyan; 12 = light red; 13 = light magenta; 14 = yellow; 15 = white. The default background is 8 (dark grey). -r : r is followed by a series of integers between 0 and 3, optionally separated by commas. The leftmost number should be the value of rule 0; the next, the value of rule 1, etc. 10 rules should be given. If less than 10 rules are given, the unspecified rules will be given a value of 0. If -r is not given, the rules are initialized to random values. -w : width should be an integer between 1 and 320, specifying the number of cells. The default is 320, which is the number of pixels across the screen. -i : The initial values of the cells can be given as a string of integers, in the same manner that the rules are. If fewer values are given than there are cells, the unspecified cells will be given a value of 0. If this argument is not given, the cells are initialized randomly. -g : The number of generations to produce (and thus rows to print). If this argument is not given, the program will continue until halted. -m : should be an integer. The rules will be replaced with a new random set each time that the specified period (number of generations) has elapsed. The default is 200, so that one screenful of generations will be printed between mutations. If 0 is specified, no mutations will occur. Each time a mutation occurs, the cells are checked to determine whether they are all identical. If they are, the value of the middle cell is changed, in order to begin an interesting sequence again. -s : If this argument is given, scrolling will be turned on. After the screen has initially been filled with generations of cells, each new generation will be printed at the bottom and the screen will be scrolled up accordingly. If this argument is not given, printing of new cells will start at the top again. Scroll mode is much slower than noscroll mode. -a : -a can be used to specify a file containing lines of arguments of the same form as the command line arguments. Each line specifies an 'environment'. Each environment is used for the number of generations specified, then the next environment is used. When the last environment has been used, the first is used again, etc. Note that if any environment does not include a -g argument, it will be used indefinately and thus no further other environments will be used. As with the command line parameters, any arguments that are not given are set to their defaults. An example of an argument file is this: r1020221011 g200 r0120120012 g200 r0102002222 g200 r2312000311 g200 r0203012123 g200 r1310121232 p0 g200 r1320001101 p0 g200 r1033021030 p0 g200 Control keys: Certain keys can be pressed while the program is running to effect changes in the display. In noscroll mode, keypresses are checked for after every mutation and after each screenful of generations. In scroll mode, keypresses are checked for after every other generation. Pressing the 'f' key will freeze the current rules (disable mutation). 'e' will echo the current rules to the screen. 's' will toggle between scroll and noscroll mode. 'm' will cause an immediate mutation. Pressing any other key will quit the program. The inspiration for this program came from an article that appeared in _BYTE_ magazine around 1986. Send bug reports, comments and suggestions to John DuBois, john@armory.com