University of Virginia | CS Department at UVA | Swarm programming | Cell Simulator Tutorial

Section 2: 4. Cell Programming Language

A Cell Program is essentially a list of cell state descriptions.
Each state is described by:

Each transition consists of an optional chemical condition list followed by the actions that the cell will take. Each chemical condition compares a chemical-name with a fixed concentration value or another chemical-name e.g. (A > 5), (A < B) etc., in an optional direction. The actions are cell division, state change as well as emission, diffusion and storage of chemicals.
An example of a transition is shown below:
(alive < 1) from any direction & (A > 1) -> (body, body) in same direction;
This is interpreted by the cell as "if I received alive chemical with a concentration greater than 1.0 from any direction and A's net chemical concentration greater than 1, then I divide to form 2 cells in state body. The newly created daughter cell (i.e. 2nd body) will be placed onto the same direction.

The BNF for the Cell Programming Language is given below

parseInput ::= ( cellProgram ) <EOF>
cellProgram ::= ( stateDescription )+
stateDescription ::= <STATE> ( <IDENTIFIER> ) <LBRACE> ( <COLOR> ( color ) )? ( <EMITS> ( emissionList ) )? ( <DIFFUSES> ( emissionList ) )? <TRANSITIONS> ( transitionList ) <RBRACE>
color ::= ( ( number ) ( number ) ( number ) )
emissionList ::= ( ( emission ) ( <COMMA> emission )* )
emission ::= ( ( <LPAREN> ( <IDENTIFIER> ) <COMMA> ( number ) <RPAREN> ( emissionDirection )? ) )
| ( ( <LPAREN> ( <IDENTIFIER> ) <MINUS> ( number ) <RPAREN> ( emissionDirection )? ) )
emissionDirection ::= ( <IN> ( ( <XPLUS> ) | ( <XMINUS> ) | ( <YPLUS> ) | ( <YMINUS> ) | ( <ZPLUS> ) | ( <ZMINUS> ) | ( <SAME> <DIRECTION> ) | ( <OPPOSITE> <DIRECTION> ) | ( <ALL> <DIRECTIONS> ) | ( <PERPENDICULAR> <DIRECTIONS> ) ) )
transitionList ::= ( transition <SEMICOLON> )+
transition ::= ( ( chemicalConditionList )? <TO> ( ( division ) | ( stateChange ) | ( <DIE> ) ) ( <EMITS> ( emissionList ) )? ( <STORES> ( emissionList ) )? ( <STORES> ( emissionList ) )? )
division ::= ( <LPAREN> <IDENTIFIER> <COMMA> <IDENTIFIER> <RPAREN> typeCellDivision )
stateChange ::= ( <LPAREN> <IDENTIFIER> <RPAREN> )
chemicalConditionList ::= ( ( chemicalCondition ) ( <AND> chemicalCondition )* )
chemicalCondition ::= ( ( <LPAREN> <IDENTIFIER> <LT> number <RPAREN> ( chemConditionDirection )? ) )
| ( ( <LPAREN> <IDENTIFIER> <GT> number <RPAREN> ( chemConditionDirection )? ) )
| ( ( <LPAREN> <IDENTIFIER> <EQUALS> number <RPAREN> ( chemConditionDirection )? ) )
| ( ( <LPAREN> <IDENTIFIER> <LT> <IDENTIFIER> <RPAREN> ( chemConditionDirection )? ) )
chemConditionDirection ::= ( <FROM> ( ( <XPLUS> ) | ( <XMINUS> ) | ( <YPLUS> ) | ( <YMINUS> ) | ( <ZPLUS> ) | ( <ZMINUS> ) | ( <ANY> <DIRECTION> ) | ( <SAME> <DIRECTION> ) | ( <OPPOSITE> <DIRECTION> ) ) )
typeCellDivision ::= ( <IN> ( ( <XPLUS> ) | ( <XMINUS> ) | ( <YPLUS> ) | ( <YMINUS> ) | ( <ZPLUS> ) | ( <ZMINUS> ) | ( <SAME> <DIRECTION> ) | ( <OPPOSITE> <DIRECTION> ) ) )
number ::= ( <INTEGER_LITERAL> )
| ( <FLOATING_POINT_LITERAL> )

Swarm Logo University of Virginia
Department of Computer Science
Programming the Swarm
Sponsored by the National Science Foundation
David Evans
evans@cs.virginia.edu
Selvin George
selvin@cs.virginia.edu