16#include <unordered_map>
39 explicit grid(
unsigned int r = 1u,
unsigned int c = 1u,
unsigned int l = 1u);
43 explicit grid(std::tuple<unsigned int, unsigned int, unsigned int> dimens);
69 virtual std::string
contents_of(std::shared_ptr<cell>
const & c)
const noexcept override;
84 std::tuple<
unsigned int,
unsigned int,
unsigned int>
get_dimensions() const noexcept override;
95 virtual std::vector<std::shared_ptr<
cell>>
get_neighbors(std::shared_ptr<
cell> const& c) const noexcept override;
106 void sort(std::vector<std::shared_ptr<
cell>>& cells) const noexcept override;
109 virtual std::shared_ptr<
cell> get_north(const std::shared_ptr<
cell>& c) const noexcept override;
110 virtual std::shared_ptr<
cell> get_south(const std::shared_ptr<
cell>& c) const noexcept override;
111 virtual std::shared_ptr<
cell> get_east(const std::shared_ptr<
cell>& c) const noexcept override;
112 virtual std::shared_ptr<
cell> get_west(const std::shared_ptr<
cell>& c) const noexcept override;
117 virtual std::shared_ptr<
cell>
search(
int index) const noexcept override;
119 virtual std::vector<std::shared_ptr<
cell>>
get_cells() const noexcept override;
131 virtual
bool set_cells(const std::vector<std::shared_ptr<
cell>>& cells) noexcept override;
133 virtual
void set_str(std::
string const& str) noexcept override;
135 virtual std::
string get_str() const noexcept override;
140 std::function<
int(
unsigned int,
unsigned int)> m_calculate_cell_index;
142 std::unordered_map<
int, std::shared_ptr<
cell>> m_cells;
144 std::tuple<
unsigned int,
unsigned int,
unsigned int> m_dimensions;
148 mutable std::mutex m_topology_mutex;
149 std::unordered_map<
int, std::unordered_map<
Direction,
int>> m_topology;
151 std::atomic<
bool> m_configured;
Binary tree algorithm for generating mazes.
Definition binary_tree.h:16
Cell class with links to other cells.
Definition cell.h:17
Depth-first search algorithm for generating mazes.
Definition dfs.h:20
Interface for the grid class.
Definition grid_interface.h:18
Interface for grid navigation and manipulation operations.
Definition grid_operations.h:16
General purpose grid class for 2D maze generation.
Definition grid.h:26
grid_operations & operations() noexcept override
grid(const grid &other)
Copy constructor.
virtual std::shared_ptr< cell > search(int index) const noexcept override
Search for a cell by index.
virtual void clear_cells() noexcept override
Cleanup cells by cleaning up links within cells.
virtual std::uint32_t background_color_for(std::shared_ptr< cell > const &c) const noexcept override
Get the background color for a cell in the grid.
virtual bool set_cells(const std::vector< std::shared_ptr< cell > > &cells) noexcept override
Set cells and build topology from them.
virtual std::vector< std::shared_ptr< cell > > get_cells() const noexcept override
Retrieves a collection of cell objects.
grid(unsigned int r=1u, unsigned int c=1u, unsigned int l=1u)
grid & operator=(const grid &other)
Assignment operator.
grid & operator=(grid &&other) noexcept
Move assignment operator.
std::tuple< unsigned int, unsigned int, unsigned int > get_dimensions() const noexcept override
Retrieves the dimensions as a tuple of three unsigned integers.
virtual std::shared_ptr< cell > get_neighbor(std::shared_ptr< cell > const &c, Direction dir) const noexcept override
Get neighbor by the cell's respective location.
grid(std::tuple< unsigned int, unsigned int, unsigned int > dimens)
grid(grid &&other) noexcept
Move constructor.
virtual std::string contents_of(std::shared_ptr< cell >const &c) const noexcept override
Get detailed information of a cell in the grid.
void sort(std::vector< std::shared_ptr< cell > > &cells) const noexcept override
Transformation and display cells.
virtual int num_cells() const noexcept override
Get the count of cells in the grid.
~grid() override
Destructor.
virtual void set_neighbor(const std::shared_ptr< cell > &c, Direction dir, std::shared_ptr< cell > const &neighbor) noexcept override
Set neighbor for a cell in a given direction.
virtual std::vector< std::shared_ptr< cell > > get_neighbors(std::shared_ptr< cell > const &c) const noexcept override
Get all the neighbors by the cell.
Sidewinder algorithm for generating mazes.
Definition sidewinder.h:16
Enumerations for the maze builder program.
Namespace for the maze builder.
Definition algo_interface.h:9
Direction
Directional neighbors for grid topology.
Definition enums.h:118