Tiled CA

The Program

This program runs cellular automata simulations on a large number of grids which can be constructed from various shaped tiles. These tile shapes can be triangles, squares, parallelograms, pentagons, hexagons or octagons. A grid editor is included with which new grid definitions may be constructed or existing grid definitions may be modified. Grid definitions may also be saved to or loaded from disk storage. Rules can be specified for each tile shape and saved to disk for later use. Cell patterns generated by the simulation may be edited and also saved to disk for later use. A color selector is provided which allows individual colors for each cell shape and state to be selected. A means of finding interesting rules is provided by a simple random rule generator.

The program will execute on a PC running Windows XP and is written in Delphi 5.

Installation

First download TiledCA.zip from here. The zip archive contains the program source code, the executable file TiledCA.exe, this document and many example grid specification files (.til), rule specification files (.rul) and pattern files (.pat). Unzip the achieve into a directory of your choice and place an icon on your desktop linked to "..\Tiled CA\Source\TiledCA.exe". To get started, click "Options | Grid" and "Load Tiles" and select a grid specification file (.til) and click "OK" to display the selected grid. Then simply click "Start" and repeatedly click "New Rule" to explore the behaviour of randomly selected rules.

The Grid

The Grid Options Dialog shown below contains an editor used to create and modify grids. Grids are constructed by repeating a small group of tiles in both the horizontal and vertical directions. The example tile group can be loaded by clicking the "Load Tiles" button and selecting file TSL2.til. Notice that the tile group is positioned in the top left corner of the editor, this is the correct position for tiling. Now click the "OK" button to see how the automatic tiling works.

The automatic tiling works with most tile groups but not with all. For those situations where the automatic tiling does not work, a manual tiler is provided. Load the file L1.til. Notice that "Tiling Automatic" is unchecked and that X and Y are set to 2 and 3. Now when the "OK" button is clicked tiling is performed by repeating the tile group every 2 squares horizontally and every 3 squares vertically.

To create a new grid, click the "New Grid" button and select a tile shape from the Shape Selector. Position the selected tile in the editor by moving the mouse and clicking the left button. Most shapes have a set of orientations. Select one of these orientations by depressing the shift key and clicking the left mouse button. Tiles may be removed by clicking the "Undo Last" button. When a tile group has been constructed, it may be moved by clicking the appropriate "Move Tiles" button. Remember to position the group in the top left corner of the editor before tiling.

Tile groups may be saved by clicking the "Save Tiles" button. The example tile files use a simple naming convention based on the tile shapes used. The letters T (triangle), S (square), L (parallelogram), P (pentagon), H (hexagon) and O (octagon) are used followed by a number. The files have an extension .til.

The Grid Options Dialog can be used to select the grid size and whether the simulation is performed on a plane or a torus by setting the "Wrap Edges" option. Point or Side neighbors can also be selected (see below).

The Rules

The rule family used by the program is called Generations and is one of the many rule families supported by Mirek Wojtowicz's MCell. The rules controlling a simulation are specified in the Rule Options Dialog shown below.

Each iteration, the neighbors of each cell that are in state 1 are counted. Cells of any shape are included in this neighbor count. If a cell is in state 0 then it changes to state 1 if its neighbor count is included in the set specified in the Birth column of the row corresponding the the cell's shape. Otherwise the cell remains in state 0. If a cell is in state 1 then it remains in state 1 if its neighbor count is included in the Survival column of the row corresponding to the cell's shape. If its neighbor count is not included in the relevant set and the number of states corresponding to its shape is greater than 2 then it changes to state 2, otherwise it changes to state 0. If a cell is in state n where n >= 2 and the number of states corresponding to the cells shape is s, then it changes to state n + 1 if n + 1 < s, otherwise the cell returns to state 0. In the example shown below, the rules are set for the well know rule "Star Wars" which uses a square grid.

The Rule Options Dialog can also be used to load and save rules. In the rule examples included with the program, the file names indicate which grid the rule is intended to use. For example, the file TSLH5_2.rul contains rules which should be used with the grid file TSLH5.til.

The Colors

The tiles, tile edges and grid colors for both the editor and the simulation display can all be selected using the Color Options Dialog shown below. The state colors for a particular shaped cell on the simulation display are smoothly interpolated using the state 1 and final state colors. To change a color simply click its square.

The Display

Set cell states on (state 1) or off (state 0) by simply left clicking the grid. To edit the CA display, first select a group of tiles by left clicking the display with the "Ctrl" key down. The first click marks a corner of the area to be selected and the second click marks an opposite corner. A third click clears the selection. While a group of tiles is selected, either the selected area can be cleared with "Edit | Clear Inside" or the non selected area can be cleared with "Edit | Clear Outside". Also a selected area can be copied or moved by left clicking the new top left position with either the "C" key (Copy) or the "M" key (Move) down.

The display may be saved to a pattern file with "File | Save" and restored from a pattern file with "File | Load". The example pattern files use a simple naming convention which describes the pattern type followed by the base name of the corresponding rule file with an extension .pat. The pattern types are S (ship), DS (diagonal ship), KS (Knight ship), O (oscillator), P (puffer), DP (diagonal puffer), G (gun), DG (diagonal gun) and R (replicator).

The display cells may be cleared (set to state 0) with "Clear" and set to random states with "Random". Finally, the simulation may be started, stopped and stepped by clicking the appropriate menu buttons.

The three example display sections show ships on different grids. These ships can be run by loading the file sets:

T7.til, T7_3.rul and DS001_T7_3.pat

TL7.til, TL7_3.rul and S001_TL7_3.pat

TSH10.til, TSH10_1.rul and S001_TSH10_1.pat

The Neighbors

Cells can have either point neighbors where at least one point is shared with a neighboring cell or they can have side neighbors where at least one side is shared with a neighbor. The display section shown below shows the point neighbors of several cells of different shapes. A cell's neighbors can be displayed by clicking the cell with the "Shift" key down.

Enhancements

A primitive method of finding interesting rules which has worked quite well is to first load or create a grid, then click "Start" and then repeatedly click "New Rule". The code executed by "New Rule" is the procedure NewRuleMenuClick in the file Display.pas. Recode this procedure to implement a more sophisticated algorithm.

To try different rule families recode the procedure ca_step in file TiledCAUnit.pas and rewrite the RuleOptions Dialog.

It would be nice to have a better pattern editor.

References

The original version of Tiled CA was written by Jason Rampe and is included in his excellent collection of programs which may be obtained here:

Visions of Chaos

Some of the example patterns are the work of Dr Carter Bays' students. Their work is here:

Triangular, Pentagonal, and Hexagonal CA

Three other CA Simulators that use a square grid are here:

Square Cell - Version 1

Square Cell - Version 2

Square Cell - Version 3

I have recently written three new CA Simulators in Java. These may be obtained here:

Java Square Cell

Java Hexagonal and Triangular Cell

All three Java programs together with the complete source code and a large collection of example patterns are included in a zip file:

Here

Contact

Please send any comments, suggestions or program enhancements to:

Brian Prentice.