RandomMaze

This module provides a random maze with no holes, i.e., in which all cells of the grid are accessible. Walls and mud are placed randomly. It is also the base class of random mazes with holes, which only redefine how cells are added.

class RandomMaze(wall_percentage, mud_percentage, mud_range=None, random_seed=None, *args, **kwargs)[source]

(This class inherits from Maze ).

A random maze is a maze that is created randomly. All cells of the grid are accessible (there are no holes), and walls and mud are placed randomly. You can specify the size of the maze, the density of walls and mud, and the range of the mud values. You can also specify a random seed to reproduce the same maze later.

This class is also the base class of random mazes with holes (BigHolesRandomMaze, UniformHolesRandomMaze and HolesOnSideRandomMaze). They redefine the _add_cells(...) method, and receive an additional cell_percentage argument. Since the maze is generated by the constructor of this class, the attributes they need to add cells must be set before calling it.

__init__(wall_percentage, mud_percentage, mud_range=None, random_seed=None, *args, **kwargs)[source]

Initializes a new instance of the class, and generates the maze.

Parameters:
  • wall_percentage (float) – Percentage of walls to be present.

  • mud_percentage (float) – Percentage of mud to be present.

  • mud_range (tuple[int, int] | None) – Range of the mud values (optional if mud_percentage = 0.0).

  • random_seed (int | None) – Random seed for the maze generation, set to None for a random value.

  • args (object) – Arguments to pass to the parent constructor (in particular, the width and height of the maze).

  • kwargs (object) – Keyword arguments to pass to the parent constructor (in particular, the width and height of the maze).