计算剪辑规则右侧的现有事实
如何测试 Clips 中规则的 RHS 中是否存在事实?我正在努力 设计一个规则,通过计算存在多少个目标事实来对当前状态进行“评分”。很明显如何在 LHS 中测试事实,但我找不到如何在 RHS 中进行等效操作。
我想做这样的事情,尽管这不是有效的 Clips 代码:
(defrule score-state ""
?score <- (score (value ?value))
=>
(modify ?score (value (+ (exists (goal-1)) (exists (goal-2)) (exists (goal-3))))))
这样,如果没有任何目标状态存在,那么就会存在事实(分数(值 0))。相反,如果所有目标状态都存在,则事实(分数(值3))就会存在。
参考手册提到了函数fact-existp,但这似乎需要它传递一个事实地址。我尝试像 (fact-existp (goal-1)) 一样使用它,但 Clips 给了我一个语法错误。
How do you test for fact existence in the RHS of rules in Clips? I'm trying to
design a rule that will "score" the current state by counting how many goal facts exist. It's obvious how to test for facts in the LHS, but I can't find how to do the equivalent in the RHS.
I want to do something like this, albeit this isn't valid Clips code:
(defrule score-state ""
?score <- (score (value ?value))
=>
(modify ?score (value (+ (exists (goal-1)) (exists (goal-2)) (exists (goal-3))))))
So that if none of the goal states exist, then there would exist the fact (score (value 0)). Conversely, if all the goal states existed, then there would exist the fact (score (value 3)).
The reference manual mentions the function fact-existp, but this seems to require it's passed a fact address. I tried using it like (fact-existp (goal-1)), but Clips gives me a syntax error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)