-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClingoProj.sm
84 lines (55 loc) · 2.13 KB
/
ClingoProj.sm
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
node(1..9).
step(0..9).
holds(edge(1,2),0).
holds(edge(2,3),0).
holds(edge(2,4),0).
-holds(edge(4,5),0).
holds(edge(5,6),0).
-holds(edge(5,7),0).
holds(edge(7,8),0).
holds(edge(7,9),0).
holds(edge(X,Y),0) :- holds(edge(Y,X),0).
% (Sword)
% 6 8(Dead-End)
% / _
% / |
% (-Door) / |
% 1 — — — 2 — — — 4 — — — 5 — — — 7 — — — 9(Exit)
% | (-Boss)
% |
% |
% 3(Key)
%not listed is not holds
-holds(edge(X,Y),0) :- not holds(edge(X,Y),0), node(X), node(Y).
-holds(edge(Y,X),0) :- not holds(edge(Y,X),0), node(X), node(Y).
#show occurs/2.
%On node 1 at time 0, not on any other nodes at time 0, no items
holds(on(1),0).
-holds(on(X),0) :- not holds(on(X),0), node(X).
-holds(keypickup).
-holds(swordpickup).
fluent(on(X)) :- node(X).
fluent(edge(X,Y)) :- node(X), node(Y).
fluent(keypickup).
fluent(swordpickup).
action(move(X,Y)):- node(X), node(Y).
holds(on(Y),T+1):- occurs(move(X,Y),T), node(X), node(Y), step(T), step(T+1).
-holds(on(X),T+1):- occurs(move(X,Y),T), node(X), node(Y),step(T), step(T+1).
-occurs(move(X,Y),T) :- -holds(on(X),T), node(X), node(Y), step(T).
-occurs(move(X,Y),T) :- -holds(edge(X,Y),T), node(X), node(Y), step(T).
%holds(on(3),T) :- holds(keypickup), step(T).
%holds(on(6),T) :- holds(swordpickup), step(T).
holds(edge(4,5),T+1) :- holds(on(3),T), step(T),step(T+1).
holds(edge(5,7),T+1) :- holds(on(6),T), step(T),step(T+1).
holds(keypickup,T+1) :- holds(on(3),T), step(T),step(T+1).
holds(swordpickup,T+1) :- holds(on(6),T), step(T),step(T+1).
sub_goal(on(9)).
%sub_goal(on(6)).
%sub_goal(on(9)).
-goal(T) :- not holds(X,T), sub_goal(X), step(T).
goal(T) :- not -goal(T), step(T).
goal :- goal(T), step(T).
:- not goal.
1{occurs(A,T):action(A)}1 :- not goal(T), step(T).
holds(F,T+1) :- holds(F,T), not -holds(F,T+1), fluent(F), step(T), step(T+1).
-holds(F,T+1) :- -holds(F,T), not holds(F,T+1), fluent(F), step(T), step(T+1).