I'm working on a Clips project. I am trying to firstly store facts (which is fine). Then I am trying to ask the user to provide details about the gems that are stored as facts, and based on their answer, to provide them with the correct name of the gem.
(deftemplate gem
(slot name)
(slot hardness)
(slot density)
(multislot colors))
(deffacts gems
(gem (name diamond) (hardness 10) (density 3.52) (colors yellow, brown, green, blue, white, colorless))
(gem (name corundum) (hardness 9) (density 4) (colors red, pink, yellow, brown, green, blue, violet, black, white, colorless))
(gem (name chrysoberyl) (hardness 8.5) (density 3.72) (colors yellow,brown,green))
(gem (name spinel) (hardness 8) (density 3.6) (colors red, pink, yellow, brown, green, blue, violet, white, colorless)))
(defrule reading-input
=>
(printout t "Enter the hardness of the gem: " )
(assert (var(read)))
(printout t "Enter the density of the gem: " )
(assert (var(read)))
(printout t "Enter the color of the gem: " )
(assert (var(read))))
(defrule checking-input
(var ?hardness)
(var ?density)
(var ?colors)
(gem (name ?name1) (hardness ?hardness1) (density ?density1) (colors $?colors1))
(test (= ?hardness ?hardness1))
(test (= ?hardness ?hardness1))
(test (member$ ?hardness ?hardness1))
=>
(printout t "Gem is " ?name1 crlf))
I am a beginner in CLIPS and cannot figure out how to get the above code to work right despite spending hours on it. Any help would be appreciated.Thank you.