-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_generator.py
More file actions
245 lines (190 loc) · 8.23 KB
/
task_generator.py
File metadata and controls
245 lines (190 loc) · 8.23 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import re
import argparse
import random
parser = argparse.ArgumentParser(
description='Script to generate and schedule navigation tasks')
parser.add_argument('--train_size', type=int, default=10000,
help='task instances shown during training')
args = parser.parse_args()
task_repository = {}
structure_repository = {}
task_set = set()
primitive_task_set = set()
command = "look"
primitive_task_set.add(command)
task_repository[command] = "I_LOOK"
command = "turn left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT"
command = "turn right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT"
command = "walk"
primitive_task_set.add(command)
task_repository[command] = "I_WALK"
command = "run"
primitive_task_set.add(command)
task_repository[command] = "I_RUN"
command = "jump"
primitive_task_set.add(command)
task_repository[command] = "I_JUMP"
command = "look left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_LOOK"
command = "look right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_LOOK"
command = "walk left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_WALK"
command = "walk right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_WALK"
command = "run left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_RUN"
command = "run right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_RUN"
command = "jump left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_JUMP"
command = "jump right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_JUMP"
command = "turn around left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT I_TURN_LEFT I_TURN_LEFT"
command = "turn around right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT I_TURN_RIGHT I_TURN_RIGHT"
command = "look around left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_LOOK I_TURN_LEFT I_LOOK I_TURN_LEFT I_LOOK I_TURN_LEFT I_LOOK"
command = "look around right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_LOOK I_TURN_RIGHT I_LOOK I_TURN_RIGHT I_LOOK I_TURN_RIGHT I_LOOK"
command = "walk around left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_WALK I_TURN_LEFT I_WALK I_TURN_LEFT I_WALK I_TURN_LEFT I_WALK"
command = "walk around right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_WALK I_TURN_RIGHT I_WALK I_TURN_RIGHT I_WALK I_TURN_RIGHT I_WALK"
command = "run around left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_RUN I_TURN_LEFT I_RUN I_TURN_LEFT I_RUN I_TURN_LEFT I_RUN"
command = "run around right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_RUN I_TURN_RIGHT I_RUN I_TURN_RIGHT I_RUN I_TURN_RIGHT I_RUN"
command = "jump around left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_JUMP I_TURN_LEFT I_JUMP I_TURN_LEFT I_JUMP I_TURN_LEFT I_JUMP"
command = "jump around right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_JUMP I_TURN_RIGHT I_JUMP I_TURN_RIGHT I_JUMP I_TURN_RIGHT I_JUMP"
command = "turn opposite left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT"
command = "turn opposite right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT"
command = "look opposite left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT I_LOOK"
command = "look opposite right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT I_LOOK"
command = "walk opposite left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT I_WALK"
command = "walk opposite right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT I_WALK"
command = "run opposite left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT I_RUN"
command = "run opposite right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT I_RUN"
command = "jump opposite left"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_LEFT I_TURN_LEFT I_JUMP"
command = "jump opposite right"
primitive_task_set.add(command)
task_repository[command] = "I_TURN_RIGHT I_TURN_RIGHT I_JUMP"
for k, v in task_repository.items():
structure_repository[k] = [str(len(v.split(' ')))]
task_set = primitive_task_set
twice_task_set = set()
for primitive_command in task_set:
command = primitive_command + " twice"
twice_task_set.add(command)
structure_repository[command] = structure_repository[primitive_command] * 2
task_repository[command] = task_repository[primitive_command] + \
" " + task_repository[primitive_command]
three_times_task_set = set()
for primitive_command in task_set:
# command = primitive_command + " three times"
command = primitive_command + " thrice"
three_times_task_set.add(command)
structure_repository[command] = structure_repository[primitive_command] * 3
task_repository[command] = task_repository[primitive_command] + " " + \
task_repository[primitive_command] + " " + \
task_repository[primitive_command]
task_set = task_set | twice_task_set | three_times_task_set
and_task_set = set()
for primitive_command_1 in task_set:
for primitive_command_2 in task_set:
command = primitive_command_1 + " and " + primitive_command_2
and_task_set.add(command)
structure_repository[command] = structure_repository[primitive_command_1] + \
structure_repository[primitive_command_2]
task_repository[command] = task_repository[primitive_command_1] + \
" " + task_repository[primitive_command_2]
after_task_set = set()
for primitive_command_1 in task_set:
for primitive_command_2 in task_set:
command = primitive_command_1 + " after " + primitive_command_2
after_task_set.add(command)
structure_repository[command] = structure_repository[primitive_command_2] + \
structure_repository[primitive_command_1]
task_repository[command] = task_repository[primitive_command_2] + \
" " + task_repository[primitive_command_1]
task_set = task_set | and_task_set | after_task_set
# in_reverse_task_set = set()
# for primitive_command in task_set:
# if (re.search(" ",task_repository[primitive_command])):
# command = primitive_command + " in reverse"
# in_reverse_task_set.add(command)
# task_repository[command]= ' '.join(task_repository[primitive_command].split(' ')[::-1])
#
# task_set = task_set | in_reverse_task_set
for selected_task in task_repository:
print("::: " + selected_task + " ::: " +
task_repository[selected_task], " ::: ", ' '.join(structure_repository[selected_task]))
# for test_task in task_set:
# print("CURRENT TEST TASK: " + test_task)
# train_set = task_set - {test_task}
# i=args.train_size
# while (i>0):
# selected_task = random.sample(train_set,1)[0]
# print("IN: " + selected_task + " OUT: " + task_repository[selected_task])
# i=i-1
# print("IN: " + test_task + " OUT: " + task_repository[test_task])
# print("*** primitive *** : " + str(len(primitive_task_set)))
# for task in sorted(primitive_task_set):
# print task + " " + task_repository[task]
#
# print("*** twice ***: " + str(len(twice_task_set)))
# for task in sorted(twice_task_set):
# print task + " " + task_repository[task]
#
# print("*** and ***: " + str(len(and_task_set)))
# for task in sorted(and_task_set):
# print task + " " + task_repository[task]
#
# print("*** reverse ***: " + str(len(in_reverse_task_set)))
# for task in sorted(in_reverse_task_set):
# print task + " " + task_repository[task]
#
# print("*** all tasks ***: " + str(len(task_set)))