Вы находитесь на странице: 1из 5

TITLE: ARTIFICIAL INTELLIGENCE PROJECT

(Ideal Bike for User)

An Artificial Intelligence Prolog EXPERT SYSTEM Code submitted by

101509014
Harshul Garg
MTX1 (Mechatronics; 4th year)

Date of Submission: 30/11/2018

Thapar Institute of Engineering and Technology, Patiala


PROGRAM

The user would like to know what his/her ideal bike would be.

CODE:
% To run, type go.

go :- hypothesize(Bike),
write('My ideal bike would be: '),
write(Bike), nl, undo.

/* hypotheses to be tested */
hypothesize(yamaha) :- yamaha, !.
hypothesize(suzuki) :- suzuki, !.
hypothesize(splendor) :- splendor, !.
hypothesize(pulsar) :- pulsar, !.
hypothesize(enfield) :- enfield, !.
hypothesize(renegade) :- renegade, !.
hypothesize(triumph) :- triumph, !.
hypothesize(unknown). /* no diagnosis */

/* bike identification rules */


yamaha :- commuter, sports,
verify(is_mildly_expensive),
verify(is_the_fastest).
suzuki :- commuter, sports,
verify(is_mildly_expensive),
verify(comes_in_black).
splendor :- cheap,
verify(has_famous_suspension),
verify(has_low_maintenance).
pulsar :- cheap,
verify(comes_in_black).
enfield :- cruiser,
verify(average_cruiser_mileage),
verify(has_famous_suspension).
renegade :- cruiser,
verify(average_cruiser_mileage),
verify(has_military_theme),
verify(is_not_easily_available).
triumph :- cruiser,
verify(owned_by_mumbiker_nikhil),
verify(the_most_powerful_bike).
/* classification rules */
commuter :- verify(light_weighted), !.
commuter :- verify(easy_to_handle).
cruiser :- verify(is_heavy), !.
cruiser :- verify(has_great_power),
verify(very_expensive).
sports :- verify(super_fast), !.
sports :- verify(good_pickup),
verify(has_style),
verify(has_mileage).
cheap :- commuter, verify(has_slow_pickup), !.
cheap :- commuter, verify(slow_topspeed).
/* how to ask questions */
ask(Question) :-
write('Does the bike have the following property: '),
write(Question), write('? '),
read(Response), nl,
( (Response == yes ; Response == y)
-> assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
/* How to verify something */
verify(S) :- (yes(S) -> true ; (no(S) -> fail ; ask(S))).
/* undo all yes/no assertions */
undo :- retract(yes(_)),fail.
undo :- retract(no(_)),fail.
undo.
EXECUTION OF CODE

Вам также может понравиться