I am new to JESS. I want to have a fact which contains a boolean value in
one of its slots. However, I am unsure of the best way to pass this to JESS
and use this slot value in a defrule. I have tried the following:

  public static final String LOCATION_IN_AOI_TEMPLATE_NAME =
"Location-In-AOI";
  public static final String FACTION_IDU_SLOT = "Unit-faction";
  public static final String IS_DETONATION_SLOT = "is-Detonation";

      //Create a Location Fact
      Fact f = new Fact(LOCATION_IN_AOI_TEMPLATE_NAME, RuleBase.getRete());
      //Set the slot value from isDetonation boolean value
      f.setSlotValue(IS_DETONATION_SLOT,
        new jess.Value(new Boolean(isDetonation)));
      //Set the slot value for the unit's faction
      f.setSlotValue(FACTION_IDU_SLOT,
        new jess.Value(factionIdu, jess.RU.STRING));
      //Assert the Location Fact
      newFactId = RuleBase.instance().getRete().assert(f);

  private static final String DEFRULE_ID_ENGAGE_AT_TAI_TRIGGER =
    "(defrule IdEngageAtTai-Trigger" +
    "  (" + UnitLocationMonitor.LOCATION_IN_AOI_TEMPLATE_NAME + "  " +
    "     (" + UnitLocationMonitor.IS_DETONATION_SLOT + " ?is-boom)" +
    "     (" + UnitLocationMonitor.FACTION_IDU_SLOT + " ?faction))" +
    "  (  TAI-Location-Filter" +
    "     (Enemy-factions $?factions&:" +
    "        (or (eval ?is-boom)" +
    "         (member$ ?faction $?factions))))" +
    "=>" +
    " (printout t \"triggered faction=\" ?faction \";\" (eval ?is-boom)
crlf)"
    ")";

Not shown is my code for the deftemplates and the 2nd fact, but that appears
to work fine.
My problem is that the above rule seems to always fire, even when "?is-boom"
is false (and the printout in the RHS prints it as false), even if the
"?faction" is not is the list of "enemy-factions".
If I remove the "?is-boom" check altogether, then the faction check works as
I expect. I would also like to add a check using "NOT", but this rule never
fires:

    "     (Friendly-factions $?frdlyfactions&:" +
    "        (or (not (eval ?is-boom))" +
    "         (member$ ?faction $?frdlyfactions))))"

I know that I could probably just match string values for the "is-boom" slot
value, i.e., "YES" and "NO", but I am wondering
if there is a way to do this with boolean slot values. I suspect my problem
may be with the "eval" function or the way I am setting the slot value
(somehow pass a boolean as a jess.RU.ATOM?). Thanks.

-Steve




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