The Computational Beauty of Nature
Source code

ca

simulate arbitrary one-dimensional cellular automata

Full screen →

ca -help
  or
ca     [-width  integer]  [-height integer] [-states inte-
       ger]  [-radius  integer]  [-seed  integer]  [-wrap]
       [-rules  string]  [-init  string]  [-lambda double]
       [-sq] [-bin] [-inv] [-mag integer] [-term string]

Simulates arbitrary one-dimensional cellular automata with an arbitrary choice of simulation parameters. Random rules can be generated and used with a desired lambda value.

Computes a one-dimensional cellular automata. The evolution of the CA is determined by the number of states, the radius size, the initial state, and the supplied rule. A rule is specified by a (states - 1) (radius 2 + 1) length string. At each time step a sum of each cell plus all of its neighbors within the radius is computed. That sum is used as an index into the rules string which determines the next step For example, with radius = 1 and states = 2 the rule that sums of 0 and 3 map to the 0 state, and sums of 1 and 2 map to the 1 state. A negative init string randomly initializes the starting states. If the init string is of being non-zero.

Miscellany

When supplying a lambda value for a random rule, it may not be possible to find a string with that lambda value because one may not exist. In this case, the program will do its best to find one as close as possible. In any event, the algorithm for finding random rules strings for a specified lambda value is non-deterministic and may not always find a perfect match even if one exists. However, it will work well with high probability, and even when it doesn't find a perfect match it almost always gets close.

Bugs

No sanity checks are performed to make sure that any of the options make sense.

Options

-widthWidth of the plot in pixels.640
-heightHeight of the plot in pixels.480
-statesNumber of CA states.2
-radiusRadius of CA neighborhood.1
-seedRandom seed.0
-wrapUse a wrap-around space?True
-rulesCA rules to use.0110
-initStarting state (< 0 is random).11
-lambdaLambda value for random rules.-1.0
-sqEnforce strong quiescence?True
-binBinary colors?False
-invInvert all colors?False
-magMagnification factor.1
-termHow to plot points.None

ca.c on GitHub