CLIPS条件规则

时间:2016-11-22 09:50:38

标签: if-statement clips

如何在CLIPS中创建条件规则以查找输出

例如

(deftemplate holiday
(slot hotel (allowed-symbols nice good poor))
(slot weather (allowed-symbols sunny raining))
)
(deftemplate output
(slot option (allowed-symbols go plan stay))
)

这就是这个,我们如何创建像

这样的规则
if hotel = poor then stay
if hotel = poor and weather = raining then stay
if (hotel = poor and weather = sunny) or (hotel = good and weather = raining) then plan

由于

1 个答案:

答案 0 :(得分:1)

 (defrule hotel-rule1
       (holiday (hotel ?hotel&:(eq ?hotel poor)))
       =>
       (assert (output (option stay)))
    )

(defrule hotel-rule2
       (holiday (hotel ?hotel&:(eq ?hotel poor)) (weather ?weather&:(eq ?weather raining)))
       =>
       (assert (output (option stay)))
    )

我会拆分"或"最后一条规则在两个不同规则中的条件,类似于我写的例子。

再见 NIC