Skip to content

index_agents

Syntax

index_agents(agent-list, test)

Parameters

agent-list
A list expression that evaluates to a list of agent ids.
test
A boolean expression used to evaluated the current agent against the given list of agents.

Returns

A list of indices of agents from agent-list that satisfies the test argument.

Description

Returns a list of indices of agents from a list that satisfies the test argument. The test can consist of multiple conditions.

In the test expressions, agent properties refer to the evaluating agent while the special variable "_" refers to the evaluated agent from the given list. For example, the test expression age < ask(_,age) would compare the evaluating agent's age against the age of each agent in the list.

Examples

The following sets the list my_list to the list of indices of agents from the evaluating agent's school who are male and older than 15:

my_list = index_agents(members(School), ask(_,sex)==male & ask(_,age)>15)

See Also