Hello again!

Suppose I have the following rule:

(defrule rule-eat
        ?f <- (hungry (starveling ?starveling))
        (test (me ?starveling))
        (have (owner ?starveling) (possession_type ?*food*) (possession
?possession))
        =>
        (printout t "I am eating a " ?possession crlf)
        (retract ?f)
)

The second fact in the LHS (test (me ?starveling)) is just the call to a
function that determines if the agent that owns this knowledge base is the
starveling in question. My problem however concerns the third fact in the
LHS: (have (owner ?starveling) (possession_type ?*food*) (possession
?possession))

This is a backward-chaining definstance fact. ?*food* is a defglobal that
contains the Java class Food. I use this construction to indicate that the
starveling is happy with any kind of food and not just a specific object
(possession_type contains the class of possession). The point is, that Food
is a superclass of many different kinds of food. For example the class Apple
(contained in a defglobal ?*apple*) is a subclass of Food. How can I cause
rule-eat to fire when I have a fact (have (owner ?starveling)
(possession_type ?*apple*) (possession ?possession)) present in the
knowledge base?

Of course I could do the following:

(defrule rule-eat
        ?f <- (hungry (starveling ?starveling))
        (test (me ?starveling))
        (have (owner ?starveling) (possession_type ?pt) (possession ?possession))
        (test (is-a ?pt ?*food*))
        => ...
)

in which is-a is a function that determines whether ?pt is a subclass of
?*food*. But then the back-chaining mechanism asserts a need-have fact
without the notion that the need concerns food.

Bye,
Sander


--------------------------------------------------------------------
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