-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathgripper.py
More file actions
executable file
·56 lines (42 loc) · 1.58 KB
/
Copy pathgripper.py
File metadata and controls
executable file
·56 lines (42 loc) · 1.58 KB
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
#!/usr/bin/env python
import argparse
import random
parser = argparse.ArgumentParser()
parser.add_argument("balls", type=int, help="the number of balls")
parser.add_argument("--seed", "-s", type=int, help="random seed")
parser.add_argument("--randomize", "-r", action="store_true", help="randomize the initial state and the goal if present")
args = parser.parse_args()
random.seed(args.seed)
def init():
# static
facts = ["(room rooma)","(room roomb)", "(gripper left)", "(gripper right)"]
for i in range(args.balls):
facts.append(f"(ball ball{i})")
# fluents
facts.extend(["(free left)", "(free right)"])
if args.randomize:
for i in range(args.balls):
room = random.choice(["rooma","roomb"])
facts.append(f"(at ball{i} {room})")
room = random.choice(["rooma","roomb"])
facts.append(f"(at-robby {room})")
else:
for i in range(args.balls):
facts.append(f"(at ball{i} rooma)")
facts.append(f"(at-robby rooma)")
return " ".join(facts)
def goal():
facts = []
if args.randomize:
for i in range(args.balls):
room = random.choice(["rooma","roomb"])
facts.append(f"(at ball{i} {room})")
else:
for i in range(args.balls):
facts.append(f"(at ball{i} roomb)")
return " ".join(facts)
print("(define (problem gripper)")
print(" (:domain gripper-strips)")
print(" (:objects rooma roomb left right " + " ".join([f"ball{i}" for i in range(args.balls)]) + ")")
print(" (:init " + init() + ")")
print(" (:goal (and " + goal() + ")))")