-
Notifications
You must be signed in to change notification settings - Fork 0
/
r1.asl
79 lines (63 loc) · 1.54 KB
/
r1.asl
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
// mars robot 1
/* Initial beliefs */
at(P) :- pos(P,X,Y) & pos(r1,X,Y).
battery(10).
/* Initial goal */
!check(slots).
/* Plans */
+!check(slots) : not garbage(r1) & battery(S) & S > 0 & not charge
<- nextContinous(slot);
-+battery(S-1);
showBattery(S-1);
!check(slots).
+!check(slots) : battery(S) & S == 0 & not charge.
+!check(slots).
+battery(0) : true
<- -at(_);
-garbage(r1);
-pos(last,X,Y);
.drop_all_intentions;
!goToChargeStation(charge).
+!goToChargeStation(charge) : true
<-
?pos(r1,X,Y);
-+pos(last,X,Y);
!at(r4);
+charge;
!charging(r);
!at(last);
-at(_);
-garbage(r1);
-charge;
.drop_all_intentions;
!check(slots).
+!charging(r): battery(S) & S < 100 & charge
<- -+battery(S+1);
showBattery(S+1);
.wait(100);
!charging(r).
+!charging(r): battery(S) & S == 100 & charge.
@lg[atomic]
+garbage(r1) : not .desire(carry_to(r2)) & battery(S) & S > 0 & not charge
<- !carry_to(r2).
+!carry_to(R) : battery(S) & S > 0 & not charge
<- // remember where to go back
?pos(r1,X,Y);
-+pos(last,X,Y);
// carry garbage to r2
!take(garb,R);
// goes back and continue to check
!at(last);
!check(slots).
+!take(S,L) : battery(E) & E > 0 & not charge
<- !ensure_pick(S);
!at(L);
drop(S).
+!ensure_pick(S) : garbage(r1) & battery(E) & E > 0 & not charge
<- pick(garb);
!ensure_pick(S).
+!ensure_pick(_).
+!at(L) : pos(L,X,Y) & pos(r1,X,Y).
+!at(L) <- ?pos(L,X,Y);
move_towards(X,Y);
!at(L).