age¶
Syntax¶
Description¶
This action returns the age of the agent that calls this action in years. The
return value is an integer, meaning that this drops any decimal portion of the
agent's age in years. If this is undesireable, use the age_in_years() action
instead.
Examples¶
Suppose the calling agent is \(33.75\) years old.
In this case some numeric x would be assigned the value 33.
As a more interesting example, the following code defines a list containing a
transmission value for each decade (0 to 9, 10 to 19, and so forth). The
following lines would set the agent's trans value to the appropriate value in
the list based on the agent's age.
trans_by_decade = list(0.12, 0.23, 0.34, 0.35, 0.36, 0.37, 0.45, 0.46, 0.56, 0.67, 0.67)
# This assumes agents do not live past 110 years old
my_index = floor(age() / 10)
set_trans(INFLUENZA, select(trans_by_decade, my_index))
Let's assume that the calling agent is \(12.34\) (or \(12.98\)) years old. The
above statements would set the trans property for the INFLUENZA condition
to the value \(0.23\).