coordinates = [(0, 2), (0, 1), (1, 2), (1, 1), (0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]
I have created a Python array stated above. It contains tuples of points (x,y). I will assume I start at the first point (not the orgin). I want to move to the points in the order given. The only movement functions I have are rotate90Degrees(direction)
where direction is 1 or -1 for left and right, respectively. And forward(time)
where time is how long to move. I will assume time = 1 is equivalent to one unit in the coordinate system. Is there a clever way to easily change the this into movement instructions without a huge if/else if/else? What I have so far:
start = coordinates[0]
for x in range(1,len(coordinates)):
finish = coordinates[x]
change.append((finish[0] - start[0],finish[1] - start[1]))
start = coordinates[x]