As I continue to learn on how to use CLIPS, I found an improvement to the terminating condition for the knights tour from the previous post by using the halt statement. Replace the terminating condition with the code as follows:
;; Terminating condition
(defrule goal-rule
?init <- (square-is 2)
=>
(printout t “Reached the goal square.” crlf)
(halt))
The execution is the same:
CLIPS> (run)
Firing rule 1.
New square is 8.
Firing rule 13.
New square is 3.
Firing rule 5.
New square is 4.
Firing rule 7.
New square is 9.
Firing rule 15.
New square is 2.
Reached the goal square.
Advertisement