-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
26 lines (25 loc) · 664 Bytes
/
Copy pathtest.py
File metadata and controls
26 lines (25 loc) · 664 Bytes
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
#!/usr/bin/python
def make_temp_route(car, mode = 'remaining'): # mode = remaining/original
if mode == 'remaining':
o = car.next_intersection
elif mode == 'original' or mode == 'both':
o = car.origin
d = car.destination
dx = d.x - o.x
dy = d.y - o.y
curr_x = o.x
curr_y = o.y
r = [(o.x, o.y)]
for i in range(dx):
curr_x += 1
r.append((curr_x, curr_y))
if dy > 0:
for i in range(dy):
curr_y += 1
r.append((curr_x, curr_y))
if dy < 0:
for i in range(abs(dy)):
curr_y -= 1
r.append((curr_x, curr_y))
print(r)
return r