我想执行以下操作:
我有一个最初的目标,将论证作为信念,我想扭转它,使信念的论证成为新的信念,论证成为信念名称。
类似这样的事情:
//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
所以,我的问题是,愿意以这种方式构建信念吗?
最佳答案
像 T
一样构造术语:
...
X =.. [B,[A]]; // constructs the belief
+X; // adds the belief to the current belief base
...
摘自本书Programming Multi-Agent Systems in AgentSpeak using Jason :
One operator also available in Prolog that works slightly differently here (because of the predicate annotations not available in Prolog) is ‘
=..
’, which is used to deconstruct a literal into a list. The resulting list has the format[functor, list of arguments, list of annotations]
, for example:p(b,c)[a1,a2] =.. [p, [b,c], [a1,a2]]
.
关于prolog - 如何扭转或构建对杰森(特工的话)的信念?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10445273/