Here's my writeup about this program for George Francis's Spring 1992 Math 198 class.
Thomas Insel
My goal in writing cs3d was to implement a flexible shell for the display of various types of three-dimensional cellular-automata. That is, to display a three-dimensional matrix of cells in such a way that the user can see both the gross patterns of cells and the overall layout. I implemented this program on an Iris workstation, using its standard 3d graphics libraries. The executable can be found in REL as ~tinsel/life/w6.x, and the source is at ~tinsel/life/w6.c. Portions of cs3d include code written by or adapted from Professor George Francis, Steve Kommrush, Pablo Mena, and Jon Obermark. They should be identified in the source code (attached).
Quite possibly the hardest problem in writing a program like this is the display. The Iris graphics library handles the actual three-dimensional drawing, but it is not enough to simply draw a grid of cubes and let the computer display them--many would be obscured, and inner parts of the grid might be completely invisible. Thus, it was neccessary to use various strategies to simplify the display. I originally had many ideas, several of which proved impractical:
I decided that the best approach to displaying a matrix of many cell types was to allow the user complete flexibility. To this end, the user of cs3d can change how each cell type is displayed in real time. Each type has a fixed color, but the keyboard controls whether it is drawn as a solid, as a wireframe, or invisible, and its size. With only a little adjustment, one can make sense out of even a random assortment of cells. One of the best layouts is to make one type of cell solid and full size, another solid and small, and the rest wireframe and about 3/4 of full, but the user can actively change the display as his focus of attention shifts.
For demonstration purposes, there are currently three different ``games'' implemented. The first is Conway's Life 4555, with glider and rotors available on the menu to show that it actually works. The second is Life 5766, with only a random option. The last is a color-cycler which cycles a random grid through various colors, to demonstrate the various display capabilities of cs3d.
There are many things missing from cs3d. It would be nice if there was a way to interactively layout the cells, but currently the only way to change the layout is to add a menu item which sets the world to a hardcoded configuration. Unfortunately, I see no easily understandable (by the user) way to allow input like this. Perhaps the program could ask the user to pick first a plane, then a row, then finally an individual cell (ie, x,y,z coordinates in order). If this is implemented, there should probably be a command to save the configuration to a file, and then to reload it.
I do not yet have a particularily interesting automaton which takes advantage all of cs3d's display capabilities. Also, although it doesn't always show, there are still bugs in the t-mesh for my solid cube.
cs3d is a shell for displaying three-dimensional cellular automata on Iris workstations, using the Iris graphics library (DGL when writing to a different display than the host computer). The cells appear in a three-dimensional grid (a large cube) which rotates as the user moves the mouse. The specific behavior depends upon the automaton (``game'') in the source code, but these keyboard commands should be fairly constant:
| 1,2,3,4,5 | toggle between wireframe and solid drawing for cell types one through five. (Shifted: hide respective cell types.) |
| x,y,z | translate along an axis (relative to internal coordinates). |
| f1,f2,f3,f4,f5 | grow respective cell type. (Shifted: shrink it). |
| b | hide world-border box. (Shifted: show it). |
| space-bar | process next generation. |
| n | random world, if appropriate. |
OW[][][] stores the matrix of cells. 0 is an empty cell, and the number represents the cell type.
generation() should calculate each succesive generation by reading OW[][][] and writing the new world to NW[][][]. It can then call xfer() to transfer NW to OW.
keybd() handles keypresses.
rtmenu lists available games. Add your game here. Also, modify dortmenu() to initialize your game when it is selected. A menu should be created for commands specific to the game (mmenu[n] and domenun).
randomworld() randomizes the grid. If appropriate, add a randomization routine here.
The included automata are far from exciting, and the program isn't really done.
The code for drawing the solid cube is still wrong.
Thomas Insel (tinsel@uiuc.edu). cs3d also includes code by George Francis, Steve Kommrush, Pablo Mena, and Jon Obermark.