Skip to main content

Port a Jason agent

The Prolog incarnation keeps Jason's knowledge representation, so most of an AgentSpeak program translates line by line. The Blocks World showcase is a complete port of the Jason agent of the same name.

Beliefs and rules​

parent(abraham, isaac).
ancestor(X, Y) :- parent(X, Y).
believes {
+initialBelief { "parent"("abraham", "isaac") }
+inferenceRule { "ancestor"(X, Y) impliedBy "parent"(X, Y) }
}

Initial goals​

!start. becomes:

hasInitialGoals { !initialGoal { "start".toAtom() } }

Plans​

+!introduce(P) : ancestor(A, P) <- .print(P, " descends from ", A). becomes a plan with a trigger, a guard and a Kotlin body:

prologPlan {
adding.goal { matchingGoal { "introduce"(P) } } onlyWhen { satisfies { "ancestor"(A, P) } } triggers {
agent.print(P, " descends from ", A)
}
}
AgentSpeakJaKtA
+!gadding.​goal { matchingGoal { g } }
-!g (failure handling)failing.​goal { matchingGoal { g } }
+b / -badding.​belief { matchingBelief { b } } / removing.​belief { .​.​.​ }
:​ contextonlyWhen { satisfies { context } }
[source(​S)] in a triggerthe same annotation: matchingBelief { b[source(​S)] }

Plan bodies​

AgentSpeakJaKtA
!gagent.​achieve(​goal { g })
!!gagent.​alsoAchieve(​goal { g })
?qtestQuery { q } (see why there are no test goals)
+b / -bagent.​believe(​belief { b }) / agent.​forget(​belief { b })
.​print(​.​.​.​)agent.​print(​.​.​.​)
environment actionsa skill

Messages​

.send becomes a KQML function, with a MessagingSkill in scope:

AgentSpeakJaKtA
.​send(​bob,​ tell,​ b) / .​send(​bob,​ untell,​ b)agent.​tellTo(​bob,​ belief { b }) / agent.​untellTo(​bob,​ beliefQuery { b })
.​send(​bob,​ achieve,​ g) / .​send(​bob,​ unachieve,​ g)agent.​delegateAchieveTo(​bob,​ goal { g }) / agent.​sendUnachieveTo(​bob,​ goal { g })
.​send(​bob,​ askOne,​ q,​ A)agent.​askOneTo(​bob,​ beliefQuery { q })
.​send(​bob,​ askAll,​ q,​ L)agent.​askAllTo(​bob,​ beliefQuery { q })
.​broadcast(​tell,​ b)agent.​broadcastTell(​belief { b })

Unlike Jason, questions need an answering plan: see Ask and answer with KQML.

What changes​

  • Bodies are Kotlin: loops, conditionals and calls replace AgentSpeak body formulas.
  • Agents live in nodes and act through skills, not a Jason environment.
  • A belief has a single source: a belief told by two agents is kept once (see caveats).

See Jason-like Kotlin Agents for how JaKtA relates to Jason.