0
votes

I'm in the process of designing an expert system from a decision tree and one of the tests is to check the wildlife score. The user is asked to enter the wildlife score and 3 possible outcomes are decided.

A score of at least 20 rejects the proposal and ends the program.

A score of more than 10 but less than 20 moves on to test 4 but asserts the outcome will be second-best.

A score of no more than 10 simply moves to test 4.

The read line from the previous test:

(defrule wildlife-score(or(energy-level 2)(energy-level 3))
=> (printout t "What is the wildlife impact score?" crlf)
(assert(wildlife-impact(read))))

The following is where I am having trouble in comparing the read value to the outcome values. Any help would be appreciated.

(defrule reject-wildlife
(wildlife-impact  ? (> ?wildlife-impact 20))
=> (assert(reject))
(printout t "Reject - completely unsuitable due to wildlife impact." crlf))
1

1 Answers

0
votes

The correct syntax for your comparison is (wildlife-impact ?varname&:(> ?varname 20)).

 (defrule reject-wildlife 
  (wildlife-impact ?score&:(> ?score 20)) 
 =>  
  (assert (reject)) 
  (printout t "Reject - completely unsuitable due to wildlife impact." crlf))