1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Python 3.2.3 (default, Feb 27 2014, 21:33:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> OFFSETS = ((0, -1), (-1, 0), (0, 1), (1, 0))
>>> def voisin(x, y):
... for i in range(4):
... yield x + OFFSETS[i][0], y + OFFSETS[i][1]
...
>>> bombx = 5
>>> bomby = 3
>>> vs = voisin(bombx, bomby)
>>> print("Nord: %s, %s" % next(vs))
Nord: 5, 2
>>> print("Ouest: %s, %s" % next(vs))
Ouest: 4, 3
>>> print("Sud: %s, %s" % next(vs))
Sud: 5, 4
>>> print("Est: %s, %s" % next(vs))
Est: 6, 3
>>> |
Partager