identify -clear_dynamic_DB sport write The sport is write write write

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
identify:-clear_dynamic_DB,sport(X),write('The sport is - '),write(X),write('.'),write('\n Press Enter to exit program.'), get_char(_),!.
identify:-clear_dynamic_DB,write('I cannot identify the sport.'),write('\n Press Enter to exit program.'), get_char(_).
clear_dynamic_DB:-retractall(known(_,_,_)).
class(ski):-covering(snow),movement(dynam).
class(skating):-covering(ice),movement(dynam).
class(sled):-covering(ice),movement(static).
sport(ski_races):-class(ski),touching(wooden),weapons(notpresent).
sport(biatlon):-class(ski),purpose(target),speed(slow),ride(free),weapons(present).
sport(skating):-class(skating),path(vicious_circle).
sport(figure_skating):-class(skating),rating(mark),ride(figure_elements).
sport(hockey):-class(skating),time(static),purpose(gate),type_of_work(teamwork),rating(goal).
sport(skeleton):-class(sled),position(lying),speed(high),touching(iron).
sport(bobsled):-class(sled),position(sitting),type_of_work(teamwork),speed(high).
covering(X):-ask(covering,X). %поверхня(сніг,лід)
position(X):-ask(position,X). %положення(лежачи,сидячи)
movement(X):-ask(movement,X). %пересування(статичне,динамічне)
time(X):-ask(time,X). %час
purpose(X):-ask(purpose,X). %ціль
rating(X):-ask(rating,X). %оцінка
type_of_work(X):-ask(type_of_work,X). %тип роботи(командна)
speed(X):-ask(speed,X). %швидкість(висока)
path(X):-ask(path,X). %шлях(замкнуте коло)
touching(X):-ask(touching,X). %поверхня_дотику_до землі
weapons(X):-ask(weapons,X). %зброя
ride(X):-ask(ride,X). %катання
ask(Atribute,Value):-known(yes,Atribute,Value),!.
ask(Atribute,Value):-known(_,Atribute,Value),!, fail.
ask(Atribute,_):-known(yes,Atribute,_),!, fail.
ask(Atribute,Value):-write(Atribute:Value),write('? (yes or no): '),read(Answer),remember(Answer,Atribute,Value),Answer=yes.
remember(Answer,Atribute,Value):-asserta(known(Answer,Atribute,Value)).