Maze Builder Docs 8.8.13
Loading...
Searching...
No Matches
masked_grid.h
Go to the documentation of this file.
1#ifndef MASKED_GRID_H
2#define MASKED_GRID_H
3
4#include <MazeBuilder/grid.h>
5#include <MazeBuilder/mask.h>
6
7#include <memory>
8
11namespace mazes
12{
13 class cell;
14 class randomizer;
15
21 class masked_grid : public grid
22 {
23 public:
28 explicit masked_grid(
29 unsigned int width = 1u,
30 unsigned int length = 1u,
31 unsigned int height = 1u
32 );
33
36 explicit masked_grid(mask m);
37
38 ~masked_grid() override = default;
39
40 masked_grid(const masked_grid &) = delete;
41 masked_grid &operator=(const masked_grid &) = delete;
42
43 masked_grid(masked_grid &&) noexcept = default;
44 masked_grid &operator=(masked_grid &&) noexcept = default;
45
48 [[nodiscard]] std::size_t num_cells() const noexcept override;
49
53 std::shared_ptr<cell> search(int index) const noexcept override;
54
57 const mask &get_mask() const noexcept;
58
62 std::shared_ptr<cell> random_cell(randomizer &rng) const noexcept;
63
64 private:
65 mask m_mask;
66 };
67} // namespace mazes
68
69#endif // MASKED_GRID_H
Cell class with links to other cells.
Definition cell.h:18
grid(unsigned int rows=1u, unsigned int columns=1u, unsigned int levels=1u)
Construct a grid using unsigned integers.
2D boolean mask for controlling which cells are available in maze generation
Definition mask.h:20
std::size_t num_cells() const noexcept override
Get the number of available cells in the masked grid.
masked_grid(unsigned int width=1u, unsigned int length=1u, unsigned int height=1u)
Constructs a masked grid with specified dimensions.
masked_grid(mask m)
Constructs a masked grid sized to the given mask.
std::shared_ptr< cell > search(int index) const noexcept override
Search for a cell by index, respecting the mask.
std::shared_ptr< cell > random_cell(randomizer &rng) const noexcept
Return a random available cell based on the mask.
const mask & get_mask() const noexcept
Access the mask used by this grid.
Provides random-number generating capabilities.
Definition randomizer.h:16