2010-05-09 58 views
0

你好,我有这样的模板:剪辑匹配的表情不是剪辑工作

(deftemplate cell(slot x)(slot y)(slot alive)) 

和这样一个事实:

(start 1 1) 

然后我有这个圣诞老人的LHS:

?start<-(start ?x ?y) 

,我想获得变量?a1

(cell (x (+ ?x 1))(y ?y)(alive ?a1)) 

它似乎不允许添加到变量"(+ ?x 1)"那么如何 我可以达到我想要的。

+2

通过使用“代码示例”按钮将代码段标记为代码,可以使您的文章更清晰易读。 – Cerin 2010-07-06 21:30:45

回答

1
CLIPS> (deftemplate cell (slot x) (slot y) (slot alive)) 
CLIPS> 
(deffacts initial 
    (start 1 1) 
    (cell (x 2) (y 1) (alive yes))) 
CLIPS>  
(defrule example 
    (start ?x ?y) 
    (cell (x =(+ ?x 1)) (y ?y) (alive ?a1)) 
    => 
    (printout t "?a1 = " ?a1 crlf)) 
CLIPS> (reset) 
CLIPS> (run) 
?a1 = yes 
CLIPS>