Thanks so much, it worked fine and helped me find cousins, aunts and uncles
too. Now the only issue is that when i test straight from the terminal it
works fine, but when i try to do a (batch FILEPATH) it throws me an error
like this. I read somewhere that it may be due to me using OSX.

Jess> (batch
"/Users/abritez/Documents/__school/NewApproachesToDigitalLearning/Jess/alexFamily.clp")
Jess reported an error in routine Tokenizer.nextToken
        while executing (batch
"/Users/abritez/Documents/__school/NewApproachesToDigitalLearning/Jess/alexFamily.clp").
  Message: I/O Exception.
  Program text: ( batch
"/Users/abritez/Documents/__school/NewApproachesToDigitalLearning/Jess/alexFamily.clp"
)  at line 6087.
Nested exception is:
Pushback buffer overflow
java.io.IOException: Pushback buffer overflow
        at java.io.PushbackReader.unread(PushbackReader.java:136)
        at jess.ce.if(Unknown Source)
        at jess.n.for(Unknown Source)
        at jess.n.do(Unknown Source)
        at jess.Jesp.for(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Batch.batch(Unknown Source)
        at jess.Batch.call(Unknown Source)
        at jess.ep.a(Unknown Source)
        at jess.Funcall.execute(Unknown Source)
        at jess.Jesp.a(Unknown Source)
        at jess.Jesp.for(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Jesp.parse(Unknown Source)
        at jess.Main.execute(Unknown Source)
        at jess.Main.main(Unknown Source)

;;;*******************************************************************



Here is my code as it stands now:


;;;*******************************************************************
;;;*************
;;;* TEMPLATES *
;;;*************
(deftemplate member (slot child)(slot mother)(slot father)(slot gender))
;;;*****************
;;;* INITIAL STATE *
;;;*****************
(deffacts family
(member (child Alex)(mother Carmen)(father Miguel)(gender Male))
(member (child Loren)(mother Carmen)(father Miguel)(gender Female))
(member (child Carmen)(mother Rosa)(father Jorge)(gender Female))
(member (child Amanda)(mother Rosa)(father Jorge)(gender Female))
(member (child Alexandra)(mother Amanda)(father Juan)(gender Female))
(member (child Rosita)(mother Rosa)(father Jorge)(gender Female))
(member (child Eilien)(mother Rosaita)(father Luis)(gender Female))
(member (child Eddie)(mother Rosaita)(father Luis)(gender Female))
(member (child Dalila)(mother Rosa)(father Jorge)(gender Female))
(member (child Alexis)(mother Dalila)(father Alberto)(gender Female))
(member (child Carlos)(mother Dalila)(father Alberto)(gender Female))
(member (child Goerge)(mother Dalila)(father Alberto)(gender Female))
(member (child Sandra)(mother Dalila)(father Alberto)(gender Female))
(member (child Miguel)(mother Josefina)(father Octavio)(gender Male))
(member (child Elsa)(mother Josefina)(father Octavio)(gender Female))
(member (child "Luis Veron")(mother Elsa)(father Pete)(gender Female))
(member (child Marcie)(mother Elsa)(father Pete)(gender Female))
(member (child Raquel)(mother Elsa)(father Pete)(gender Female))
(member (child Patty)(mother Elsa)(father Pete)(gender Female))
(member (child Gabby)(mother Elsa)(father Pete)(gender Female))
(member (child Elba)(mother Josefina)(father Octavio)(gender Female))
(member (child Gustavo)(mother Elba)(father Jose)(gender Female))
(member (child Osvaldo)(mother Elba)(father Jose)(gender Female))
)
;;;******************
;;;* FUNCTIONS *
;;;******************
(deffunction select-relation (?gender ?relation)
;;;CHECK IS BROTHER/SISTER
(if (eq ?gender Female)
        then
        ;;;THESE ARE FEMALES
        (if (eq ?relation "sibling")
                then
        (return "sister"))
        (if (eq ?relation "auntUncle")
                then
        (return "aunt"))


else
        ;;;THESE ARE MALES
        (if (eq ?relation "sibling")
                then
        (return "brother"))

        (if (eq ?relation "auntUncle")
                then
        (return "uncle"))

))

;;;******************
;;;* RULES *
;;;******************
;;;;;Find a child's mom
(defrule find_mom
(declare (salience 50))
(member (mother ?mom) (child ?child))
(ask ?child)
=>
(printout t ?child "'s mom is " ?mom crlf))
;;;;;Find a child's dad
(defrule find_dad
(declare (salience 40))
(member (father ?dad) (child ?child))
(ask ?child)
=>
(printout t ?child "'s dad is " ?dad crlf))
;;;;;Find a child's sibling (brother/sister)
(defrule find_sibling
(declare (salience 30))
(member (father ?dad) (child ?sibling))
(member (father ?dad) (child ?child))
(member (gender ?gender) (child ?sibling))
(ask ?child)
(ask ~?sibling)
=>
(printout t ?child "'s " (select-relation ?gender "sibling") " is "?sibling
crlf))

;;;;;Find a child's grandparents
(defrule find_grandparent
    (declare (salience 20))
    (ask ?child)
    (member (father ?dad) (mother ?mom) (child ?child))
    (or (member (child ?dad) (mother ?gmom) (father ?gdad))
          (member (child ?mom) (mother ?gmom) (father ?gdad)))
    =>
        (printout t ?child "'s " "Grandmother is " ?gmom crlf ?child "'s
Grandfather is " ?gdad crlf))

;;;;;Find a child's (uncle/aunt)
(defrule find_uncle_aunt
        (declare (salience 10))
        (ask ?child)
        (member (father ?dad) (mother ?mom) (child ?child))
        (or (member (child ?dad) (mother ?gmom) (father ?gdad))
                (member (child ?mom) (mother ?gmom) (father ?gdad)))
        (member (mother ?gmom)(child ?aunt)(child ~?dad)(child ~?mom)(gender
?gender))

    =>
        (printout t ?child "'s " (select-relation ?gender "auntUncle") " is "
?aunt  crlf))

;;;;;Find a child's (uncle/aunt)
(defrule find_cusins
        (declare (salience 5))
        (ask ?child)
        (member (father ?dad) (mother ?mom) (child ?child))
        (or (member (child ?dad) (mother ?gmom) (father ?gdad))
                (member (child ?mom) (mother ?gmom) (father ?gdad)))
        (member (mother ?gmom)(child ?aunt)(child ~?dad)(child ~?mom)(gender
?gender))
        (member (mother ?aunt)(child ?cousin))

    =>
        (printout t ?child "'s cousin is " ?cousin  crlf))

;;;;;List children
(defrule listChild
      (member (child ?y))
      (ask list)

 =>
      (printout t ?y ", ")
)
;;;;;;prompt user for questions. This rule fires first.
(defrule askQuestions
=>
(printout t crlf "*****************************************"crlf
"Type a child's name in quotes and I will tell you the name of the child's
parents, grandparents, uncle/aunt, cousins, and sibblings.  To view a child
list type in the command 'list'." crlf )
(assert (ask (read)))
)
;;;;;; Initialize working memory (facts)
;;;;;; Note: function (read) will be replaced with user input in the command
console.
(reset)
(run)
--
View this message in context: 
http://www.nabble.com/Newbie-question-tp15518587p15548567.html
Sent from the Jess mailing list archive at Nabble.com.

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to