Generate a maze using Python
Download this repository, then use maze.py
as below:
import matplotlib.pyplot as plt
import numpy as np
from maze import Maze
maze=np.zeros(shape=(100,100))
start_point=np.array([0,0])
maze_generator=Maze(maze, start_point)
plt.imshow(maze_generator.maze)
import cv2
pic = cv2.imread('duck.jfif')
pic = cv2.cvtColor(pic, cv2.COLOR_BGR2GRAY)
pic = cv2.resize(pic, (100, 100))
pic = (pic > pic.mean()) * (-1)
from maze import Maze
start_point=np.array([50,50])
maze_generator=Maze(pic, start_point)
plt.imshow(maze_generator.maze)
If you want to know why it works, see here