失败计划只能用于目标,在您的情况下,计划+i_can_enter... 对新信念而不是新目标做出反应。计划-i_can_enter.... 对删除这种信念作出反应。 (注意i_can_enter要小写,否则为变量)
有很多方法可以解决您的问题:
-
使用表演性的achieve 而不是tell,这样接收者就会有一个新的目标而不是一个新的信念。然后计划可能是+!i_can_enter(R) ...,计划失败是-!i_can_enter(R) ...。
-
将测试放在计划的上下文中:
+i_can_enter(R)[source(Ag)] : wedding_guests(R) <- .print(R,"You are on the guest list").
+i_can_enter(R) <- .print("You can not pass").
- 使用
askOne 表演。在接收器中:
+?can_enter(R,ok) : wedding_guests(R). // R can enter if it is a wedding guest
+?can_enter(R,nok). // R cannot otherwise
在发件人中:
.send(receiver_name, askOne, can_enter(john,_), can_enter(_,ok)); // only continue if answer is "ok"
或
.send(receiver_name, askOne, can_enter(john,_), can_enter(_,A));
.print("it is ",A," for john to enter");
.send 中的第四项与答案统一。