-
Notifications
You must be signed in to change notification settings - Fork 57
/
domain.pddl
146 lines (133 loc) · 3.85 KB
/
domain.pddl
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
(define (domain citycar)
(:requirements :typing :equality :negative-preconditions :action-costs :conditional-effects)
(:types
car
junction
garage
road
)
(:predicates
(same_line ?xy - junction ?xy2 - junction) ;; junctions in line (row)
(diagonal ?x - junction ?y - junction ) ;; junctions in diagonal (on the map)
(at_car_jun ?c - car ?x - junction) ;; a car is at the junction
(at_car_road ?c - car ?x - road) ;; a car is in a road
(starting ?c - car ?x - garage) ;; a car is in its initial position
(arrived ?c - car ?x - junction) ;; a car arrived at destination
(road_connect ?r1 - road ?xy - junction ?xy2 - junction) ;; there is a road that connects 2 junctions
(clear ?xy - junction ) ;; the junction is clear
(in_place ?x - road);; the road has been put in place
(at_garage ?g - garage ?xy - junction ) ;; position of the starting garage
)
(:functions (total-cost) - number)
;; move the car in a road: no limit on the number of cars on the road
(:action move_car_in_road
:parameters (?xy_initial - junction ?xy_final - junction ?machine - car ?r1 - road)
:precondition (and
(at_car_jun ?machine ?xy_initial)
(not (= ?xy_initial ?xy_final))
(road_connect ?r1 ?xy_initial ?xy_final)
(in_place ?r1)
)
:effect (and
(clear ?xy_initial)
(at_car_road ?machine ?r1)
(not (at_car_jun ?machine ?xy_initial) )
(increase (total-cost) 1)
)
)
;; move the car out of the road to a junction. Junction must be clear.
(:action move_car_out_road
:parameters (?xy_initial - junction ?xy_final - junction ?machine - car ?r1 - road)
:precondition (and
(at_car_road ?machine ?r1)
(clear ?xy_final)
(not (= ?xy_initial ?xy_final))
(road_connect ?r1 ?xy_initial ?xy_final)
(in_place ?r1)
)
:effect (and
(at_car_jun ?machine ?xy_final)
(not (clear ?xy_final))
(not (at_car_road ?machine ?r1) )
(increase (total-cost) 1)
)
)
;; car in the final position. They are removed from the network and position is cleared.
(:action car_arrived
:parameters (?xy_final - junction ?machine - car )
:precondition (and
(at_car_jun ?machine ?xy_final)
)
:effect (and
(clear ?xy_final)
(arrived ?machine ?xy_final)
(not (at_car_jun ?machine ?xy_final))
)
)
;; car moved from the initial garage in the network.
(:action car_start
:parameters (?xy_final - junction ?machine - car ?g - garage)
:precondition (and
(at_garage ?g ?xy_final)
(starting ?machine ?g)
(clear ?xy_final)
)
:effect (and
(not (clear ?xy_final))
(at_car_jun ?machine ?xy_final)
(not (starting ?machine ?g))
)
)
;; build diagonal road
(:action build_diagonal_oneway
:parameters (?xy_initial - junction ?xy_final - junction ?r1 - road)
:precondition (and
(clear ?xy_final)
(not (= ?xy_initial ?xy_final))
(not (in_place ?r1))
(diagonal ?xy_initial ?xy_final)
)
:effect (and
(road_connect ?r1 ?xy_initial ?xy_final)
(in_place ?r1)
(increase (total-cost) 30)
)
)
;; build straight road
(:action build_straight_oneway
:parameters (?xy_initial - junction ?xy_final - junction ?r1 - road)
:precondition (and
(clear ?xy_final)
(not (= ?xy_initial ?xy_final))
(same_line ?xy_initial ?xy_final)
(not (in_place ?r1))
)
:effect (and
(road_connect ?r1 ?xy_initial ?xy_final)
(in_place ?r1)
(increase (total-cost) 20)
)
)
;; remove a road
(:action destroy_road
:parameters (?xy_initial - junction ?xy_final - junction ?r1 - road)
:precondition (and
(road_connect ?r1 ?xy_initial ?xy_final)
(not (= ?xy_initial ?xy_final))
(in_place ?r1)
)
:effect (and
(not (in_place ?r1))
(not (road_connect ?r1 ?xy_initial ?xy_final))
(increase (total-cost) 10)
(forall (?c1 - car)
(when (at_car_road ?c1 ?r1)
(and
(not (at_car_road ?c1 ?r1))
(at_car_jun ?c1 ?xy_initial)
)
)
)
)
)
)