2016-12-05 11 views
0

Я пытаюсь создать экспертную систему диагностики. Мне удалось создать меню и подменю, но после ввода моего выбора (например, 1). Вопрос, который должен быть задан после подменю, не появляется. Следовательно, не в состоянии продолжать. Я хотел бы спросить, есть ли что-то не так с тем, что я сделал? Если есть, каков правильный способ сделать это?CLIPS: Не удается продолжить после ввода выбора

Вот часть кода для справки:

CLIPS> ;; MainMenu 
    (defrule Menu 
    (not (iffoundChoice ?)) 
=> 
    (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: ") 
    (assert (iffoundChoice (read)))) 

CLIPS> ;; submenu1 
(defrule subMenu1 
    (not (iffoundChoice1 ?)) 
    => 
    (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 
    " 4.) END SYSTEM. "crlf crlf crlf 
    " Enter no. of your choice: ") 
    (assert (iffoundChoice1 (read)))) 

    CLIPS> ;; Rule 1 based on choice 1 

(defrule car_pulls_one_side_when_braking 

    (iffoundChoice1) 
    ?retractCh1 <- (iffoundChoice1) 
    (not (ifYesNochoice ?)) 
    => 
    (retract ?retractCh1) 
    (printout t crlf crlf crlf 
    " Was your tyre uneven? (yes|no) "crlf crlf 
    " Your answer: ") 
    (assert (ifYesNochoice (read)))) 

    CLIPS> ;;Rule 2 based on Yes answer in Rule 1 

    (defrule car_pulls_one_side_when_braking1 

    (ifYesNochoice yes) 
    ?retractChy <- (ifYesNochoice yes) 
    (not (ifYesNochoice1 ?)) 
    => 
    (retract ?retractChy) 
    (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))))) 

    CLIPS> ;;Rule 3 based on Yes answer in Rule 2 

    (defrule car_pulls_one_side_when_braking2 

    (ifYesNochoice1 yes) 
    ?retract <- (ifYesNochoice1) 
    (not (ifYesNochoise2 ?)) 
    => 
    (retract ?retract Chy) 
    (printout t crlf crlf crlf 
    " Then your car should be no problem. " crlf crlf 
    " Thanks for using Vehicle Diagnosis Failure System. " crlf crlf)) 

    CLIPS> ;; Rule 4 based on NO answer in Rule 2 

    (defrule car_pulls_one_side_when_braking3 

    (ifYesNochoice1 no) 
    ?retract <- (ifYesNochoice1) 
    (not (ifYesNochoice3 ?)) 
    => 
    (retract ?retract Chy) 
    (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)) 

    CLIPS> (reset) 

    CLIPS> (run) 

ответ

0

Изменить шаблоны для iffoundChoice и iffoundChoice1 включать выбор пользователя.

(defrule car_pulls_one_side_when_braking 
    (iffoundChoice 1)     ; <-- 
    ?retractCh1 <- (iffoundChoice1 1) ; <-- 
    (not (ifYesNochoice ?)) 
    => 
    (retract ?retractCh1) 
    (printout t crlf crlf crlf 
    " Was your tyre uneven? (yes|no) "crlf crlf 
    " Your answer: ") 
    (assert (ifYesNochoice (read)))) 
+0

Привет, извините за поздний ответ, мне удалось получить его работу, используя с помощью ссылки по другой ссылке, подобный моему [ссылка] (http://stackoverflow.com/questions/34110980/expert-system-clips -код-возвратного ложно-значение). но, к сожалению, в более позднем коде есть незначительная икота, которую я сделал, чтобы опубликовать ее в другом сообщении. Но спасибо за помощь! :) – Isaac