我正在使用 Jason 语言在两个代理之间进行通信。但我无法使用发送操作,它给出了一个错误。
这是我的两个经纪人
代理1:-
// 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").*/
特工2:-
// 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.
因此,当我尝试在 agent1 中调用发送操作时出现错误,而 agent2 给出了接收错误。
更新
我收到此错误,
[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)