[valid xhtml 1.1]
[valid css]
supported browser Youre Browser has to know the CSS 2.0 property white-space.

Table of contents

  1. Introduction
    1. Preamble
    2. Syntax and Terminology
  2. celmac 2.0 Manual
    1. Terms in celmac
      1. ABC ( a bit C )
        1. Peculiarities
        2. Expressions
        3. Variables
        4. Assignments
        5. Control Structures
        6. Loops
        7. Working with Braces
      2. CAL ( CA Language )
        1. Variables
        2. Comments
        3. CAL-Statements
    2. Handling celmac 2.0
      1. Generator and Player
      2. The Generator
        1. Menu Navigation
        2. Programming in ABC
      3. The Player
        1. Open CA
        2. The Sub-Windows
        3. Main Menu
          1. Der Menüpunkt CA
          2. Assistants
            1. Simulationsassistant
            2. Iterationsassitant
            3. Parameterassistant
            4. Statistikassistant
            5. Optimierungsassistant
      4. Statistical Evaluation
        1. Combinations
        2. Evaluation Window

1. Introduction

1.1 Preamble

This is the official manual to celmac 2.0, a very flexible simulator for Cellular Automata (CA). celmac 1.0, the previous version (released 2004), was optimized to the CAs Game Of Life and Langton's Ant, but celmac 2.0 has the potential to simulate far more CAs. The greatest improvement of celmac 2.0 is, that the global function which determines the next state of each cell can be rewritten by the user. Furthermore celmac 2.0 comes with a variety of helpful statistical tools, which allow e.g. the analysis of discrete dynamical systems and their usage for producing random numbers.

This manual assumes that you have consolidated knowledge about the Theory of Cellular Automata. In case you haven't, please familiarise with the topic to deal with that manual as well as the program itself.

I hope you enjoy you're experience with celmac 2.0. Do me a favour by sending your feedback!

fstahlberg@googlemail.com

However you can write a comment on my homepage, but its hard to deal with the captcha if you don't unterstand german (maybe Google Translation helps?).

1.2 Syntax and Terminology

In the manual I'll use consistent terminology and typography, as shown in the following table. Hopefully this will simplify understanding.

Meaning Example typographic characteristic
proper name CAL italic
syntactical definitions
<name>:<value>
italic, placeholders in angle brackets (<, >)
code
if(var=266) var=2;
gray background, font family: Courier, keywords bold

2. celmac 2.0 Manual

2.1 Terms in celmac

2.1.2 ABC

The goal of celmac 2.0 is to simulate a lot of different CAs. The most characteristic element of a CA is the global function (GF), the one rule for updating each cell. In celmac 2.0 you can set the GF via two different programming languages: ABC ( a bit C ) and CAL. At first we will discuss ABC.

ABC is a very minimalistic language with syntax based on C. We begin with the fundamentals of that language and realize them in the chapter Programming with ABC.

Peculiarities

You shouldn't expect ABC to be a fully developed and ingenious programming language. ABC has low requirements, so it is as slight as it can be. You can't even define your own procedures, structures or anything else you are accustomed to use in C or other programming languages (okay, except for Brainfuck or similar ;). There is only one data type: the 1-byte-integer. ABC consists of only four language components.

  1. Declarations of Variables
  2. Assignments
  3. Control Structures
  4. Loops

Three of these components strongly deal with expressions, so expression is a central term in ABC.

By the way there is unexceptional no syntax-relevant Whitespace in ABC. That is an important difference to the most of the other programming languages. We'll notice its consequences later.

Expressions

<expression>

The expression is the basic part of ABC. If you want to characterize ABC with one sentence, you can say it's an expression-oriented language. Even more clearly is that when we discuss CAL, in which ABC finally becomes translated. CAL works exclusively with expressions.

Generally an expression is an instruction to execute something, which will return a value. In ABC an expression is made up of integer constants, variable names and operators and it will always return an 1-byte-integer value.

42
It's an expression which will return the value 42.
23+66/2
It's an expression which will return the value 56.

On the one hand expressions are intended for assignments to variables, on the other hand they are used as conditions in control structures and in loops.

Variables

mk(<name>);

We allready know that there is (according to the low requirements to the language) only one data type in ABC, the 1-byte signed integer. The value -127 is reserved to the constant TARITH_IDENTIFIER and must not be used. Therefore variables in ABC can only cover integers between -126 and +127. However during application this range is absolutly sufficient.

The name conventions in ABC corresponds with the common name conventions for variables in programming languages like C.

Declarations of variables in ABC looks a bit different as in C. Why?

int var;
Declaration of an integer variable called var in C.

Because there is no syntax-relevant Whitespace in ABC, the following string would be generated by parsing the code above.

intvar;

That is a syntax error. Instead of that ABC has (comparable to Perl) an own procedure for declaring variables (by the way the only procedure in ABC) called mk().

mk(var);
Declaration of a variable called var in ABC.

In this way the unnecessary specification of data type is bypassed. Unfortunately there is no possibility to set an initialization value. Variables are initialized with 0 per default.

The declaration via mk() isn't compulsory. If you don't declare a variable via mk(), it becomes declared automatically at it's first use.

Assignments

<variable name>=<expression>;

Assignments are used to set a value to a variable. This value will always be a value, which has been returned by an expression. The syntax is equal to C, but the implementation is not. The character '=' is (as opposed to C) not an operator in ABC, therefore an assignment is never an expression. As shown in the following example, assignments do never return a value.

var=42;
valid to ABC and C syntax, assigns 42 to var.
if(var=266) var=2;
C-Syntax: If you can set var to 266, set var to 2.
ABC-Syntax: Syntax error! ABC tries to interpret the string var=266 as an expression, but find the unknown operator '='.

Control Structures

if(<expression>){ <command1>; <command2>; (...) }else{ <command1>; <command2>; (...) }

The only available control structure in ABC is the if-else control structure. The syntax looks similar to a C syntax, but again you have to keep in mind that there is no syntax-relevant Whitespace in ABC. Deal with the following example code. It is valide C code, but in ABC this code is leading to an unexspected result.

if(a==2) b=3; else b=7;

Becomes parsed as follows.

if(a==2)b=3;elseb=7;
Assigns the value 7 to the variable elseb.

This issue can be solved by using braces. You'll learn more about working with braces later.

if(a==2) b=3; else{ b=7; }

Loops

In ABC you have two different loops: the while loop and the repeat-until loop.

While Loop
while(<expression>){ <command1>; <command2>; (...) }

The expression is first evaluated - if the expression is true the code within the block will be executed. It will be repeated until the condition becomes false. The while-loop is a classical pre-test loop.

Repeat-Until Loop
repeat{ <command1>; <command2>; (...) } until(<expression>);

First, the code within the block is executed, and then the expression is evaluated. If the expression is false the code within the block will be executed again. This will be repeated until the expression becomes true. The repeat-until loop is the post-test loop in ABC.

Working with Braces

The translator for translating ABC into CAL used in celmac 2.0 has several problems with stripping braces ('{' and '}') in combination with nested blocks. We already know an example where we were confronted with an issue caused by stripping braces even without nested blocks. In case of doubt you are better off setting braces. However in some cases avoiding braces will improve performance of produced CAL-code. Keep the following rules in mind.

  1. else must always be followed by an opening brace.
  2. When Braces have not been used, one block must not include another block but only an assignment. Following code is not valid.
    if(a==5) while(a<20)a=a+1; if(a==5) while(a<20){ a=a+1; }
    not valid ABC.
    Setting braces solves this issue.
    if(a==5){ while(a<20)a=a+1; }
    now it's valid.

2.1.2 CAL

CAL (CA-Language) is a very simple and low-level language known by celmac's Player. The dependencies between ABC, CAL and celmac 2.0 is comparable to the relationship between C, assempler and the machine itself. C becomes translated to assempler so it can be compiled. You don't necessarily have to deal with CAL to handle celmac 2.0, but sometimes you can optimize the generated CAL code to make the CA faster and more flexible.

Variables

CAL-Variables are consistent with ABC-Variables. Additionaly there is a reserved CAL variable called LC. You're better to abstain from using this as long as you don't exactly know what you are doing. This variable contains the value 1 or 0, depending on whether the last statement was executed or not. The ABC-To-CAL-Translator needs this variable for high-performance CAL implementations of ABC's if-else-structures.

Comments

#<comment>

If the first character in a line is a mesh (#) this line is marked as a comment.

CAL-Statements

<command> <condition> <argument>

In CAL each line is a statement (needless to say except for comment lines..). A statement is composed of at least two elements. The elements are separated with a space character. You must not use Whitespace. Here an example of a valid CAL statement.

st a!=2 a=2

The first two characters (the first element) declare how to use the argument. The second element (an ABC-expression) specifies, if the statement will be executed. Furthermore some CAL-commands require a third element as an argument. The following, will give you an overview of all CAL-commands and a short description of how to use the argument.

Command Description
mk That command is equivalent to mk() in ABC. With mk you can declare variables. If you want to declare many variables use commas.
Example:
mk 1 var
Declares unconditionally the variable var
st The most important command. It expects an ABC-assignment as argument..
Example:
st 1 var=2
unconditionally assignment: assigns 2 to variable var.
jp The argument has to be a positive integer here. It consists the line number that ought to be carried out in case the condition is true. The first line has the line number 0.
Example:
jp !a<5 3 st 1 a=a+1 jp 1 0
In ABC-Syntax: while(a<5) a = a+1;
vd The vd-command can be seen as a st-command without an argument. At first sight this command doesn't make sense, but finally you can i.g. invert the LC variable needed in control structures.
Example:
vd 1
Does unconditionally nothing :)

In the following table you'll find examples for ABC to CAL translation. The line numbers are in braces to make it easier to comprehend the jp-commands.

ABC CAL
mk(a, b, c); a=4; if(a==5) b=5; else{ c=b; } if(b<a){ b=4; } else{ c=b; } c=a; while(3>a) a=a+1; b=4; repeat{ b=5; } until(4==5); b=c;
{0} mk 1 a,b,c {1} st 1 a=4 {2} st a==5 b=5; {3} vd LC==0 {4} jp LC==0 6 {5} st 1 c=b {6} jp b>=a 9 {7} st 1 b=4 {8} vd LC==0 {9} jp LC==0 11 {10} st 1 c=b {11} st 1 c=a {12} jp 3<=a 15 {13} st 1 a=a+1 {14} jp 1 12 {15} st 1 b=4 {16} st 1 b=5 {17} jp 4==5 16 {18} st 1 b=c

2.2 Handling celmac 2.0

The goal of celmac 2.0 is to simulate a lot of different CA. However this flexibility yields a deterioration of performance to a certain extent. For this reason there are several techniques which counteracts. Therefore it could be hard for beginners to handle celmac 2.0, but after a while you will get used to the handling. Let's start with the basic structure.

2.2.1 Generator and Player

The most obvious (see the start dialog) and important structuring of the program is the differentiation between Player and Generator.

The Generator creates CA. Basically it defines the GF (global function), the character of each CA. Additionally the Generator can suggest the dynamics, because a GF often calculates with a constant value.

The Player handles the execution and the iteration of the CA, which previously was created by the Generator. Using the Player you can monitor the expansion of a CA, run random experiments or test given GFs. In celmac 2.0, you have a strict differentiation between the universe in which the CA is being executed and other elements of CA (especially the GF), so you can deal with a lot of different experiment set-ups (e.g. run Langton's Ant in a Game Of Life universe).

2.2.2 The Generator

Menu Navigation

Benutzerinterface des Generators You open the window on the right side by clicking Generator in the startdialog. It has a main menu and three tabs.

The first tab Head contents all required settings of CA except of the GF. Please read the chapter Programming with ABC to set the Range of Cell States in proper style. When the checkbox Synchronous Dynamic is unchecked, you can see the groupbox Divide field into blocks.... If you want to use an asynchronous dynamic, set the dimension of each block executed synchronous on this panel. Example: set width and height to 1 to trigger celmac 2.0 to iterate each cell one by one in reading direction (left to right).

On the tab ABC you'll find a textfield for editing the GF.

Click the tab CAL and celmac 2.0 translates the given ABC to CAL and prints it out. Now you could edit the low-level CAL code to optimize the GF.

Menu des GeneratorsLet's deal with the main menu. The only interesting point is File.

Click New... to create new CA. It will appear a dialog for choosing assistants which helps you to do this. If you don't want to use an assistant doubleclick the first option.
Note: This assistants have nothing to do with player's assistants!

The following three menu items (Open..., Save and Save As...) are to handle files containing ABC code (*.abc). On the one hand such files can be edited later using the Generator, on the other hand the Player cannot deal with them.

To create a file readable for the Player you have to use Create CA.... Note that you cannot edit those files with the Generator anymore, because these files contain CAL code which cannot be retranslated to ABC.

With Player... you switch to the Player.

Programming with ABC

In celmac 2.0 the programming language ABC is used to programm the GF. We allready know the syntax of ABC, so now we put it into practice.

Actually ABC doesn't know arrays. However you access to the neighbours just with an array called Cell[x][y] (x and y are integer constants). Even the return value of the GF you define with an assignment to the variable Cell[0][0]. The following example of a binary cellular automaton set the state of a cell to 1 if its left neighbour state is 0 and its right neighbour state is 1.

if((Cell[-1][0]==0)&&(Cell[1][0]==1)) Cell[0][0]=1;

At first glance following assignment is valid.

Cell[0][1]=1;

However according to the theory of CA that assignment isn't possible. Nevertheless ABC stores the value, but only as long as the GF runs. All self-declared variables are static and keep their values as long as the cellular automaton is opened.

Furthermore you have to keep in mind the Range of Cell States. The Generator defines the value, but it has not the meaning which you might think of.

This value (let's call it z) sets the maximum absolute value which a cell state can reach. During the execution of the GF it is anyhow possible for Cell[0][0] to take a higher value (certainly the technical maximum of variables in ABC will remain unaffected), but after the run of the GF we set the value to modulo z. Consequential celmac 2.0 is not able to simulate binary CA (even with z=2 Cell[0][0] can take values {-1;0;1}), but that doesn't affect the common arithmetic.

if(Cell[0][1]==1) Cell[0][0]=Cell[0][0]+1;

The example above shows a binary CA, which toggles the state of the cell if its bottom neighbour has the state 1. If Cell[0][0] is set to 0, after execution of GF it is set to 1 (1mod2=1). If Cell[0][0] is set to 1, the GF calculates 0 (2mod2=0).

In conclusion, lets deal with a complete GF of an established CA. We take the classical Conway's Game Of Life as an example (23/3).

Count= Cell[-1][-1]+Cell[0][-1]+Cell[1][-1]+ Cell[-1][0]+Cell[1][0]+ Cell[-1][1]+Cell[0][1]+Cell[1][1]; if(Count==3) Cell[0][0]=1; else{ if(Count!=2){ Cell[0][0]=0; } }
Conway's Game of Life realized in ABC (z=2).

3.2.3 The Player

When you click on Player in celmac's startdialog you'll see a relatively blank window. Basically you can open help or open a CA.

Opening CA

You can open a CA by clicking on the folder icon or the menu item Open CA.... The dialog Open CA will appear.

Dialogfeld CA öffnen At first choose the CA. Therefore load a CA-file (*.ca), which was created by the Generator before. The second textfield specifies the initial field which is used as the universe of the CA. Either you load a PBML-file or you create a new field by typing Empty Field or using the speedbutton. If you create a new field you have further options to set the size and its topology. Both settings can be edited later. To set the topology you have to constitute how to connect both ends of each dimension of our universe. The following three values are possible.

Click OK to close this dialog and open a MDI-child containing the CA.

The Sub-Windows

One window stands for one CA and shows its universe. The cells are coloured depending on their state. You can modify the universe by left-clicking. Lets deal with the contextual menu.

PopUp-Menü eines Unterfensters The contextual menu appears when you right-click on the window. The first menu item Clickaction defines what will happen with a cell, which is being left-clicked. You can also load/save discrete sections of the universe. The used file format is PBML. All other menu items should be self-explanatory.

The Mainmenu

If a CA is loaded the mainmenu of celmac 2.0 will expand.

Hauptmenu of the Player

Lets take a look to the speedbuttons. The first four icons are well-known. Click on the green arrow, hit F9 or use the menu to iterate the CA. The number of iterations are set via iterationassistant. The other speedbuttons show/hide the different assistants, which will be explained later in this chapter.

The Menuitem CA

Der Menupunkt CA The CA menu of the player mostly relates to the CA of the active subwindow. The submenu Field is similar to the contextual menu of the child window. Statistical Evaluation is described later. Close CA closes a CA and hences a subwindow. CA-Generator... switches to the Generator. Preferences are the basic settings of celmac 2.0, not related to the currently active CA.

Assistants

Die Assistenten des Players

Player's assistants control the whole simulation. You can hide/show the assistants via main menu, speedbuttons or the keys F4 - F8. Following five assistants are available.

Simulationsassistant

Simulationsassistant The simulationassistant offers three differentiated specifications about the performance of the simulation. The more often the screen is refreshed, the slower the whole simulation will be. The assistant differentiates between Field, Generation Panel and Statistics. If a checkbox is unchecked, the panel belonging to it will not be refreshed until the whole simulation is finished. Even if you simulate a lot of iterations I recommend to refresh the Generation Panel, cause refreshing this is not hard for the system and you will always be able see the progress of the simulation.

Iterationsassitant

Every simulation is started (directly or indirectly via shortcuts or speedbutton) via the iterationassistant. I think the GUI of this assistant doesn't need further explanations in the absence of intricacy of it.

Parameterassistant

The table in this assistant shows all ABC-variables declared in the GF of the currently active CA. Therefore it is possible to write ABC-code, which reacts to changes of some variables. E.g. you could programm a GF for Greenberg-Hastings Automata with a variable parameter s. You can edit the values directly in the table. Note: changes aren't effectual until you defocus the assistant.

Statisticsassistant

Der Statistikassistent The statisticsassistant has two different states: collapsed and normal. The assistant always relates to the actual generation of the currently active CA. You always see the monitored combinations and their absolute frequency up to this generation. Certainly you can edit and delete the combinations or create new ones. Additionally you could save the statistics as a SPG-file or load old statistics in the same file format. When loading old statistics all data gathered so far will be lost.

Please pay attention to the checkbox Statistical Records. If this checkbox is unchecked, no combinations will be monitored and no statistical informations will be collected while iterating CA.

Optimizationassistant

The optimizationassistant defines how to interpret the GF - In-Time-Interpreting of CAL and Table. Choosing In-Time-Interpreting of CAL, the interpreter construes the GF while executing the CA. In case Table is selected , the interpeter first collects the results of all neighbourhood constellations in a table and looks them up while iterating the CA. Which option is more performant depends on how much neighbours are defined and how many states they can reach. Further information in the help of celmac 2.0 by clicking on the question mark.

3.2.4 Statistical Evaluation

If you want to work with the statistical tools of celmac 2.0, you have to know the idea of the Combinations, which is the essential element of statistics in celmac 2.0.

Combinations

If the checkbox Statistical Records in the statisticsassistant is checked, after each generation the given monitored combinations are read out in the current field. Therefore all cells of the field have been arranged one after another in a line. In this line celmac 2.0 searches for combinations, counts them and saves the result. Combinations can reach any length. Here some examples how to use combinations.

Combinations are the tool to produce statistical results in celmac 2.0. By dint of the concept of combinations you're able to filter dedicated patterns, generate random numbers and compare different CA.

Evaluation Window

You can open this window via player's mainmenu (CA->Statistical Evaluation) or with the button in the statisticsassistant. Here you can visualize collected data and compare different graphs.