-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtile_utils.py
More file actions
47 lines (30 loc) · 840 Bytes
/
tile_utils.py
File metadata and controls
47 lines (30 loc) · 840 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def fill(tile, direction):
tile.find(direction)
while tile.neighbors[direction] is not None:
tile = tile.neighbors[direction]
tile.find(direction)
def get_row(tile):
ts = []
while tile.neighbors['left'] is not None:
tile = tile.neighbors['left']
while tile is not None:
ts.append(tile)
tile = tile.neighbors['right']
return ts
def get_col(tile):
ts = []
tile = go(tile, 'up')
while tile is not None:
ts.append(tile)
tile = tile.neighbors['down']
return ts
def go(tile, direction):
while tile.neighbors[direction] is not None:
tile = tile.neighbors[direction]
return tile
def go_to_top_left(tile):
fill(tile, 'up')
tile = go(tile, 'up')
fill(tile, 'left')
tile = go(tile, 'left')
return tile