Hi,

I'm new to Jess & expert systems as well. I'm basing my code on the Pump/Tank example provided. Basically the goal of the experiment is: offer a first-time promotion to a first-time user, else offer an ongoing promotion.

The UserBean has some promotion properties (counter,name,value) that are set if the rule fires. I am assuming that when the RHS of the rule is evaluated, the code in the RHS will set the bean properties appropriately.

However, the following code (in a .clp file) loops infinitely. Why?

(defclass UserBean test.ruleEngine.UserBean )

(defrule qualify-for-first
(UserBean (name ?name) (promoCounter ?counter) (promoValue ?value) (promoName ?pName) (OBJECT ?user))
    (test (= ?counter 0))
    =>
    (printout t "User " ?name " has qualified for a first time promotion of $10.00! " crlf)   
    (printout t "increased promotion counter to " (get ?user promoCounter) crlf
                "before promoName is " (get ?user promoName) crlf
                "before promoValue is " (get ?user promoValue) crlf)
    (set ?user promoCounter (+ ?counter 1))
    (set ?user promoName "First Time Promotion")
    (set ?user promoValue 10.00)
    (printout t "increased promotion counter to " (get ?user promoCounter) crlf
                "now promoName is " (get ?user promoName) crlf
                "now promoValue is " (get ?user promoValue) crlf)
    )

 



Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!

Reply via email to