Add Rule
Rules are the essential part of the time advancing process. In each time-step, for all cells and for all organisms in that cell the rule-set is evaluated and the extracted values are applied to the specified organism's characteristic.
Rules are created or edited through the fourth (last) tab in the create or edit process. In this tab there are three (3) input boxes and two buttons. The one button is for adding the rule and the other for getting a fast help regarding the syntax of the rules and the available mathematical functions and constants. All of these will also be covered in this help section and in the following paragraphs.
The first of the three input boxes regards the name of the rule. The name is just a mnemonic tool for the experimenter and has no effect on the rule or the rule's result/evaluation. Nevertheless, the name should be unique.
The second input box accepts the characteristic that the rule will be applied to. The evaluation of the rule will lead to an arithmetic value. This value will be assigned as the selected characteristic's value for the next time-step. For example, if the characteristic "Temperature" was selected in the second input box, then the arithmetic value that the evaluation of the rule will produce it will be the "Temperature"'s value for the next time-step. This is not applicable to characteristics that have predefined values.
The last input box is for the rule's expression. In the expression, the experimenter can use numbers, functions, mathematical constants, all basic arithmetic operations (+, -, /, *) and values from any characteristic of any organism (environment included) from the organism's (the organism that has the characteristic that the rule will affect) cell and all its immediate neighbours. This means that in the expression, besides numbers, the values of the characteristics can be used as variables. These characteristics can be of any organism as long as this organism is in the same or any immediate neighbour cell.
Accessing characteristics:
-
You can access characteristics using the GET function. The function takes 5 arguments.
GET(organismName, characteristicName, neighbourIndex, historyIndex, defaultValue)- organismName: The name of the organism.
- characteristicName: The name of the characteristic.
- neighbourIndex: Zero (0) is for the current cell, 1 for the exact top cell, 2 is for the top right neighbour, 3 for the exact right and so on in a clockwise fashion. This parameter is optional and defaults to 0.
- historyIndex: A value of 0 for the history index would select the current value of the characteristic whereas a value of 1 would select the exact previous value. This parameter is optional and defaults to 0.
- defaultValue: This value will be used if the requested value does not exist. This parameter is optional.
-
You can check if a cell has an organism with the HAS function. The function takes 2 arguments.
HAS(organismName, neighbourIndex)- organismName: The name of the organism.
- neighbourIndex: Zero (0) is for the current cell, 1 for the exact top cell, 2 is for the top right neighbour, 3 for the exact right and so on in a clockwise fashion. This parameter is optional and defaults to 0.
- When a default value is omitted and the requested value does not exist the rule has no effect.
- The GET & HAS functions are evaluated before any boolean logic which means that, if no default value is provided and even if the function is part of a branch (when using an IF conditional for example) that should not be taken, the rule will have no effect.
- You can access only the 8-connected cells.
-
The GET & HAS functions cannot be nested with each other or themselves.
-
Not supported
- GET(organism, characteritic, GET(oragnism2, characteristic2), 1, 0)
- HAS(organism, GET(oragnism2, characteristic2))
-
Supported
- All other functions eg. FLOOR(GET(oragnism, characteristic))
-
Not supported
The available mathematical functions are:
| Function | Description |
|---|---|
| NOT(expression) | Boolean negation, 1 (means true) if the expression is not zero |
| IF(condition,value_if_true,value_if_false) | Returns one value if the condition evaluates to true or the other if it evaluates to false |
| RANDOM() | Produces a random number between 0 and 1 |
| RANGE1(e1) | Produces a random number in the range [0, e1] or [e1, 0] if e1 < 0, where e1 can be an expression or value |
| RANGE2(e1, e2) | Produces a random number in the range [e1, e2], where e1 and e2 can be an expression or values |
| MIN(e1,e2) | Returns the smaller of both expressions |
| MAX(e1,e2) | Returns the bigger of both expressions |
| ABS(expression) | Returns the absolute (non-negative) value of the expression |
| ROUND(expression,precision) | Rounds a value to a certain number of digits, uses the current rounding mode |
| FLOOR(expression) | Rounds the value down to the nearest integer |
| CEILING(expression) | Rounds the value up to the nearest integer |
| LOG(expression) | Returns the natural logarithm (base e) of an expression |
| LOG10(expression) | Returns the common logarithm (base 10) of an expression |
| SQRT(expression) | Returns the square root of an expression |
| SIN(expression) | Returns the trigonometric sine of an angle (in degrees) |
| COS(expression) | Returns the trigonometric cosine of an angle (in degrees) |
| TAN(expression) | Returns the trigonometric tangens of an angle (in degrees) |
| ASIN(expression) | Returns the angle of asin (in degrees) |
| ACOS(expression) | Returns the angle of acos (in degrees) |
| ATAN(expression) | Returns the angle of atan (in degrees) |
| SINH(expression) | Returns the hyperbolic sine of a value |
| COSH(expression) | Returns the hyperbolic cosine of a value |
| TANH(expression) | Returns the hyperbolic tangens of a value |
| RAD(expression) | Converts an angle measured in degrees to an approximately equivalent angle measured in radians |
| DEG(expression) | Converts an angle measured in radians to an approximately equivalent angle measured in degrees |
The available mathematical constants are:
| Constant | Description |
|---|---|
| ExpE | The value of e: 2.718281828459045 |
| PI | The value of PI, exact to 100 digits |
| TRUE | The value one |
| FALSE | The value zero |
LORES