Jess - % equivalent operation

I am starting to learn Jess and I want to know if there is in Jess an equivalent operation to the % in Java? By the way, there is something in the internet that you recommend to learn it?For example:(bind ?z (Symbol 5 7))?z = 5(bind ?z (Symbol 49 7))?z = 0...Read more

Jess multislot questions

This is for a homework assignment, but I am having a really hard time finding good jess information on the web. I'm trying to use a multislot to to solve a problem, but I can't find anything on how to match the different values. I have this:(deftemplate patient (slot name)(multislot symptoms))(deffacts init (patient (name john) (symptoms very-high-fever cough)))How can I match the left hand side for just a very-high-fever? This works if I know that the very-high-fever is the first symptom, but I can't be sure of that, so I need to be able to ma...Read more

Jess: define a rule with "not" syntax

Jess somehow does not check for not existing facts. I want to define a rule like this:(defrule (not (fact)) => (assert (something)))But it does not seem to be possible, because this rule never becomes true, regardless if there is this fact in the working memory or not!(It does work without the (not ... ) and if this fact exists, of course!)...Read more

Jess pattern matching 'not' condition on rule

I'm playing on jess. I want to make rule that is not using '~'.Here is my code. (clear)(reset)(deftemplate person (slot name) (slot eyes) (slot hair))(defrule person-without-brown-hair (person (name ?name) (hair ?hair&:(not brown)))=> (printout t ?name " does not have brown hair." crlf))(assert (person (name "Jeon") (eyes green) (hair brown)))(assert (person (name "Park") (eyes blue) (hair red)))(run)What I expected was variable ?hair is not brown....Read more

A deftemplate code in Jess programing

I saw such code in a paper:(import com.psy.entity.Record) Can this statement import a Java class?(deftemplate Record(declare(from-class Record))) I don't understand this statement, how to use the declare statement, is there a function in Jess named from-class, I think I have never seen such function in the book of Jess in Action.(defrule show-test-result-20?0<-(Record {score<=30}))I think it's better to do this test by the test conditional element, is this code right?...Read more

Defglobal variable not working in my defrule in JESS

I have the following deffacts.(deffacts students (student-information (id-number 2014567) (course BSCS) (year 2) (semester 2) (subjects-taken CS111 Math103 Math101 Engl111n PE101)))(deffacts curriculum (prospectus-information (curriculum-name BSCS) (1st-year-1st-sem-subjects CS111 Bio101 Math103 Math101 Engl111n PE101))In this application, I ask the user for a student-id and if it does exists in my working memory, it acquires the student-id and binds its information in global variables suc...Read more

Tetris Rotation T piece Jess

I am making a tetris game in Jess language and I have made this algorithm to rotate the T piece.(defrule rotateTPiece?g<-(piece (id 4) (x1 ?x1) (y1 ?y1) (x2 ?x2) (y2 ?y2) (x3 ?x3) (y3 ?y3) (x4 ?x4) (y4 ?y4))=>(bind ?lowerx (min ?x1 ?x2 ?x3 ?x4))(bind ?lowery (min ?y1 ?y2 ?y3 ?y4))(modify ?g (x1 (- ?x1 ?lowerx)) (y1 (- ?y1 ?lowery)) (x2 (- ?x2 ?lowerx)) (y2 (- ?y2 ?lowery)) (x3 (- ?x3 ?lowerx)) (y3 (- ?y3 ?lowery))(x4 (- ?x4 ?lowerx)) (y4 (- ?y4 ?lowery))) (modify ?g (x1 ?y1) (y1 (- 1 (...Read more

How to sort people in JESS?

This is the code of my program to sort people gender wise and age wise. I am getting the output but not as expected. (deffacts initial-phase (phase choose-gender) (phase choose-age) (phase choose-name))(deffacts person (gender) (age) (name))(deffunction ask-start-again () (printout t "Enter another person? (y/n) ") (if (eq (read) y) then (assert (phase choose-gender) (phase choose-age) (phase choose-name))))(deffunction comparePerson(?pa ?pb $?comp) (if (< ((nth$ 1 $?comp) ?pa ?pb) 0) then (return -1)) (if (> ((nt...Read more

How to compare the ArrayList Object (java class) in JESS?

This is my main method.public static void main(String[] args) throws JessException { Rete engine = new Rete(); engine.batch("template.clp"); PizzaBase pizzaBase = new PizzaBase(); pizzaBase.setSize(9); PizzaTopping pizzaTopping = new PizzaTopping(); pizzaTopping.setName("T1"); PizzaTopping pizzaTopping2 = new PizzaTopping(); pizzaTopping2.setName("T2"); PizzaTopping pizzaTopping3 = new PizzaTopping(); pizzaTopping3.setName("T3"); List<PizzaTopping> pizzaToppingList = new ArrayList<PizzaTopping>(); ...Read more

jess multislot value matching ignoring the order

I am trying to check if there already exists the same instance or not.(defemplate justificand (slot consq) (multislot antes))(assert (justificand (consq s) (antes p q r))) ;;; order p q r(defrule test (exists (justificand (consq s) (antes q p r))) ;;; order q p r => (printout t "matching success " crlf))In my case, I assert a justificand with (antes p q r) but the order of p, q and ris not important. So, test rule need to succeed even if it test with (antes q p r).But, jess seems to consider order of multislot values for matching.Any ...Read more

jess - JessRules - Iteration over an ArrayList

there is my dilemna : (defrule A15_test ?list <- (accumulate (bind ?ll (new java.util.ArrayList)) ;; initializer (?ll add ?id) ;; action ?ll ;; result (P (ID_Jess ?id) (m ?ref&:(neq ?ref nil))) ) ;; CE (foreach ?l ?list (printout t "l:" ?l " " crlf) ) => (printout t "FIRE ! c:" (?list toString) " end. " crlf)Which gives the following error :Jess reported an error in routine Jesp....Read more