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 necessary to use various strategies to simplify the display. I originally had many ideas, several of which proved impractical:
Cells are arranged in a large cubical grid. We can slice this grid into sheets, and then display the sheets side by side, to be stacked mentally by the viewer. Not only is this is an inefficient use of screen space, but it is difficult to see patterns split across layers.
Simply display cells of type zero as empty space, cells of other types as solid cubes, all drawn within a large cube that rotates as the user moves the mouse. This is the simplest solution, but inner cells can be hidden by the outer cells.
Use varying transparencies by group. Inner `clumps’ of cells would be solid, and groups would get progressively more transluscent as they got farther from the center. Unfortunately, the Iris doesn’t appear to have routines for this, and if it did, they would be too slow for real time display.
Because of the wrap-around between opposite cube faces, the cube is actually the 3d surface of a 4d hyper-torus cut along three lines. Since the opposite faces of the cube “wrap around,” it is difficult to see how certain logically adjacent cells touch, but we can translate the cube by moving where these lines are. This is implemented by the x, y, and z keys in my program.
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 — a shell for displaying 3d cellular automata
cs3d [-help] [display]
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.|
Normally, clicking the right mouse-button brings up a menu from which the user may select from a list of game-specific commands. Clicking the left button brings up a menu of more general commands, including a submenu from which the user may select from the available games.
It should be relatively obvious from the source code where code for new games can be added. These variables and functions may be particularily useful:
OWstores the matrix of cells. 0 is an empty cell, and the number represents the cell type.
generation()should calculate each succesive generation by reading
OWand writing the new world to
NW. It can then call
rtmenulists 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 (
randomworld()randomizes the grid. If appropriate, add a randomization routine here.
~tinsel/life/w6.c — source code
Unlike the right menu, the left menu is stays up until the
user either chooses an item or clicks on the background with the
right menu button. This makes no sense to the user, and is
probably because of the way
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 (firstname.lastname@example.org). cs3d also includes code by George Francis, Steve Kommrush, Pablo Mena, and Jon Obermark.
Copyright © 1998–2017 Thomas Insel