我正在尝试通过以下方式将计划从 Agent1 发送到 Agent2:
@c2[atomic]
+giveRule[source(A)]: planGiven(B) <-
-+planGiven(B+1);
.send(A, tellHow, "@s1 +sum(num1(X, Y), num2(A, B))[source(S)] :logic(L) & attentiveness(T)<- if ((L + T) > 2){ -+res(num1(X, Y), num2(A, B), res(X*10 + A*10 + Y + B)); .send(S, tell, result(X*10 + A*10 + Y + B)); } else { -+res(num1(X, Y), num2(A, B), res(X + A + Y + B)); .send(S, tell, result(X + A + Y + B)); }.");
-+stopGivingPlan.
然后,我试图通过从 Agent1 向 Agent2 发送消息来使这个计划生效:
@c3[atomic]
+giveProbs[source(A)]: probsGiven(B) & stud(A,X)<-
-+probsGiven(B+1);
.send(A, tell, sum(num1(3,3), num2(4,9))).
这是行不通的。 为什么?
还有重要的补充: 如果我不发送计划,只是将其复制到 Agent2 中,它就可以正常工作。所以语法没问题。
另外,我在 eclipse 中使用了 jason 插件,如果值得一提的话。
最佳答案
不太清楚正在执行什么,如果你能展示整个代码就更好了。我简化了案例只是为了展示一个总体思路,如下所示:
代理1代码:
!start.
+!start: true <-
.send(agent2, tellHow, "@s1 +!sum(num1(X, Y), num2(A, B))[source(S)] :true <- -+res(num1(X, Y), num2(A, B), res(X + A + Y + B)); ?res(Z1,Z2,Z3); .print(Z1,\"+\",Z2,\"=\",Z3).");
.send(agent2, achieve, sum(num1(1,2), num2(3,4))).
代理2代码:
/* No previous code - agent1 will send a plan*/
响应应该是:
[agent2] num1(1,2)+num2(3,4)=res(10)
在这种情况下,agent2 在 agent1 发送计划之前无事可做。 Agent1 也在发送一个触发计划来实现一个总和。
关于artificial-intelligence - AgentSpeak : Problems at sending plan (Jason),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28223993/