svgalib Cellular Automata Program README
Introduction to SCAP
SCAP (svgalib Cellular Automata Program) is a flexible program which allows you to create and manipulate cellular automata applications. Right now it is pretty limited to what it can do, but in the future, I will be expanding it quite a bit. One feature I would like to see is a programming language for making rules. Maybe something like George Maydwell has with SARCASim. If you haven't seen SARCASim, go check it out at http://www.bayarea.net/~maydwell/htdoc/ca. The program only runs on MS Windows, but if you can get access to a machine, try it out. I'm not sure if it runs on WINE or not.
What's New?
See CHANGES
What's Included
ca.h - header file for the program
main.c - sets up everything and draws the board
cells.c - allows you to manipulate the board
complex.c - runs the system
parse.c - parses the configuration files
LICENSE - the GNU General Public License
README - this file
TODO - future enhancements
CHANGES - changes from past versions
nhoods/moore.rules - moore neighbourhood
nhoods/neumann.rules - von neumann neighbourhood
nhoods/emoore.rules - extended moore neighbourhood
nhoods/knight.rules - knight neighbourhood
nhoods/diamond.rules - diamond neighbourhood
nhoods/circle.rules - circle neighbourhood
nhoods/box.rules - box neighbourhood
nhoods/x.rules - x neighbourhood
nhoods/lr.rules - left and right cell neighbourhood
rules/life.cfg - rules for Conway's Game of Life
rules/one.cfg - some useless rules
rules/two.cfg - more useless rules
rules/pascal.cfg - with lr.rules, makes Pascal's triangle
Installing SCAP
To install it, simply type './compile'. All it does is run 'gcc *.c -lvga -O3 -o scap'. This program may run too fast on your system, too slow, or not at all. It runs just right on mine, so you can fix it yourself. By the way, my system is running slackware linux 7.1 with the 2.2.16 kernel. It has 32 megs of RAM and a 233 k6 processor.
Configuring SCAP
As default, the board is grey with green cells and is 50 by 50 cells. You may change this by editing 'ca.h'. Simply find the 'LINES' and 'CELLS' #defines and put whatever color that you wish to use. To change the size look for 'X_SIZE', 'Y_SIZE', 'CELL_SIZE', 'LINE_WIDTH'. Obviously, you will have to recompile for the changes to take place. You don't really need to change anything unless you really want to, my settings are pretty good.
Using SCAP
First of all, you MUST be root to run scap. Otherwise, you can't get the video permissions. For an almost useless help menu, type 'scap -h'. I'll try to offer more information here. Here are what the switches do:
-h - Displays the help screen
-o - This specifies a file to log all of the cell information to for each
generation. This can be played back using the '-i' switch later. Large
generations can produce quite large files.
ex: scap -o moore.run
-i - This specifies a file to read from and playback. I'll detail
playback in more detail later.
ex: scap -i moore.run
-s - This shows one generation at a time and waits for a keypress to
continue. This is useful if you want to see every little detail. The
same effect can be achieved by outputting to a file and playing it back.
-n - This is a required option. It specifies the neighbourhood to be used
when running the system.
ex: scap -n moore.rules
-r - This is another required option. It specifies the rules to be used
on the neighbourhood.
ex: scap -r moore.rules -n life.cfg
-m - This changes the screen mode of the program. Default is 6, or
320x240x256. Other modes include 4, which is 640x480x256, and 5,
which is 320x200x256. On my computer, mode 4 runs a bit slow.
-d - This specifies the dimension of the lattice. It may be 2 or
- Default is 2.
When you run the program normally (not playback mode) you should see a grey mesh. This is your game board. At first, it can do nothing. So press 'j' and you'll see a white box outlining the top left cell. By pressing 'j' again, you'll highlight the cell. A highlighted cell means it is alive. Press 'k' to kill it. A cell is dead if it is black. To fill in random cells, press 'r'. To clear the board, press 'c'. To leave the edit mode, press 'q'. Summary:
j - takes you to edit mode and fills in cells
k - kills cells
r - fills in random cells
c - clears the board
q - leaves edit mode
To run the system, press 'r' at the main screen (looks like every other screen). Hopefully, your system will do some cool things. To stop it, press 'q'. You can then edit your paused system by going to the edit mode. To start it back up, press 'r' again at the main screen.
Now let's talk about playback. Remember, you must have output a file using '-o'. To read it in for playback, use the '-i' switch. When you do that, you will see the initial state of the system. To quit the playback, press 'q'. To advance a frame, press 'd'. To go back a frame, press 'a'. To restart the playback, press 's'.
Rules and Neighbourhoods
These are the heart of the program. Without them, it won't run. However, without them, you can use it as a crappy drawing program! If you try to run it without rules or a neighbourhood, it segment faults. The neighbourhood files I provide all have a '.rules' extension. It would be nice to stick with that. The format of a .rules file is the following:
number_of_cells
x[1] y[1]
x[2] y[2]
...
x[number_of_cells] y[number_of_cells]
The x and y values are coordinates that specify a cell's neighbours. We think of the cell as having x = 0, y = 0. That way, x = -1, y = -1 would be to the topleft of the cell. Here is an example of a moore neighbourhood file:
8
-1 -1
-1 0
-1 1
1 -1
1 0
1 1
0 -1
0 1
The diagram would look like this (note, the diagram is not included in the .rules file, it is only shown here for clarity):
[-1,-1] [0,-1] [1,-1]
[-1, 0] [0, 0] [0, 0]
[-1, 1] [0, 1] [1, 1]
It looks sloppy but it gets the job done. I will probably make a nifty little program to generate these files, but for now you have to do it by hand.
The rule files all end in '.cfg'. These specify the how many cells are needed for a cell to live. The format of a rule file is:
number_of_states
state[1] number_of_cells[1]
...
state[number_of_states] number_of_cells[number_of_states]
The 'state' field is either 1 or 0 for alive or dead. The 'number_of_cells' field is how many cells must be counted for the cell to be alive when it is in that state.
Here is an example for Life:
3
1 2
1 3
0 3
So, if the state of a cell is 1 and there are 2 or 3 living neighbours, the cell lives. If the state of the cell is 0 and it has 3 living neighbours, it lives. Otherwise, it is dead.
Closing
Well, I think that takes care of the program. This program is distributed using the GNU General Public License. Read LICENSE for more information. If there are any questions or concerns about my program, e-mail me at nanlokd@yahoo.com. To all of you coders out there, please make my program better. And if you do modify my program, I'd appreciate it if you would send me a copy. Of course, if you find any bugs, send them my way. If you want to be a member of this project, e-mail me.
If you want more information about cellular automata, head over to yahoo! and do a search. Be sure to check out Stephen Wolfram's page.
coded by widge - august 30th 2000 - nanlokd@yahoo.com
webpage: http://www.sourceforge.net/projects/scap - visit sourceforge.net today!
