||x + y
x - y
x * y
x / y
|Basic arithmetic operations
||3 + 4
|Agent Attribute Access
||Access the value of an agent attribute. An agent can have any number of attributes defined by the user
Diameter * 3.14
|value of the agent attribute "Diameter"
value of attribute "Diameter" multiplied by 3.14
|Remote Agent Attribute Access
|Access the value of other agents' attribute using relative coordinates.
Valid coordinates are up, down, left, and right. Coordinates can also be specified numerically as row,column. Valid values for row and column are -1, 0, 1. Positive row value indicates right, positive column value indicates down.
0.25 * (Temp[left] + Temp[right]+ Temp[up] + Temp[down])
|value of the "Age" attribute of agent to the left
value of the "Temperature" attribute of the agent above to the left
The average of the value of the "Temp" attribute of the agents left, right, up and down.
|Simulation Property Access
||Access the value of a global simulation property
Simulation Properties are used to share information between agents. Users can inspect and edit the values of simulation properties using the simulation property editor. The "@" sign is used to differentiate the simulation properties from agent attributes.
||value of simulation property "Time"
||Trigonometric function sine, where x is expressed in radians
||Trigonometric function cosine, where x is expressed in radians
||Trigonometric function tangent, where x is expressed in radians
|Random Number Generator
||Returns a pseudo random number between zero and number .
AgentSheets differentiates between integers and decimal numbers. If the number is an integer (e.g. 6), an integer between 0 and number is returned, whereas if number is a decimal number, a decimal number between 0 and number is returned.
In a Ristretto-generated applet, whether number is an integer or a decimal number, a decimal number between 0 and number is always returned.
To have your applets and your AgentSheets simulations be consistent, use decimals, e.g. random(15.0).
|returns decimal number between 0 (inclusive) and 4.0 (exclusive)
AgentSheets: returns either 0, 1, 2, or 3
Ristretto: returns decimal number between 0 (inclusive) and 4.0 (exclusive)
||x ^^ y
||Exponentiation function. Raises the base number x to the exponent y
||Square root function. Takes the square root of number x, where x is a non-negative integer or a decimal number (x>=0).
|x % y
||Modulo function. Gives the remainder of the division of x / y.
||17 % 4
||x | y
||Bitwise logical inclusive OR. Performs a logical OR operation on each of the digits of the binary representation of x and y.
||13 | 7
(13 in decimal is 1101 in binary; 7 in decimal is 111 in binary; Bitwise ORing 1101 and 111 yields 1111, which is 15 in decimal)
|x ^ y
||Bitwise logical exclusive OR. Performs a logical EXCLUSIVE OR operation on each of the digits of the binary representation of x and y.
||13 ^ 7
(13 in decimal is 1101 in binary; 7 in decimal is 111 in binary; Bitwise Exclusive ORing 1101 and 111 yields 1010, which is 10 in decimal)
|x & y
||Bitwise logical AND. Performs a logical AND operation on each of the digits of the binary representation of x and y.
||13 & 7
(13 in decimal is 1101 in binary; 7 in decimal is 111 in binary; Bitwise ANDing 1101 and 111 yields 0101, which is 5 in decimal)
|x << y
||Left shift. Shifts binary representation of number x, y places to the left. (Equivalent to multiplying number x with 2^^y)
||13 << 2
(13 in decimal is 1101 in binary; shifting 1101 2 positions to the left yields 110100, which is 52 in decimal - which is equivalent to multiplying 13 by 4 (2^^2))
|x >> y
||Right shift. Shifts binary representation of number x, y places to the right. (Equivalent to the integer division of number x by 2^^y)
||13 >> 2
(13 in decimal is 1101 in binary; shifting 1101 2 positions to the right yields 11, which is 3 in decimal - which is equivalent to the integer division of 13 / 4 (2^^2))