-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathICThelper2Version1.pl
67 lines (52 loc) · 1.33 KB
/
ICThelper2Version1.pl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* ICT HELPER 2 */
/* Version 1.0 */
go :- hypothesise(Solution),
write('You should consider: '),
write(Solution),
nl,
undo.
/* hypotheses to be tested */
hypothesise(asking_DIYNGO_for_help_please) :- ask_diyngo, !.
hypothesise(a_solar_computer_solution) :- solar_comp, !.
hypothesise(a_wind_computer_solution) :- wind_comp, !.
hypothesise(sorry_we_cannot_help).
/* rules */
ask_diyngo :- renewables,
verify(plenty_of_sunshine),
verify(little_knowledge_of_renewables).
ask_diyngo :- renewables,
verify(plenty_of_wind),
verify(little_knowledge_of_renewables).
solar_comp :- renewables,
verify(understanding_of_computers),
verify(plenty_of_sunshine).
wind_comp :- renewables,
verify(understanding_of_computers),
verify(plenty_of_wind).
/* classification rules */
renewables :- verify(no_grid_electricity).
renewables :- verify(often_lose_power).
/* ask questions */
ask(Question) :- write('In your community is there the following: '),
write(Question),
write('? '),
read(Response),
nl,
((Response == yes ; Response == y)
->
assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
/* 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.