31 lines
844 B
Python
31 lines
844 B
Python
|
|
from models import Cell, Maze
|
||
|
|
|
||
|
|
# Создаем лабиринт 3x3
|
||
|
|
maze = Maze(3, 3)
|
||
|
|
|
||
|
|
# Создаем клетки
|
||
|
|
for y in range(3):
|
||
|
|
for x in range(3):
|
||
|
|
cell = Cell(x, y, is_wall=False)
|
||
|
|
maze.set_cell(x, y, cell)
|
||
|
|
|
||
|
|
# Устанавливаем старт и выход
|
||
|
|
maze.start = maze.get_cell(0, 0)
|
||
|
|
maze.start.is_start = True
|
||
|
|
maze.exit = maze.get_cell(2, 2)
|
||
|
|
maze.exit.is_exit = True
|
||
|
|
|
||
|
|
#Создаем стену в центре
|
||
|
|
center = maze.get_cell(1, 1)
|
||
|
|
center.is_wall = True
|
||
|
|
|
||
|
|
print(f"Лабиринт: {maze}")
|
||
|
|
print(f"Старт: {maze.start}")
|
||
|
|
print(f"Выход: {maze.exit}")
|
||
|
|
|
||
|
|
# Проверяем соседей
|
||
|
|
neighbors = maze.get_neighbors(maze.start)
|
||
|
|
print(f"Соседи старта: {neighbors}")
|
||
|
|
|
||
|
|
# Проверяем проходимость
|
||
|
|
print(f"Центр проходим? {center.is_passable()}")
|