2

我想做以下事情:

我有一个将论点作为信念的初始目标,我想将其反转,以使信念的论点成为新的信念,而论点成为信念名称。

像这样的东西:

//Agent asker in project Test.mas2j
!translate(barks(dog)). //I would like to have the belief: dog(barks)
+!translate(T)<-
    T =.. [A,[B],C];
    .print("functor: ",A);
    .print("argument: ",B);
    //.print("source: ",C);
    +B(A);//<- I want something like this, but it gives a syntax error.
    +B. //<-this works, but it doesn't give the argument to it

所以,我的问题是,以这种方式来建立信仰有什么好处?

4

1 回答 1

3

像你一样构建术语T

...
X =.. [B,[A]]; // constructs the belief
+X; // adds the belief to the current belief base
...

使用 Jason 在 AgentSpeak 中编程多代理系统一书中

Prolog 中也可用的一个操作符在此处的工作方式略有不同(因为 Prolog 中没有谓词注释)是 '<code>=..',它用于将文字解构为列表。结果列表的格式[functor, list of arguments, list of annotations]为 ,例如: p(b,c)[a1,a2] =.. [p, [b,c], [a1,a2]]

于 2012-05-04T08:41:39.590 回答