Skip to content

set_age

Syntax

set_age(agent-id, age-exprression)

Parameters

agent-id
An expression that must evaluate to a valid ordinary agent ID.
age-expression
An expression that must evaluates to a numeric value.

Description

Set the agent's age in years to the integer part of the expression's value.

The agent is assigned a randomly selected birth date within the year.

An error occurs of the first argument does not evaluate to a valid agent ID.

Examples

In the following, the new agent is assigned a birthdate between 40 and 41 years prior to the current simulation date.

new_agent_id = spawn_agent()
set_age(new_agent_id, 40)

In the following, the new agent is ageless, meaning that its age will always be reported as -1.

new_agent_id = spawn_agent()
set_age(new_agent_id, -1)

See Also