Создание экспертной системы продукционного типа, страница 2

cheap(Mark, Model, Pr1):-vehicle(Mark, Model, _, _, _, _, _, _, _, Pr), Pr<Pr1, !, cheap(Mark, Model, Pr).

cheap(Mark, Model, Pr):-vehicle(Mark, Model, _, _, _, _, _, _, _, Pr), write("Price: ", Pr, " ").

expensive(Mark, Model, Pr1):-vehicle(Mark, Model, _, _, _, _, _, _, _, Pr), Pr>Pr1, !, cheap(Mark, Model, Pr).

expensive(Mark, Model, Pr):-vehicle(Mark, Model, _, _, _, _, _, _, _, Pr), write("Price: ", Pr, " ").

repeat.

repeat:-repeat.

dialog:-repeat,

          write("-----------------------------------------------"),nl,

          write("Please, choose action: "),nl,

          write("1 - to view the base"), nl,

          write("2 - to find a car"), nl,

          write("3 - to delete a car"), nl,

          write("4 - to recomend you a car"), nl,

          write("5 - to consult about features"),nl,

          write("6 - to simple choose car"),nl,

          write("8 - to input new fact"), nl,

          write("10 - to exit"), nl,

          write("Your command: "),

          readint(X),

          doaction(X),

          nl.

doaction(1):-vehicle(N,M,Cl,BT,Doors,Offr,Power,_,_,_), write(N," ", M," ", "Class ", Cl," ",BT," ", Doors, " doors ",Offr," ", Power), nl, fail.

doaction(2):-

                    write("Mark: "), readln(Mark), nl,

                    write("Model: "),  readln(Model), nl,

                    vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr),nl,

                    write("class: ", Cl), nl,

                    write("body type: ", BT), nl,

                    write("number of doors: ", Nd), nl,

                    write("wheel drive: ", WD), nl,

                    write("power: ", Pw), nl,

                    write("transmission: ", TM), nl,

                    write("petrol cunsumption: ", PC), nl,

                    write("price: ", Pr), nl, fail.

doaction(3):-

                    write("Mark: "), readln(Mark), nl,

                    write("Model: "),  readln(Model), nl,

                    vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr),nl,

                    retract(vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr)),

                    save("d:/iis/cars.txt"), fail,nl.

doaction(4):-

                    write("I will help to make a choice that car is most fits you!\n"),

                    write("How many people you will tranport mostly?: "),

                    readint(A), nl,

                    peopledoors(A,Nd),nl,

                    write("Do you plan to drive to the nature? (Yes/No): "),

                    readln(B),

                    naturewd(B,WD),

                    write("Do you need spacious boot? (Yes/No): "),

                    readln(C),

                    boot_bodytype(C,BT),

                    write("Do you have driving experience? (Yes/No): "),

                    readln(D),

                    extrans(D,TM),

                    write("Do you look for economical(petrol cunsumption) car?: "),nl,

                    write("1 - No"),nl,

                    write("2 - Probably yes"), nl,

                    write("3 - Yes"), nl,

                    readint(E),

                    economicpc(E,PC),

                    write("Do you look for powerful car? (Yes/No)"), nl,

                    readln(F),

                    power(F,Pw),nl,

                    write("What is you budget?: "),

                    readint(Pr),

                    showreccars(_, _, _, BT, Nd, WD, Pw, TM, PC, Pr),

                    fail.

doaction(5):-

                    repeat,

                    write("I can consult you about a car, but before choose one car: "),nl,

                    write("Please input: "),

                    write("mark: "), readln(Mark),

                    write("model: "), readln(Model),/*

                    write("class: "), readln(Cl),

                    write("body type: "), readln(BT),

                    write("number of doors: "), readint(Nd),

                    write("wheel drive: "), readln(WD),

                    write("power: "), readreal(Pw),

                    write("transmission: "), readln(TM),

                    write("petrol cunsumption: "), readreal(PC),

                    write("price: "), readreal(Pr),*/

                    vehicle(Mark, Model, Cl, BT, Nd, WD, Pw, TM, PC, Pr),

                    mark(Mark,Country),

                    country(Country, AboutCountry),

                    write(AboutCountry),nl,

                    classofcars(Cl,AboutClass),

                    write(AboutClass),nl,

                    bodytype(BT,AboutBodyType),

                    write(AboutBodyType),nl,

                    weeldrive(WD, AboutWeelDrive),

                    write(AboutWeelDrive),nl,

                    cross_country(AboutWeelDrive,AboutCrossCountry),

                    write(AboutCrossCountry),nl,

                    transmission(TM,AboutTransmission),

                    write(AboutTransmission),nl,

                    gearbox(AboutTransmission, AboutGearBox),

                    write(AboutGearBox),nl,

                    write("class: ", Cl), nl,

                    write("body type: ", BT), nl,

                    write("number of doors: ", Nd), nl,

                    write("wheel drive: ", WD), nl,

                    write("power: ", Pw), nl,

                    write("transmission: ", TM), nl,

                    write("petrol cunsumption: ", PC), nl,

                    write("price: ", Pr), nl,

                    write("-------------------------------------------------"),nl,

                    write("For exit type stop: "),

                    readln(A),

                    A="stop",

                    !,

                    fail.

doaction(6):-

                    write("Where you can choose car at single parametr"),nl,

                    write("1 - to find cheapes car "),nl,

                    write("2 - to find most economic car "),nl,

                    write("Your command: "),

                    readint(X),

                    nl,

                    doaction1(X),

                    nl.

doaction(8):-