Skip to content

tell

Syntax

tell(agent-id, variable, pair-expression)
tell(agent-list, variable, pair-expression)

Parameters

agent-id
An expression that evaluates to the ID of the other agent whose variable should be set.
agent-list
An expression that evaluates to a list of agent IDs whose variables should be set.
variable
The name of the variable to assign.
<pair-expression>
The expression to assign to the other agent's or agents' variable.

Description

Agent action which sets the given variable for the agent whose ID is the value of the first argument to the value of the expression in the pair expression.

If the first argument is a list, then the given variable is set for each agent whose ID is in the list.

Examples

The following shows how one agent can set the agent variable is_black of another agent.

condition RollingStone {
    start_state = Start

    state Start {
        wait(0)

        next_if(TakeANap, id() == id_of_mick_jagger)
        next_if(PrintMyColor, id() == id_of_red_door)
        default(Finish)
    }

    state PrintMyColor {
        if (is_black == 0) {
            print("I'm a red door!")
        }
        if (is_black == 1) {
            print("I'm a black door!")
        }
        wait(1)
        default()
    }

    state TakeANap {
        wait(12)
        default(PaintItBlack)
    }

    state PaintItBlack {
        tell(id_of_red_door, is_black, 1)

        wait(0)
        default(Finish)
    }

    state Finish{
        wait()
        default()
    }
}

See Also