Communication
Agents are social: they interact with other agents to cooperate, coordinate or negotiate1.
Agent communication builds on speech act theory2, where saying something is doing something: a message is an
action meant to change the mental state of its receiver, informing it of a fact or asking it to achieve a goal.
Agent communication languages such as KQML3 name these intentions with performatives (tell, achieve,
askOne, ...). Since agents are autonomous, though, no sender can change a receiver's mind directly: it is the
receiver that decides what a message means to it. Agents can also communicate indirectly, through the
environment, by stigmergy.
Messages in JaKtA
JaKtA keeps the core of direct communication minimal: a message carries a sender, a receiver and a payload, which
can be any object. Sending is an action, provided by the MessagingSkill like any other skill:
agent.sendTo(receiver, payload) sends a message to an agent, on whichever node it lives, and
agent.broadcast(payload) to every agent.
adding.goal {
takeIf { it == "sendPing" }
} triggers {
agent.sendTo(bob, "Ping!")
}
The receiver decides what a message means
A received message is an external event, and the receiver's handlesMessageEvents decides what it means: new
beliefs, as an informative message, new goals, as a request, or nothing at all, by returning null:
handlesMessageEvents { message ->
when (val payload = message.payload) {
is String -> AgentUpdate.Belief(setOf(ToldBelief(payload, message.sender)), emptySet())
else -> null
}
}
Here ToldBelief(text, sender) is a data class of the agent's own: beliefs need not be messages.
AgentUpdate.Goal(additions, removals) would accept the message as a request instead. The resulting belief or goal
events trigger plans as any other, so the agent reacts to messages as it reacts to what it perceives.
The ping-pong tutorial builds a complete example with these primitives.
The Prolog incarnation adds Jason-style4 KQML performatives on top of these
primitives, with [source(sender)] annotations on what agents receive:
see KQML messaging.
Indirect communication
Agents can also coordinate through the environment: they act on a shared world model through a skill and perceive the changes the others made, without ever addressing each other.