Hello to all!
I've been parusing this site for awhile now, must say that its very helpful for tips and learning about coding in general.
Anyways, here is my first foray into posting and of course, it begins with a question.
I have to emulate a blood bank in Jess and i'm running into some problems with the output. Here's what I have so far:
(deftemplate person "the person template"
(slot name)
(slot blood)
)
(deftemplate blood "the blood type template"
(slot kind)
(slot is-compatible-with)
(slot not-compatible)
)
(deffacts blood-bank-clients
(person (name John)(blood O))
(person (name Paul)(blood A))
(person (name George)(blood B))
(person (name Ringo)(blood AB))
(blood (kind O) (is-compatible-with O)
(kind O)(not-compatible A)
(kind O)(not-compatible B)
(kind O)(not-compatible AB) )
(blood (kind A) (is-compatible-with O)
(kind O)(is-compatible-with A)
(kind A)(not-compatible B)
(kind A)(not-compatible AB) )
(blood (kind B) (is-compatible-with O)
(kind B)(is-compatible-with B)
(kind B)(not-compatible A)
(kind B)(not-compatible AB) )
(blood (kind AB) (is-compatible-with O)
(kind AB)(is-compatible-with A)
(kind AB)(is-compatible-with B)
(kind AB)(is-compatible-with AB) )
)
(defrule compatible
(person (name ?person1) (blood ?kind1))
(person (name ?person2) (blood ?kind2))
(blood (kind ?kind1) (is-compatible-with ?kind2))
=>
(assert (compatible ?person1 ?person2))
)
(defrule match
(compatible ?person1 ?person2)
(compatible ?person2 ?person1)
(test (neq ?person1 ?person2))
=>
(printout t " is compatible with " ?person1 " to " ?person2 crlf)
)
I'm having major problems understanding what's going on because our professor's material on Jess is quite sparse and useless. I can get the facts to load properly, but for some reason it's not printing out who is compatible with who based on blood type.
Any help would be great!
- Indy