?? usedcar.clp
字號:
(defrule starter
?init <- (initial-fact)
=>
(retract ?init)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " ")
(printout t " W E L C O M E T O I A J S" crlf)
(printout t " " crlf)
(printout t " This Intelligent Automobile Judgement ")
(printout t "System will help the unknowledgable used ")
(printout t " " crlf)
(printout t "auto buyer make a sound decision ")
(printout t " in the purchase of a used car." crlf)
(printout t " " crlf)
(printout t "You, the purchaser, will be asked a series")
(printout t " of yes/no questions about the auto in" crlf)
(printout t "question. You will also be asked to perform")
(printout t " some simple tests. At the end of the " crlf)
(printout t "program a list of possible trouble areas ")
(printout t "and a recommendation on the purchase" crlf)
(printout t " " crlf)
(printout t " of the car will be made." crlf)
(printout t " " crlf)
(printout t "This system assumes that the buyer wants a")
(printout t " dependable driving car not in need of "crlf)
(printout t "major repairs. " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " Hit <cr> to begin our consulting" crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(bind ?answer (readline))
(assert (screen 2)))
(defrule first-scrn
?scrn <- (screen 2)
=>
(retract ?scrn)
(bind ?count 0)
(while (<= ?count 25)
(printout t " " crlf)
(bind ?count (+ ?count 1)))
(printout t " ")
(printout t " I will take you through 3 test phases" crlf)
(printout t " " crlf)
(printout t " ")
(printout t " 1. VISUAL INSPECTION" crlf)
(printout t " " crlf)
(printout t " ")
(printout t " 2. ENGINE RUNNING" crlf)
(printout t " " crlf)
(printout t " ")
(printout t " 3. ROAD TEST" crlf)
(printout t " " crlf)
(printout t " ")
(printout t "To begin the visual, hit <cr> " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(bind ?answer (readline))
(assert (start visual)))
(defrule visual1
?start <- (start visual)
=>
(retract ?start)
(bind ?count 0)
(while (<= ?count 20)
(printout t " " crlf)
(bind ?count (+ ?count 1)))
(printout t " The first thing to do is find the types of")
(printout t " options on the car. Please answer" crlf)
(printout t " " crlf)
(printout t "yes or no to the following questions. If")
(printout t " you don't know the answer, ask the " crlf)
(printout t " " crlf)
(printout t "seller" crlf)
(printout t " " crlf)
(printout t " " crlf)
(assert (find options)))
(defrule option1
?opt <- (find options)
=>
(retract ?opt)
(printout t "Does the car have AIR CONDITIONING?" crlf)
(printout t " " crlf)
(bind ?air (read))
(printout t " " crlf)
(printout t "How about POWER STEERING? " crlf)
(printout t " " crlf)
(bind ?psteer (read))
(printout t " " crlf)
(printout t "Are the brakes POWER ASSISTED?" crlf)
(printout t " " crlf)
(bind ?pbrake (read))
(printout t " " crlf)
(printout t "Does it have an AUTOMATIC TRANSMISSION?")
(printout t " " crlf)
(printout t " " crlf)
(bind ?auto (read))
(printout t " " crlf)
(printout t "How many cylinder engine?" crlf)
(printout t " " crlf)
(bind ?cyl (read))
(printout t " " crlf)
(printout t "Is it a REAR WHEEL DRIVE car?" crlf)
(printout t " " crlf)
(bind ?rwd (read))
(printout t " " crlf)
(printout t "What YEAR model is the car?" crlf)
(printout t " " crlf)
(bind ?year (read))
(printout t " " crlf)
(printout t "Does the car have gauges in the dash?" crlf)
(printout t " " crlf)
(bind ?dash (read))
(printout t " " crlf)
(printout t " " crlf)
(printout t " " crlf)
(printout t " ")
(printout t "Thanks for the info. " crlf)
(printout t " " crlf)
(printout t " ")
(printout t "Let's look at the car now." crlf)
(assert (options airc ?air))
(assert (options powers ?psteer))
(assert (options powerb ?pbrake))
(assert (options tran ?auto))
(assert (options eng ?cyl))
(assert (options drive ?rwd))
(assert (options yr ?year))
(assert (options dhgages ?dash))
(assert (inspect the outside)))
; USER INTERFACE TO RULES vis outside of car
(defrule vis1
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Does the car seem to sit level?" crlf)
(printout t " " crlf)
(bind ?level (read))
(assert (lvl ?level)))
(defrule vis2
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Do windows and doors fit correctly?" crlf)
(printout t " " crlf)
(bind ?wdfit (read))
(assert (fit ?wdfit)))
(defrule vis3
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is the trunk clean and neat?" crlf)
(printout t " " crlf)
(bind ?trnk (read))
(assert (trk ?trnk)))
(defrule vis4
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is there minor dents in the body?" crlf)
(printout t " " crlf)
(bind ?dent (read))
(assert (dnt ?dent)))
(defrule vis5
(inspect the outside)
=>
(printout t " " crlf)
(printout t "When looking down the car do the")
(printout t " panels line up?" crlf)
(printout t " " crlf)
(bind ?pnls (read))
(assert (pnl ?pnls)))
(defrule vis6
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is there obvious rust on the body?" crlf)
(printout t " " crlf)
(bind ?rust (read))
(assert (rst ?rust)))
(defrule vis6-5
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is the pressure good in all tires?" crlf)
(printout t " " crlf)
(bind ?tire (read))
(assert (tir ?tire)))
;RULES ABOUT CAR
;---------------------------------------------------------
(defrule vis7
?rusty <- (rst ?rust)
(test (eq ?rust yes))
=>
(assert (CAR HAS BODY RUST))
(retract ?rusty))
(defrule vis7-5
(declare (salience -200))
?rusty <- (rst ?rust)
(test (eq ?rust no))
=>
(retract ?rusty))
(defrule vis8
?panel <- (pnl ?pnls)
(test (eq ?pnls no))
=>
(assert (MAY HAVE FRAME DAMAGE))
(retract ?panel))
(defrule vis8-5
(declare (salience -200))
?panel <- (pnl ?pnls)
(test (eq ?pnls yes))
=>
(retract ?panel))
(defrule vis9
?dents <- (dnt ?dent)
(test (eq ?dent yes))
=>
(assert (PARKING LOT DAMAGE))
(retract ?dents))
(defrule vis10
?trunk <- (trk ?truk)
(test (eq ?truk yes))
=>
(assert (WELL CARED FOR))
(retract ?trunk))
(defrule vis11
?doors <- (fit ?wdfit)
(test (eq ?wdfit no))
=>
(assert (EVIDENCE OF MAJOR ACCIDENT))
(retract ?doors))
(defrule vis12
?even <- (lvl ?level)
(test (eq ?level no))
=>
(assert (POSSIBLE SUSPENSION PROBLEMS))
(assert (POSSIBLE BENT FRAME))
(retract ?even))
(defrule vis13
?tires <- (tir ?tire)
(test (eq ?tire no))
=>
(assert (UNEVEN TIRE PRESSURE))
(retract ?tires))
;---------------------------------------------------------
;USER INTERFACE engine compartment
(defrule vis14
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Do the engine belts show any wear?" crlf)
(printout t " " crlf)
(bind ?belt (read))
(assert (blt ?belt)))
(defrule vis15
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Do the hoses show any wear?" crlf)
(printout t " " crlf)
(bind ?hose (read))
(assert (hos ?hose)))
(defrule vis16
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is there a smell of gasoline? " crlf)
(printout t " " crlf)
(bind ?gaso (read))
(assert (gas ?gaso)))
(defrule vis17
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is the radiator fluid clean, green ")
(printout t "and full" crlf)
(printout t " " crlf)
(bind ?radr (read))
(assert (rad ?radr)))
(defrule vis18
(inspect the outside)
(options tran yes)
=>
(printout t " " crlf)
(printout t "Does the transmission fluid look or ")
(printout t "smell burnt" crlf)
(printout t " " crlf)
(bind ?trany (read))
(assert (tny ?trany)))
(defrule vis19
(inspect the outside)
(options tran yes)
=>
(printout t " " crlf)
(printout t "Is the transmission full of fluid?" crlf)
(printout t " " crlf)
(bind ?tranf (read))
(assert (tnf ?tranf)))
(defrule vis20
(inspect the outside)
=>
(printout t " " crlf)
(printout t "Is the brake system full of fluid?" crlf)
(printout t " " crlf)
(bind ?brakf (read))
(assert (bkf ?brakf)))
(defrule vis21
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -