VirtualTurtle/abrivan | VirtualTurtle/Stephan | ||||
---|---|---|---|---|---|
n | 1 | def turtle(poz, ppoz): | n | 1 | def turtle(m, u): |
2 | x = poz[0] | 2 | a = m[0] | ||
3 | y = poz[1] | 3 | b = m[1] | ||
4 | mest = yield ppoz | 4 | dirr = yield u | ||
5 | while mest: | 5 | while dirr: | ||
6 | if mest == 'f': | 6 | if dirr == 'f': | ||
7 | if ppoz == 0: | 7 | if u == 0: | ||
8 | x += 1 | 8 | a += 1 | ||
9 | elif ppoz == 1: | 9 | elif u == 1: | ||
10 | y += 1 | 10 | b += 1 | ||
11 | elif ppoz == 2: | 11 | elif u == 2: | ||
12 | x -= 1 | 12 | a -= 1 | ||
13 | else: | 13 | else: | ||
n | 14 | y -= 1 | n | 14 | b -= 1 |
15 | elif mest == 'l': | 15 | elif dirr == 'l': | ||
16 | if ppoz == 0: | 16 | if u == 0: | ||
17 | ppoz = 1 | 17 | u = 1 | ||
18 | elif ppoz == 1: | 18 | elif u == 1: | ||
19 | ppoz = 2 | 19 | u = 2 | ||
20 | elif ppoz == 2: | 20 | elif u == 2: | ||
21 | ppoz = 3 | 21 | u = 3 | ||
22 | elif ppoz == 3: | 22 | elif u == 3: | ||
23 | ppoz = 0 | 23 | u = 0 | ||
24 | else: | 24 | else: | ||
n | 25 | if ppoz == 0: | n | 25 | if u == 0: |
26 | ppoz = 3 | 26 | u = 3 | ||
27 | elif ppoz == 1: | 27 | elif u == 1: | ||
28 | ppoz = 0 | 28 | u = 0 | ||
29 | elif ppoz == 2: | 29 | elif u == 2: | ||
30 | ppoz = 1 | 30 | u = 1 | ||
31 | else: | 31 | else: | ||
t | 32 | ppoz = 2 | t | 32 | u = 2 |
33 | mest = yield(x, y) | 33 | dirr = yield(a, b) | ||
34 | 34 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|