I have a template called Person, and this template has eyes, hands, body, and alot of other slots. But each one of these slots are other templates.
So how can I define a slot for template of other template type??
And how to define the facts ??
Here is an example of what I main:
(deftemplate Eyes
(slot colorOfEye (type STRING))
(slot ShapeOfEye (type STRING)))
(deftemplate Person
(slot eye (type Eyes))
)
(deffacts People
(Person (eye ....))
)
(reset)
defining Person template is not working like this, and I don't know how to define the facts
Thanks
You have to define them both as separate templates. Then you can store either fact-id
or some other identifier for the "sub-fact" in the main fact, then join the main fact pattern with a "sub-fact" pattern using that value:
(defrule blue-eyed-person
(person (name ?name) (eyes ?eyes))
?eyes <- (eyes (color blue))
=>
(printout t ?name " has blue eyes." crlf))
Or alternatively
(defrule blue-eyed-person
(person (name ?name) (eyes ?eyes))
(eyes (id ?eyes) (color blue))
=>
(printout t ?name " has blue eyes." crlf))
To create the facts in the first place, you might say
(bind ?eyes (assert (eyes (color blue))))
(assert (person (name Fred) (eyes ?eyes)))