Artificial intelligence 无法将操作发送到另一个Jason代理
我使用Jason语言在两个代理之间进行通信。但我无法使用send操作,它给出了一个错误 这是我的两个经纪人 代理1:-Artificial intelligence 无法将操作发送到另一个Jason代理,artificial-intelligence,agent,artificial-life,Artificial Intelligence,Agent,Artificial Life,我使用Jason语言在两个代理之间进行通信。但我无法使用send操作,它给出了一个错误 这是我的两个经纪人 代理1:- // Agent Agent1 in project factorial3.mas2j /* Initial goals */ !start. /* Plans */ +!start : true <- .print("starting.."); !query_factorial(2). +!query_factorial(X) : true <-
// Agent Agent1 in project factorial3.mas2j
/* Initial goals */
!start.
/* Plans */
+!start : true
<- .print("starting..");
!query_factorial(2).
+!query_factorial(X) : true <-
.send(agent2,tell,giveme(X)).
/*+fact(X,Y) : true <-
.print("factorial ", X, " is ", Y, " thank you expert").*/
如果您希望请求代理执行计划(对于agent1,当您说“+!query_factorial(X)…”)时),它应该是一条实现消息。取消对“计划”+事实(X,Y)的注释:true您收到了什么错误消息?我用错误代码更新了它。我不相信这就是它的全部内容,但在Agent2中。send,acreate缺少一个“e”。然后,您尝试发送事实(X,Y)试着给它另一个名字,然后在Agto1上接收它。@ JanithaMadushan:你找到了一个解决方案吗?如果是这样,为了服务他人,你会考虑把它作为答案吗?
// Agent agent2 in project IdEx.mas2j
/* Initial beliefs and rules */
/* Initial goals */
!begin.
/* Plans */
+!begin : true
<- .print("expert starting.......");
!giveme(X).
+!giveme(X):true
<- !fact(X,Y);
.print("Factorial of ", X, " is ", Y).
//.send(agent1,achive,fact(X,Y)).
+!fact(X,1) : X == 0.
+!fact(X,Y) : X > 0
<- !fact(X-1,Y1);
Y = Y1 * X.
[agent2] *** Error adding var into renamed vars. var=X, value=(_229-1).
java.lang.ClassCastException: jason.asSyntax.ArithExpr cannot be cast to jason.asSyntax.VarTerm
at jason.asSemantics.TransitionSystem.prepareBodyForEvent(TransitionSystem.java:877)
at jason.asSemantics.TransitionSystem.applyExecInt(TransitionSystem.java:728)
at jason.asSemantics.TransitionSystem.applySemanticRule(TransitionSystem.java:222)
at jason.asSemantics.TransitionSystem.reasoningCycle(TransitionSystem.java:1429)
at jason.infra.centralised.CentralisedAgArch.run(CentralisedAgArch.java:205)
at java.lang.Thread.run(Thread.java:745)
!start.
+!start : true
<- .print("starting..");
!query_factorial(2).
+!query_factorial(X) : true <-
.send(agent2,achieve,giveme(X)).
+!giveme(X):true
<- !fact(X,Y);
.print("Factorial of ", X, " is ", Y).
+!fact(X,1) : X == 0.
+!fact(X,Y) : X > 0
<- !fact(X-1,Y1);
Y = Y1 * X.