15#include <unordered_map>
36 explicit grid(
unsigned int r = 1u,
unsigned int c = 1u,
unsigned int l = 1u);
40 explicit grid(std::tuple<unsigned int, unsigned int, unsigned int> dimens);
66 virtual void configure(
const std::vector<int>& indices)
noexcept;
77 std::vector<std::shared_ptr<cell>>
get_neighbors(std::shared_ptr<cell>
const& c)
const noexcept;
79 void set_neighbor(
const std::shared_ptr<cell>& c,
Direction dir, std::shared_ptr<cell>
const& neighbor)
noexcept;
82 std::shared_ptr<cell> get_north(
const std::shared_ptr<cell>& c)
const noexcept override;
84 std::shared_ptr<cell> get_south(
const std::shared_ptr<cell>& c)
const noexcept override;
86 std::shared_ptr<cell> get_east(
const std::shared_ptr<cell>& c)
const noexcept override;
88 std::shared_ptr<cell> get_west(
const std::shared_ptr<cell>& c)
const noexcept override;
92 virtual std::tuple<unsigned int, unsigned int, unsigned int>
get_dimensions() const noexcept override;
96 virtual
void to_vec(std::vector<std::shared_ptr<
cell>>& cells) const noexcept override;
101 virtual std::
string contents_of(std::shared_ptr<
cell>const & c) const noexcept override;
122 void configure_cells(std::vector<std::shared_ptr<
cell>>& cells) noexcept;
125 std::function<
int(
unsigned int,
unsigned int)> m_calculate_cell_index;
128 std::unordered_map<
int, std::shared_ptr<
cell>> m_cells;
129 std::tuple<
unsigned int,
unsigned int,
unsigned int> m_dimensions;
133 mutable std::mutex m_topology_mutex;
134 std::unordered_map<
int, std::unordered_map<
Direction,
int>> m_topology;
136 std::atomic<
bool> m_configured;
Binary tree algorithm for generating mazes.
Definition binary_tree.h:17
Cell class for maze generation - only stores its index and links to other cells.
Definition cell.h:17
Depth-first search algorithm for generating mazes.
Definition dfs.h:23
Interface for the grid class.
Definition grid_interface.h:26
General purpose grid class for 2D maze generation.
Definition grid.h:23
std::vector< std::shared_ptr< cell > > get_neighbors(std::shared_ptr< cell > const &c) const noexcept
Get all the neighbors by the cell.
virtual void configure(const std::vector< int > &indices) noexcept
Configure the grid's cells' neighbors.
grid(const grid &other)
Copy constructor.
virtual std::tuple< unsigned int, unsigned int, unsigned int > get_dimensions() const noexcept override
Provides dimensions of grid in no assumed ordering.
virtual void to_vec(std::vector< std::shared_ptr< cell > > &cells) const noexcept override
Convert a 2D grid to a vector of cells (sorted by row then column)
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.
grid(unsigned int r=1u, unsigned int c=1u, unsigned int l=1u)
grid & operator=(const grid &other)
Assignment operator.
void clear_cells() noexcept
Cleanup cells by cleaning up links within cells.
grid & operator=(grid &&other) noexcept
Move assignment operator.
int num_cells() const noexcept
Get the count of cells in the grid.
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.
std::shared_ptr< cell > get_neighbor(std::shared_ptr< cell > const &c, Direction dir) const noexcept
Get neighbor by the cell's respective location.
std::shared_ptr< cell > search(int index) const noexcept
~grid() override
Destructor.
Sidewinder algorithm for generating mazes.
Definition sidewinder.h:17
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