In [1]:
# Imports
import matplotlib.pyplot as plt
from maze_dataset.generation import LatticeMazeGenerators
from maze_dataset.plotting import MazePlot
Generate maze using depth first search¶
Constrain number of accessible cells
Only applying this constrain tends to yield mazes with few forks.
In [2]:
sample_lattice_maze = LatticeMazeGenerators.gen_dfs(
grid_shape=(6, 6),
lattice_dim=2,
accessible_cells=20,
max_tree_depth=None,
start_coord=None,
)
MazePlot(sample_lattice_maze).plot()
plt.show()
Constrain maximum tree depth
In [3]:
sample_lattice_maze = LatticeMazeGenerators.gen_dfs(
grid_shape=(6, 6),
lattice_dim=2,
accessible_cells=None,
max_tree_depth=5,
start_coord=(0, 0),
)
MazePlot(sample_lattice_maze).plot()
plt.show()
Shift start coord of DFS algorithm
In [4]:
sample_lattice_maze = LatticeMazeGenerators.gen_dfs(
grid_shape=(6, 6),
lattice_dim=2,
accessible_cells=None,
max_tree_depth=None,
start_coord=None,
)
MazePlot(sample_lattice_maze).plot()
plt.show()
All constraints enabled
In [5]:
sample_lattice_maze = LatticeMazeGenerators.gen_dfs(
grid_shape=(10, 10),
lattice_dim=2,
accessible_cells=20,
max_tree_depth=5,
start_coord=(5, 5),
)
MazePlot(sample_lattice_maze).plot()
plt.show()