I know this can be made more elegant (and the names of my methods are terrible!), But maybe something like this?
>>> import itertools
>>> def alternator(*values):
... return itertools.cycle(values)
...
>>> def increasor(value_1, dvalue_1, steps=2):
... counter = itertools.count(value_1, dvalue_1)
... while True:
... repeater = itertools.repeat(counter.next(), steps)
... for item in repeater:
... yield item
...
>>> def motion_plan(x_plan, y_plan, steps=6):
... while steps > 0:
... yield (x_plan.next(), y_plan.next())
... steps -= 1
...
>>> for pos in motion_plan(alternator('x1', 'x1+dx'), increaser('y1', '+dy'):
... print pos
...
('x1', 'y1')
('x1+dx', 'y1')
('x1', 'y1+dy')
('x1+dx', 'y1+dy')
('x1', 'y1+dy+dy')
('x1+dx', 'y1+dy+dy')
, , , . , , , . , - :
>>> count = 0
>>> for pos in motion_plan(increaser(0, -1), alternator(0, 1)):
... print "%d %r" % (count, pos)
... count += 1
1 (0, 0)
2 (0, 1)
3 (-1, 0)
4 (-1, 1)
5 (-2, 0)
6 (-2, 1)
:
LOCATION4 Motion Plan is like so,
6 4 2
5 3 1
, :
Location1 = motion_plan(alternator(0, 1), increasor(0, 1))
Location2 = motion_plan(increasor(0, -1), alternator(0, -1))
Location3 = motion_plan(alternator(0, -1), increasor(0, 1))
Location4 = motion_plan(increasor(0, -1), alternator(0, 1))