【发布时间】:2017-10-20 11:15:35
【问题描述】:
(deftemplate bikelife
(slot name)
(slot type))
(deffacts bike
(bikelife (name Strida) (type low_lifestyle))
(bikelife (name Brompton) (type med_lifestyle))
(bikelife (name Molton) (type high_lifestyle))
(bikelife (name Specialized_AlleComp) (type low_sport))
(bikelife (name Specialized_Tarmac) (type medium_sport))
(bikelife (name Pinarello_DOGMA_F8) (type high_sport)))
(defrule rule-1
(budget ?x)
(test (< ?x 300))
(use_for lifestyle)
=>
(assert (recommend low_lifestyle)))
(defrule rule-2
(budget ?x)
(test (< ?x 300))
(use_for sport)
=>
(assert (recommend low_sport)))
(defrule rule-3
(budget ?x)
(test (and (> ?x 300) (< ?x <500)))
(use_for lifestyle)
=>
(assert (recommend med_lifestyle)))
(defrule rule-4
(budget ?x)
(test (and (> ?x 300) (< ?x <500)))
(use_for sport)
=>
(assert (recommend med_sport)))
(defrule rule-5
(budget ?x)
(test (> ?x 500))
(use_for lifestyle)
=>
(assert (recommend high_lifestyle)))
(defrule rule-6
(budget ?x)
(test (and (> ?x 300) (< ?x <500)))
(use_for sport)
=>
(assert (recommend med_sport)))
(defrule rule-7
(budget ?x)
(test (> ?x 500))
(use_for sport)
=>
(assert (recommend high_sport)))
(defrule recommend-rule
(recommend ?type)
(bikelife (name ?x) (type ?type))
=>
(printout t crlf "I recommend " ?x " for you." crlf crlf))
(defrule ask-1
=>
(printout t crlf "================================ ")
(printout t crlf " testing testing testing. ")
(printout t crlf "================================ " crlf crlf)
(printout t "* How much are you going to spend on bike? ")
(assert (budget (read)))
(printout t "* what purpose? ( lifestyle, sport )")
(assert (use_for (read))))
(reset)
(run)
这是我推荐自行车的 Jess 代码。我在代码中没有看到任何错误。我已经尝试了数百次并来到 Stack Overflow 获取一些 帮忙看看。
代码在我获得预算值并通过 300、500 评估时运行,如果预算范围匹配,我会检查用户购买自行车的用途。之后使用事实我想发送推荐消息。我该如何解决这个问题?
【问题讨论】:
-
修正您的拼写错误:
tyle,user_for。 -
啊.. 这就是问题所在.. 很抱歉在 StackOverflow 上发布一个愚蠢的问题。我曾经想过如果我设置“test(
-
您有更多错别字:med_ 还是 medium?还有一个“中等运动”的重复规则。还有几个
<500。
标签: jess