MazeGenerator.Grid (maze_generator v0.1.0) View Source
Represents a grid of cells. The width and height represent the size of the grid. The cells are a map of cells with an {x, y} tuple key representing the cell location.
The borders are horizontal and vertical borders that represent the borders between cells, which are shared by cells, stored as an {x, y} tuple in the :borders map under :h and :v keys. Horizontal borders (:h) are those whose bars lie horizontal and are the separators between vertically aligned cells. Vertical borders (:v) are those whose bars lie vertical and are the separators between horizontally aligned cells.
Link to this section Summary
Functions
Creates a new Grid of the specified dimensions. Initializes the borders as walls and sets the state to :uninitialized since the path has not been carved.
Opens a passage in the border between two adjacent cells. If the cells are not adjacent or are the same cell, it does nothing.
Records the algorithm specified in the meta section of the grid along with the date and time.
Link to this section Types
Specs
state() :: :valid | :uninitialized | :invalid_width_height | :no_paths
Specs
t() :: %MazeGenerator.Grid{
borders: map(),
cells: map(),
height: pos_integer(),
meta: map(),
paths: map(),
state: state(),
width: pos_integer()
}
Link to this section Functions
Creates a new Grid of the specified dimensions. Initializes the borders as walls and sets the state to :uninitialized since the path has not been carved.
Specs
open_passage( t(), {pos_integer(), pos_integer()}, {pos_integer(), pos_integer()} ) :: t()
Opens a passage in the border between two adjacent cells. If the cells are not adjacent or are the same cell, it does nothing.
Specs
Records the algorithm specified in the meta section of the grid along with the date and time.