JESS: Ignore slots when matching lhs of rules

"Hunter McMillen" <[email protected]> Thu, 10 Nov 2011 22:57:08 -0500
Newsgroups gmane.comp.java.jess
Message-ID <CABWUPR2zLFJEQPowb-7LZKntQ6=aC4128SPjb6Cx62E2Cu1e6g@mail.gmail.com>
Hi everyone,

 I am trying to match the lhs of a rule using a template that has 112 slots
that is defined from a Java class.

 Here is the template definition (from show-deftemplates):

 (deftemplate MAIN::unit
            "$JAVA-OBJECT$ eisbot.proxy.model.Unit"
            (declare (from-class eisbot.proxy.model.Unit)))

Now every time that I encounter a unit object in my application I define an
instance of the unit to Jess from Java:

engine.defclass("unit", "eisbot.proxy.model.Unit", null, true); (I only do
this the first time)

Unit unit = //retrieve a unit
engine.definstance("unit", unit, false);

All of this above is working as it should be, but now when I try to match a
unit in a rule I am having trouble:

String unitSeen = "(defrule unitSeen " +
                          "(unit (ID ?id) (typeID ?typeID)) " +
                          "=> " +
                          "(printout t \"Unit seen with ID: \" ?id crlf))";

engine.executeCommand(unitSeen);

The problem is that the Unit class has 112 attributes, I am only listing
two ID and typeID, and there are probably only another handful that I care
about and need to use. Is there any way to ignore the rest of the slots in
the template, matching only on a few slots?

Goal:

The main goal of what I am trying to is that when I encounter a Unit in my
game application, I want to assert that unit object to Jess as a fact, then
match rules on the existence of a Unit. Right now I only want to match on
the existence of ANY unit, but later on the matches will be more specific.

Any help would be most appreciated.

Thanks.
Hunter McMillen