Hi,
I have tried to make sense of the help and forum but I struggle to get specific agents to contact each other. Could you
give a summary of how that works?
How can I access an agent if there is only 1 replication?
How can I access a specific agent if there are several replications? By index, I guess, but how? Can I assign names to
agents to get around the messy indexing?
If I have an agent-class "Boat" and a couple of "boats" inside, how can I access boat 1, 2 etc?
And how exactly can "boat1" send a message to, say, "aircraft5" of the "Aircraft"
agent-class?
sorry for my confusion, this topic appears very blurry to me.
thanks alot in advance for any help
Ben
Ben — 12.07.10
In addition, I found that if one agent send a message using
deliver("distress", Boat.ALL);
then even the Aircraft-agent class receives that message. I checked it using the "on message received" code
bit, putting a traceln in. Agents that are not supposed to get a message still get something, isn't that a waste of
calculations?
And once more, how can I contact a specific boat like
deliver("distress", Boat.2);
?
thanks
Pavel — 08.09.10
Hi Ben,
If there is only one instance of agent in the model, you should access it by its name, e.g. "boat". If the
agent is set as replicated, the required instance with some index should be accessed using
"boat.get(some_index)".
To send a message from one agent to another specific agent, please use the code like the following: "send("My
Message", aircraft.get(5))".
If you're using "ALL" option in "deliver()/send()" methods, this message will be delivered to all
agents placed in the environment in spite of their class.