Hello!
I firstly want to thank for your answer (Potton's weight formula).
I alter solution written in Prolog, that is:

 

domains
 Type, Colour = String
 Age, Course, Price = Integer
predicates
 nondeterm offer(Type, Course, Age, Price, Colour)
goal
 ofer(Mark,Course,Age, Price,Colour), Age<=3. 
clauses
 offer("VW Golf", 125000, 11, 4400,"red").
 offer("Skoda Favorit", 35000, 2, 2000,"gray").
 offer("Fiat Uno", 45000, 3, 3500,"blue").
 offer("Fiat 126p", 23000, 4, 1500,"pink").
 offer("Mercedes 190D", 135200, 9, 28000,"black").
 offer("Mazda", 105000, 9, 5000,"red").

 

It's about, in order from base (offerts) to choose these, which age is
smaller or even than 3 years.
And to printout them on screen. I tried to make this on several ways, but no
turned out effective.
Below I introduce my tests:

 

;(deftemplate offer
; (slot mark
;  (type STRING)
;  (default " "))
; (slot course
;  (type INTEGER)
;  (default " "))
; (slot age
;  (type INTEGER)
;  (default " "))
; (slot price
;  (type INTEGER)
;  (default " "))
; (slot colour
;  (type STRING)
;  (default " ")))
;

(defrule choose-car
 (offer(mark ?m) (course ?c) (age ?a) (price ?p) (colour ?c))
 (<= ?a 3)
 (printout t ?m crlf))

(deffacts offer
 (mark VW_Golf) (course 125000) (age 3) (price 4400) (colour red))
; ((mark Skoda_Favorit) (course 35000) (age 2) (price 2000) (colour grey))
; ((mark Fiat_Uno) (course 23000) (age 3) (price 3500) (colour blue))
; ((mark Fiat_126p) (course 23000) (age 4) (price 1500) (colour pink))
; ((mark Mercedes_190D) (course 135200) (age 9) (price 28000) (colour
black))
; ((mark Mazda) (course 105000) (age 9) (price 5000) (colour red)))

 

I got muddled up in this (i know the presented version is incorrect). I
tried with deftemplate,
but it was no change (JESS reports errors every time).

I've got another question: how to pick up from offer these one which are
named, for example:
"VW Golf" (the space between "VW" and "Golf), i mean how JESS can
distinguish it in facts?
Do I have to use deftemplate in this solution (STRING, INTEGER, ATOM?)?

 

I send greetings from Poland :)

Reply via email to