Difference between revisions of "VAT Formula parameter"

From AgentCubes
Jump to navigation Jump to search
imported>Repenning
imported>Repenning
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
Visual AgenTalk formula
+
Visual AgenTalk (VAT) Formula Syntax is used to create VAT formulas. These formulas are very powerful as they allow you to create arbitrarily complex expressions including spatial access to other agents' attributes. This is similar to a spreadsheet but even more powerful.
  
 
<br>  
 
<br>  
Line 5: Line 5:
 
{| cellpadding="10" cellspacing="0" border="0" width="100%"
 
{| cellpadding="10" cellspacing="0" border="0" width="100%"
 
|-
 
|-
| align="left" valign="top" colspan="2" |  
+
| align="left" valign="top" colspan="1" |  
<font size="5">'''Formula Syntax'''</font>
+
| align="left" valign="top" |  
 
 
|-
 
| align="left" valign="top" width="58" | '''Definition:''';
 
| align="left" valign="top" | Visual AgenTalk (VAT) Formula Syntax is used to create VAT formulas.
 
 
 
 
{| border="1" cellpadding="5" cellspacing="1" width="985"
 
{| border="1" cellpadding="5" cellspacing="1" width="985"
 
|- bgcolor="#ffcccc"
 
|- bgcolor="#ffcccc"
Line 25: Line 20:
  
 
| width="265" valign="top" bgcolor="#b0e0e6" | Basic arithmetic operations  
 
| width="265" valign="top" bgcolor="#b0e0e6" | Basic arithmetic operations  
| width="131" valign="top" bgcolor="#b0e0e6" | 3 + 4  
+
| width="131" valign="top" bgcolor="#b0e0e6" |  
| width="347" valign="top" bgcolor="#b0e0e6" | 7
+
3 + 4  
 +
 
 +
x * (3 - y)
 +
 
 +
| width="347" valign="top" bgcolor="#b0e0e6" |  
 +
7  
 +
 
 +
f(x, y)
 +
 
 +
|- align="left" valign="top" bgcolor="#ffffcc"
 +
| width="80" bgcolor="white" rowspan="2" | '''Agent Query Functions'''<br>
 +
| width="92" bgcolor="#87cefa" | agents_with_shape(''shape_name'')
 +
| width="265" bgcolor="#87cefa" | Query function that returns the number of agents with a given shape.
 +
| width="131" bgcolor="#87cefa" | agents_with_shape("dead_frog")
 +
| width="347" bgcolor="#87cefa" | returns the number of agents that have a shape with the name "dead_frog" in the simulation.<br>
 +
|- align="left" valign="top" bgcolor="#ffffcc"
 +
| width="92" bgcolor="#87cefa" | agents_of_type(''agent_name'')
 +
| width="265" bgcolor="#87cefa" | Query function that returns the number of agents with a given name.
 +
| width="131" bgcolor="#87cefa" | agents_of_type("frog")
 +
| width="347" bgcolor="#87cefa" | returns the number of "frog" agents in the simulation.
 
|- align="left" valign="top" bgcolor="#ffffcc"
 
|- align="left" valign="top" bgcolor="#ffffcc"
 
| width="80" bgcolor="white" | '''Agent Attribute Access'''  
 
| width="80" bgcolor="white" | '''Agent Attribute Access'''  
 
| width="92" bgcolor="#87cefa" | ''attribute''  
 
| width="92" bgcolor="#87cefa" | ''attribute''  
| width="265" bgcolor="#87cefa" | Access the value of an agent &lt;a href="tm_ti_attribute.html"&gt;'''attribute'''&lt;/a&gt;. An agent can have any number of attributes defined by the user  
+
| width="265" bgcolor="#87cefa" | Access the value of an agent&nbsp;'''attribute'''. An agent can have any number of attributes defined by the user  
 
| width="131" bgcolor="#87cefa" | Diameter<br>  
 
| width="131" bgcolor="#87cefa" | Diameter<br>  
 
<br> Diameter * 3.14  
 
<br> Diameter * 3.14  
Line 41: Line 55:
 
| width="92" bgcolor="#87cefa" | ''attribute''[up]<br>  
 
| width="92" bgcolor="#87cefa" | ''attribute''[up]<br>  
 
''attribute''[down]<br> ''attribute''[left]<br> ''attribute''[right]<br> ''attribute''[top]<br> ''attribute''[bottom]<br> ''attribute''[row, col]<br>  
 
''attribute''[down]<br> ''attribute''[left]<br> ''attribute''[right]<br> ''attribute''[top]<br> ''attribute''[bottom]<br> ''attribute''[row, col]<br>  
 +
 +
''attribute''[stacked_below]
 +
 +
''attribute''[stacked_above]
 +
 +
''attribute''[layer_above]
 +
 +
''attribute''[layer_below]
  
 
| width="265" bgcolor="#87cefa" | Access the value of other agents' attribute using relative coordinates.<br>  
 
| width="265" bgcolor="#87cefa" | Access the value of other agents' attribute using relative coordinates.<br>  
<br> Valid coordinates are up, down, left, right, top and bottom. Coordinates can also be specified numerically as row, column. Valid values for row and column are -1, 0, 1. Positive row values indicates right, positive column indicates down.  
+
<br> Valid coordinates are up, down, left, right, top and bottom. Coordinates can also be specified numerically as row, column. Valid values for row and column are -1, 0, 1. Positive row values indicates down, positive column indicates right.  
  
 
| width="131" bgcolor="#87cefa" | age[left]<br>  
 
| width="131" bgcolor="#87cefa" | age[left]<br>  
Line 55: Line 77:
 
| width="92" bgcolor="#b0e0e6" | @''simproperty''  
 
| width="92" bgcolor="#b0e0e6" | @''simproperty''  
 
| width="265" bgcolor="#b0e0e6" | Access the value of a global simulation property<br>  
 
| width="265" bgcolor="#b0e0e6" | Access the value of a global simulation property<br>  
<br> &lt;a href="tm_simulation_properties.html"&gt;'''Simulation Properties'''&lt;/a&gt; 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.  
+
<br>'''Simulation Properties'''&nbsp;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.  
  
 
| width="131" bgcolor="#b0e0e6" | @Time  
 
| width="131" bgcolor="#b0e0e6" | @Time  
Line 85: Line 107:
  
 
| width="347" bgcolor="#87cefa" | returns decimal number between 0 (inclusive) and 4.0 (exclusive)<br>  
 
| width="347" bgcolor="#87cefa" | returns decimal number between 0 (inclusive) and 4.0 (exclusive)<br>  
<br> returns either 0.0, 1.0, 2.0, or 3.0<br>  
+
<br> returns either 0, 1, 2, or 3<br>  
  
 
|- align="left" valign="top" bgcolor="#ffffcc"
 
|- align="left" valign="top" bgcolor="#ffffcc"
Line 105: Line 127:
 
|}
 
|}
  
&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;
+
<br> <br>  
 
 
<br>  
 
  
 
<br>  
 
<br>  
Line 113: Line 133:
 
{| width="100%" border="0" cellpadding="0" cellspacing="0"
 
{| width="100%" border="0" cellpadding="0" cellspacing="0"
 
|-
 
|-
! scope="col" |
 
! scope="col" | Operation
 
! scope="col" |
 
! scope="col" |
 
! scope="col" |
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
|
 
|-
 
! scope="row" |
 
|
 
|
 
|
 
 
|  
 
|  
 
|}
 
|}
  
<br>
+
|}
 
 
<br>
 
  
|}
+
[[Category:Parameters]]

Latest revision as of 19:14, 2 May 2017

Visual AgenTalk (VAT) Formula Syntax is used to create VAT formulas. These formulas are very powerful as they allow you to create arbitrarily complex expressions including spatial access to other agents' attributes. This is similar to a spreadsheet but even more powerful.


Operation
Definition Example Result
Arithmetic Operations x + y

x - y
x * y
x / y

Basic arithmetic operations

3 + 4

x * (3 - y)

7

f(x, y)

Agent Query Functions
agents_with_shape(shape_name) Query function that returns the number of agents with a given shape. agents_with_shape("dead_frog") returns the number of agents that have a shape with the name "dead_frog" in the simulation.
agents_of_type(agent_name) Query function that returns the number of agents with a given name. agents_of_type("frog") returns the number of "frog" agents in the simulation.
Agent Attribute Access attribute Access the value of an agent attribute. An agent can have any number of attributes defined by the user Diameter


Diameter * 3.14

value of the agent attribute "Diameter"


value of attribute "Diameter" multiplied by 3.14

Remote Agent Attribute Access attribute[up]

attribute[down]
attribute[left]
attribute[right]
attribute[top]
attribute[bottom]
attribute[row, col]

attribute[stacked_below]

attribute[stacked_above]

attribute[layer_above]

attribute[layer_below]

Access the value of other agents' attribute using relative coordinates.


Valid coordinates are up, down, left, right, top and bottom. Coordinates can also be specified numerically as row, column. Valid values for row and column are -1, 0, 1. Positive row values indicates down, positive column indicates right.

age[left]

age[top]

Temperature[-1,-1]

0.25 * (Temp[left] + Temp[right]+ Temp[up] + Temp[down])

value of the "Age" attribute of agent to the left

value of the "Age" attribute of the agent on top

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 @simproperty 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.

@Time value of simulation property "Time"
Trigonometric Functions sin(x) Trigonometric function sine, where x is expressed in radians sin(3) 0.1411
cos(x) Trigonometric function cosine, where x is expressed in radians cos(3) -0.9900
tan(x) Trigonometric function tangent, where x is expressed in radians tan(3) -0.1425
Random Number Generator random(number) Returns a pseudo random number between zero and number .


AgentSheets differentiates between integers and decimal numbers. If the number is an integer (e.g. 4), an integer between 0 and number is returned, whereas if number is a decimal number, a decimal number between 0 and number is returned.

random(4.0)



random(4)

returns decimal number between 0 (inclusive) and 4.0 (exclusive)


returns either 0, 1, 2, or 3

Other x ^^ y Exponentiation function. Raises the base number x to the exponent y 15^^4 50625
sqrt(x) Square root function. Takes the square root of number x, where x is a non-negative integer or a decimal number (x>=0). sqrt(256) 16
x % y Modulo function. Gives the remainder of the division of x / y. 17 % 4 1