0
votes

hello in clips i have this template:

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

and this fact :

(start 1 1)

then i have this claus in the LHS :

?start<-(start ?x ?y)

and i want to get the variable ?a1

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

it seems that it's not allowed to add to the variable "(+ ?x 1)" so how can i achieve what i want.

1
By marking sections as code, using the "Code Sample" button, you can make your post more legible. - Cerin

1 Answers

1
votes
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>