forked from UNN/2026-rff_mp
24 lines
647 B
Python
24 lines
647 B
Python
class Maze:
|
|
def __init__(self, width, height, cells, start, exit_):
|
|
self.width = width
|
|
self.height = height
|
|
self.cells = cells
|
|
self.start = start
|
|
self.exit = exit_
|
|
|
|
def get_cell(self, x, y):
|
|
return self.cells[y][x]
|
|
|
|
def get_neighbors(self, cell):
|
|
dirs = [(1,0), (-1,0), (0,1), (0,-1)]
|
|
result = []
|
|
|
|
for dx, dy in dirs:
|
|
nx, ny = cell.x + dx, cell.y + dy
|
|
if 0 <= nx < self.width and 0 <= ny < self.height:
|
|
n = self.get_cell(nx, ny)
|
|
if not n.is_wall:
|
|
result.append(n)
|
|
|
|
return result
|