Algorithms#

Maze-Solvers#

class mazely.algorithms.MazeSolver#

A base class for maze-solving algorithms.

solve(grid, start, goal)#

An abstract method to solve a maze.

Parameters:
  • grid (ndarray) – A two-dimensional array of cells representing a rectangular maze.

  • start (tuple[int, int]) – The location of the start cell.

  • goal (set[tuple[int, int]]) – The location(s) of the goal cell(s).

Raises:

NotImplementedError – If the method has not been implemented in a subclass.

class mazely.algorithms.ShortestPath#

A maze-solving algorithm that finds the shortest path using breadth-first search.

solve(grid, start, goal)#

Solve the maze.

Parameters:
  • grid (ndarray) – A two-dimensional array of cells representing a rectangular maze.

  • start (tuple[int, int]) – The location of the start cell.

  • goal (set[tuple[int, int]]) – The location(s) of the goal cell(s).

Returns:

An ordered list of cell locations representing the solution path.

Return type:

list[tuple[int, int]]

Maze-Generators#

class mazely.algorithms.MazeGenerator#

A base class for maze-generating algorithms.

generate(rows, columns, seed=None)#

An abstract method to generate a maze.

Parameters:
  • rows (int) – The total number of rows of the maze.

  • columns (int) – The total number of columns of the maze.

  • seed (int, optional) – The seed value used to initialize the random number generator. Defaults to None.

Raises:

NotImplementedError – If the method has not been implemented in a subclass.

class mazely.algorithms.RecursiveBacktracking#

A maze-generating algorithm that creates a perfect maze using a randomized version of depth-first search.

generate(rows, columns, seed=None)#

Generate a maze.

Parameters:
  • rows (int) – The total number of rows of the maze.

  • columns (int) – The total number of columns of the maze.

  • seed (int, optional) – The seed value used to initialize the random number generator. Defaults to None

Returns:

A two-dimensional array of cells representing a rectangular maze.

Return type:

ndarray