Skip to content

Commit b6c6cea

Browse files
Consistent comment separators [ci skip]
1 parent 0508669 commit b6c6cea

File tree

5 files changed

+45
-24
lines changed

5 files changed

+45
-24
lines changed

PDDL.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class PDDL_Parser:
88

99
SUPPORTED_REQUIREMENTS = [':strips', ':negative-preconditions', ':typing']
1010

11-
# ------------------------------------------
11+
#-----------------------------------------------
1212
# Tokens
13-
# ------------------------------------------
13+
#-----------------------------------------------
1414

1515
def scan_tokens(self, filename):
1616
with open(filename,'r') as f:
@@ -202,9 +202,9 @@ def split_predicates(self, group, pos, neg, name, part):
202202
else:
203203
pos.append(predicate)
204204

205-
# ==========================================
205+
#-----------------------------------------------
206206
# Main
207-
# ==========================================
207+
#-----------------------------------------------
208208
if __name__ == '__main__':
209209
import sys, pprint
210210
domain = sys.argv[1]

action.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
class Action:
77

8+
#-----------------------------------------------
9+
# Initialize
10+
#-----------------------------------------------
11+
812
def __init__(self, name, parameters, positive_preconditions, negative_preconditions, add_effects, del_effects):
913
self.name = name
1014
self.parameters = parameters
@@ -13,6 +17,10 @@ def __init__(self, name, parameters, positive_preconditions, negative_preconditi
1317
self.add_effects = add_effects
1418
self.del_effects = del_effects
1519

20+
#-----------------------------------------------
21+
# to String
22+
#-----------------------------------------------
23+
1624
def __str__(self):
1725
return 'action: ' + self.name + \
1826
'\n parameters: ' + str(self.parameters) + \
@@ -21,9 +29,17 @@ def __str__(self):
2129
'\n add_effects: ' + str(self.add_effects) + \
2230
'\n del_effects: ' + str(self.del_effects) + '\n'
2331

32+
#-----------------------------------------------
33+
# Equality
34+
#-----------------------------------------------
35+
2436
def __eq__(self, other):
2537
return self.__dict__ == other.__dict__
2638

39+
#-----------------------------------------------
40+
# Groundify
41+
#-----------------------------------------------
42+
2743
def groundify(self, objects):
2844
if not self.parameters:
2945
yield self
@@ -40,6 +56,10 @@ def groundify(self, objects):
4056
del_effects = self.replace(self.del_effects, variables, assignment)
4157
yield Action(self.name, assignment, positive_preconditions, negative_preconditions, add_effects, del_effects)
4258

59+
#-----------------------------------------------
60+
# Replace
61+
#-----------------------------------------------
62+
4363
def replace(self, group, variables, assignment):
4464
g = []
4565
for pred in group:
@@ -52,6 +72,9 @@ def replace(self, group, variables, assignment):
5272
g.append(pred)
5373
return g
5474

75+
#-----------------------------------------------
76+
# Main
77+
#-----------------------------------------------
5578
if __name__ == '__main__':
5679
a = Action('move', [['?ag', 'agent'], ['?from', 'pos'], ['?to', 'pos']],
5780
[['at', '?ag', '?from'], ['adjacent', '?from', '?to']],

planner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def apply(self, state, positive, negative):
7474
new_state.append(i)
7575
return new_state
7676

77-
# ==========================================
77+
#-----------------------------------------------
7878
# Main
79-
# ==========================================
79+
#-----------------------------------------------
8080
if __name__ == '__main__':
8181
import sys, time
8282
start_time = time.time()

test_PDDL.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
from action import Action
66
from PDDL import PDDL_Parser
77

8-
# ==========================================
9-
# Test PDDL
10-
# ==========================================
11-
128
class Test_PDDL(unittest.TestCase):
139

14-
# ------------------------------------------
10+
#-----------------------------------------------
1511
# Test scan_tokens
16-
# ------------------------------------------
12+
#-----------------------------------------------
1713

1814
def test_scan_tokens_domain(self):
1915
parser = PDDL_Parser()
@@ -44,9 +40,9 @@ def test_scan_tokens_problem(self):
4440
[':goal', ['and', ['dinner'], ['present'], ['not', ['garbage']]]]]
4541
)
4642

47-
# ------------------------------------------
43+
#-----------------------------------------------
4844
# Test parse domain
49-
# ------------------------------------------
45+
#-----------------------------------------------
5046

5147
def test_parse_domain(self):
5248
parser = PDDL_Parser()
@@ -64,9 +60,9 @@ def test_parse_domain(self):
6460
]
6561
)
6662

67-
# ------------------------------------------
63+
#-----------------------------------------------
6864
# Test parse problem
69-
# ------------------------------------------
65+
#-----------------------------------------------
7066

7167
def test_parse_problem(self):
7268
parser = PDDL_Parser()
@@ -78,9 +74,9 @@ def test_parse_problem(self):
7874
self.assertEqual(parser.positive_goals, [['dinner'], ['present']])
7975
self.assertEqual(parser.negative_goals, [['garbage']])
8076

81-
#-------------------------------------------
77+
#-----------------------------------------------
8278
# Test parse predicates
83-
#-------------------------------------------
79+
#-----------------------------------------------
8480

8581
def test_parse_predicates(self):
8682
parser = PDDL_Parser()
@@ -96,5 +92,8 @@ def test_parse_predicates(self):
9692
'shared_type_pred': {'?v1': 'type1', '?v2': 'type1', '?v3': 'object'}
9793
})
9894

95+
#-----------------------------------------------
96+
# Main
97+
#-----------------------------------------------
9998
if __name__ == '__main__':
10099
unittest.main()

test_planner.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
from action import Action
66
from planner import Planner
77

8-
# ==========================================
9-
# Test Planner
10-
# ==========================================
11-
128
class Test_Planner(unittest.TestCase):
139

14-
# ------------------------------------------
10+
#-----------------------------------------------
1511
# Test solve
16-
# ------------------------------------------
12+
#-----------------------------------------------
1713

1814
def test_solve_dinner(self):
1915
planner = Planner()
@@ -25,5 +21,8 @@ def test_solve_dinner(self):
2521
]
2622
)
2723

24+
#-----------------------------------------------
25+
# Main
26+
#-----------------------------------------------
2827
if __name__ == '__main__':
2928
unittest.main()

0 commit comments

Comments
 (0)