-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroup.py
More file actions
49 lines (40 loc) · 1.28 KB
/
Copy pathgroup.py
File metadata and controls
49 lines (40 loc) · 1.28 KB
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
47
48
49
"""
A class used to represent a single grouping of coordinates in a Kavanaugh
Map. Each Group has a size, a list of coordinates inside, adjacent groups, and
the coordinates of the adjacent groups
"""
class Group:
"""
Creates the global variables
"""
def __init__(self, size, coord_list):
self.size = size
self.coord_list = coord_list
self.adjacent_groups = 0
self.adjacent_group_coords = []
"""
Gets the adjacent coordinates to this Group. Only called
if size equals 1
Returns: Tuple(left,right,up,down) adjacent coords
"""
def get_adjacent_coords(self):
if self.size == 1:
row = self.coord_list[0]
col = self.coord_list[1]
if row > 0:
left = (row-1, col)
else:
left = (3, col)
if col > 0:
down = (row, col-1)
else:
down = (row, 3)
if row < 3:
right = (row+1, col)
else:
right = (0, col)
if col < 3:
up = (row, col+1)
else:
up = (row, 0)
return [left, right, up, down]