update
[ker1415-1.git] / report / src / domaintask7.pl
1 % ------------------------- Domain Definition -------------------------
2 % --- Cross-file definitions ------------------------------------------
3 :- multifile connected/3, crate/4, agent/2, key/3.
4
5 % --- Primitive control actions ---------------------------------------
6 primitive_action(move(_, _)).
7 primitive_action(push(_, _)).
8 primitive_action(pickup(_)).
9
10 % --- Precondition for primitive actions ------------------------------
11 poss(move(From, To), S) :-
12 agent(From, S),
13 connected(From, To, _),
14 not(crate(_, _, To, S)).
15
16 poss(push(From, Direction), S) :-
17 agent(From, S),
18 connected(From, CrateLocation, Direction),
19 crate(_, Key, CrateLocation, S),
20 keyinbag(Key, S),
21 connected(CrateLocation, CrateTarget, Direction),
22 not(crate(_, _, CrateTarget, S)).
23
24 poss(pickup(CurrentLocation), S) :-
25 agent(CurrentLocation, S),
26 key(_, CurrentLocation, S).
27
28 % --- Successor state axioms ------------------------------------------
29 agent(AgentPlek, result(A, S)) :-
30 A = move(_, AgentPlek);
31 A = push(OudeAgentPlek, Richting),
32 connected(OudeAgentPlek, AgentPlek, Richting);
33 not(A = move(AgentPlek, _)), not(A = push(AgentPlek, _)),
34 agent(AgentPlek, S).
35
36 crate(Krat, _, Kratplek, result(A, S)) :-
37 A = push(AgentPlek, Richting),
38 connected(AgentPlek, OudeKratPlek, Richting),
39 connected(OudeKratPlek, Kratplek, Richting),
40 crate(Krat, _, OudeKratPlek, S);
41 not(A = push(AgentPlek2, Richting2)),
42 connected(AgentPlek2, Kratplek, Richting2),
43 crate(Krat, _, Kratplek, S).
44
45 key(Key, Location, result(A, S)) :-
46 not(A = pickup(Location)), key(Key, Location, S).
47
48 keyinbag(Key, result(A, S)) :-
49 agent(CurrentLocation, S),
50 A = pickup(CurrentLocation),
51 key(Key, CurrentLocation, S);
52 keyinbag(Key, S).