2022-04-29 16:07:21 -05:00
|
|
|
class BoardUtils:
|
|
|
|
def findOccupied(board):
|
|
|
|
occupied = []
|
|
|
|
for i in board:
|
|
|
|
pos = i.getCoords()
|
|
|
|
dims = i.dims
|
|
|
|
for j in range(dims[0]):
|
|
|
|
for k in range(dims[1]):
|
|
|
|
occupied.append([pos[0] + j, pos[1] + k])
|
|
|
|
return occupied
|
|
|
|
def surround(pos, radius=1):
|
|
|
|
surrounding = []
|
2022-04-29 16:10:40 -05:00
|
|
|
for i in range(-1 * radius, radius + 1, 1):
|
|
|
|
for j in range(-1 * radius, radius + 1, 1):
|
2022-04-29 16:07:21 -05:00
|
|
|
surrounding.append([pos[0] + i, pos[1] + j])
|
|
|
|
|
|
|
|
return surrounding
|
|
|
|
def tileAtPosition(board, pos):
|
|
|
|
for i in board:
|
|
|
|
lpos = i.getCoords()
|
|
|
|
dims = i.dims
|
|
|
|
if not dims:
|
|
|
|
dims = [1, 1]
|
|
|
|
for j in range(dims[0]):
|
|
|
|
for k in range(dims[1]):
|
|
|
|
if [lpos[0] + j, lpos[1] + k] == pos:
|
|
|
|
return i
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|