Good evening, i have problem with solving Hanoi towers in CLIPS i tried to help myself with AI but its not helping this is the code i wrote :
(deffunction make-game ()
(make-instance 'game (make-list 3)))
(defrule init-game
(not (game))
=>
(make-game))
(defrule move-ring
(game (towers (member $t1 $towers))
(tower $t1 (rings $r1 $r2 $r3))
(tower (member $t2 $towers) (rings))
(tower (member $t3 $towers) (rings))
(test (not (eq $r1 $r2))
(not (eq $r1 $r3))
(not (eq $r2 $r3)))
=>
(modify-tower $t1 (remove $r1))
(modify-tower $t2 (append $r1))
(print-game))
(defrule print-game
(game (towers (list $t1 $t2 $t3)))
=>
(print "Tower 1: " (tower-rings $t1))
(print "Tower 2: " (tower-rings $t2))
(print "Tower 3: " (tower-rings $t3)))
its not working i have errors everywhere i dont understand CLIPS well, i need to use facts, rules etc to make this logical game to work... Thank you very much for your help!
I tried AI, nothing works i need fully functioned game of Hanoi Towers thanks!