PDA

View Full Version : CLIPS Rule Based Expert Systems




abijnk
Feb 18, 2008, 01:39 PM
Does anyone have any experience with writing expert systems in CLIPS? I have to do an assignment to solve the Towers of Hanoi (http://www.cut-the-knot.org/recurrence/hanoi.shtml) problem using CLIPS, but I don't know how to handle the fact that the solution is recursive...

Anyone have some advice?

Thanks



zor724
Apr 29, 2009, 05:20 PM
; Towers of Hanoi in CLIPS
(defrule move-disk
?old-list <- (goals disk ?number ?from ?to $?rest)
=>
(retract ?old-list)
; (printout t "move disk from " ?from " to " ?to crlf)
(assert (goals ?rest)))

(defrule move-single-disk-tower

?old-list <- (goals tower 1 ?from ?to $?rest)
=>
(retract ?old-list)
(assert (goals disk 1 ?from ?to ?rest)))

(defrule move-tower
?old-list <- (goals tower ?number&1 ?from ?to $?rest)
=>
(retract ?old-list)
(assert (goals tower =(- ?number 1) ?from =(- 7 ?from ?to)
tower 1 ?from ?to
tower =(- ?number 1) =(- 7 ?from ?to) ?to ?rest)))

(defrule completed
?old-list <- (goals done)
=>
(retract ?old-list))