Cellular Automata Library for OCaml

Useful functions for generating, displaying, and analyzing cellular automata.

Table of Contents

  1. What is the Cellular Automata Library?
  2. How do I use the library?
  3. How can I contribute?
  4. Bugs.
  5. Screenshots.

What is the Cellular Automata Library?

The purpose of the library is to have a simple way to generate and analyze cellular automata from the OCaml language, similar to certain functionality found in Mathematica and other software. It is not a stand-alone program that creates cellular automata; rather, the goal is to provide that functionality under a standard interface allowing such a program, or any other program that makes use of cellular automata, to be easily written.

Back to Top

How do I use the library?

There will be a standard interface across the library, with a common type defined by a record for each automata generated. Similar to other OCaml libraries, there will be a "make" function that will take certain parameters to generate an automata (such as the rule or code of the automata, the number of generations, and the starting conditions, etc.). The interface has not been finalized, as the project is still in early development. A comprehensive library documentation will be generated with ocamldoc once it is officially released.

As of right now, the interface for elementary- and totalistic-automata is provided in the Ca1D module like so:

# Ca1D.make n count start;;

...where 'n' is the number or code of the particular type of automata you wish to generate, 'count' is the number of generations to create, and 'start' is an bit array of the initial conditions. 'start' needs to be of size count*2, though hopefully this will be fixed soon. To generate a k-color nearest-neighbor totalistic automaton, you would call make with the additional optional arguments:

# Ca1D.make n ~k:3 ~r:1 count start;;

...where 'k' is the number of colors and 'r' is the range of neighbors. If 'k' and 'r' are not given, then make defaults to k=2 r=1 (i.e. elementary cellular automata).

Please read Bugs section before using this early version.

Back to Top

How can I contribute?

The Cellular Automata Library project needs developers. As is obvious from the code, I don't know very much about OCaml or programming in general. I know even less about cellular automata; in fact, my only guide is the set of notes in the back of Wolfram's A New Kind of Science. So, please go to the project page at forge.ocamlcore.org and request to join. Any ideas, tips, suggestions, or feature requests please use the project page, or contact mhtraylor@NO@SPAM@gmail.com.

Back to Top


The current preview release lacks many features, and only has functionality for generating elementary cellular automata. Some problems with the current implementation include lack of proper boundary condition handling, and speed issues with automata of several thousand generations or more. The code for generating an automata currently uses arrays and is unoptimised. Note: the array of the starting conditions should be twice the size of the number of generations (this will be fixed soon). Also, the algorithm for generating automata is currently an exponential time one, so I wouldn't advise using this early version for anything over a couple thousand generations.

Back to Top


Some screen captures of cellular automata generated by the library, plotted using the OCaml Graphics module.

Back to Top

Author: Matthew Traylor