i am doing a Vehicle diagnosis expert system based on link. I have managed to run my system and runs successfully but at the end it displays "Fact-x"(X being the facts number). Here's a Decision Tree and code for reference:
;; initialize
(deffacts init (start))
;;Main Menu
(defrule Menu
?ml <- (start)
=>
(printout t crlf crlf crlf
"Choose one of the problem areas listed below" crlf crlf
" 1- Brake Pedal System. "crlf crlf
" 2- Gearbox. "crlf crlf
" 3- ." crlf crlf
" 4- END SYSTEM. "crlf crlf crlf
" Enter no. of your choice: ")
(bind ?response (read))
(switch ?response
(case 1 then (assert (type 0-1)))
(case 2 then (assert (type 0-2)))
(case 3 then (assert (type 0-3)))
(case 4 then (assert (type quit))))
(printout t crlf)
(retract ?ml)))
;; submenu1
(defrule subMenu1
?ml <- (type 0-1)
=>
(printout t crlf crlf crlf
"Choose which topic best relates to your problem? "crlf crlf
" 1-1 Car Pulls One Side When Braking. "crlf crlf
" 1-2 Rear Brake Drag. "crlf crlf
" 1-3 Brake squeal. "crlf crlf
" 1-4 END SYSTEM. "crlf crlf crlf
" Enter no. of your choice: ")
(bind ?response (read))
(switch ?response
(case 1-1 then (assert (type 1-1)))
(case 1-2 then (assert (type 1-2)))
(case 1-3 then (assert (type 1-3)))
(case 1-4 then (assert (type quit))))
(printout t crlf)
(retract ?ml)))
;; END System
(defrule user-quits
(type quit)
=>
(printout t "You have EXIT the System." crlf)
(halt))
;; Rule 1 based on choice 1-1
(defrule car_pulls_one_side_when_braking
?ml <- (type 1-1)
=>
(printout t crlf crlf crlf
" Was your tyre uneven? (yes|no) "crlf crlf
" Your answer: ")
(assert (ifYesNochoice (read))))
(printout t crlf)
(retract ?ml)))
;;Rule 2 based on Yes answer in Rule 1
(defrule car_pulls_one_side_when_braking1
?ml <- (ifYesNochoice yes)
=>
(printout t crlf crlf crlf
" Please check your tyre pressure "crlf crlf
" Is it in good condition? (yes|no) "crlf crlf
" Your answer: "
(assert (ifYesNochoice1 (read)))))
(printout t crlf)
(retract ?ml)))
;;Rule 3 based on Yes answer in Rule 2
(defrule car_pulls_one_side_when_braking2
?ml <- (ifYesNochoice1 yes)
=>
(printout t crlf crlf crlf
" Then your car should be no problem. " crlf crlf
" Thanks for using Vehicle Diagnosis Failure System. " crlf crlf))
(printout t crlf)
(retract ?ml)
(halt)))
;; Rule 4 based on NO answer in Rule 2
(defrule car_pulls_one_side_when_braking3
?ml <- (ifYesNochoice1 no)
=>
(printout t crlf crlf crlf
" Please inflate all the tyres according to the tyre plycard. "crlf crlf
" Please check again with your technician if problem is solved. "crlf crlf
" Thanks for using Vehicle Diagnosis Failure System. "crlf crlf))
(printout t crlf)
(retract ?ml)
(halt)))
;; Rule 5 based on NO answer in Rule 1
(defrule car_pulls_one_side_when_braking4
?ml <- (ifYesNochoice no)
=>
(printout t crlf crlf crlf
" Do you feel a stuck calliper? (yes|no) "crlf crlf
" Your answer: ")
(assert (ifYesNochoice2 (read))))
(printout t crlf)
(retract ?ml)))
;; Rule 6 based on NO answer to Rule 5
(defrule car_pulls_one_side_when_braking5
?ml <- (ifYesNochoice2 no)
=>
(assert (type1-1))
(printout t crlf)
(retract ?ml))
;; Rule 7 based on yes answer in Rule 6
(defrule car_pulls_one_side_when_braking6
?ml <- (ifYesNochoice2 yes)
=>
(printout t crlf crlf crlf
" Did you service your brake calliper? (yes|no) "crlf crlf
" Your answer: ")
(assert (ifYesNochoice3 (read))))
(printout t crlf)
(retract ?ml)))
My question is as follows:
1) How do i NOT display the facts-X after the system is run. The results shown are like these: (Note the Fact-X)
2) If i want to do a looping for my question based on NO for Rule 1 in choice 1-1. (e.g when NO is fired for Rule 1, it jumps to next problem(Rule 6) as shown in decision tree. However when No is fired for Rule 6, it does not jumps back to Rule 1.) How do I loop them?