Maze Builder Docs 8.2.1
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>
7
8#include <memory>
9
12namespace mazes
13{
14 class cell;
15
21 class masked_grid : public grid
22 {
23 public:
24 // Non-copyable (contains a mask with non-trivial state)
25 masked_grid(const masked_grid&) = delete;
26 masked_grid& operator=(const masked_grid&) = delete;
27
28 masked_grid(masked_grid&&) noexcept = default;
29 masked_grid& operator=(masked_grid&&) noexcept = default;
30
33 explicit masked_grid(mask m);
34
35 ~masked_grid() override = default;
36
40 std::shared_ptr<cell> search(int index) const noexcept override;
41
44 int num_cells() const noexcept override;
45
48 const mask& get_mask() const noexcept;
49
53 std::shared_ptr<cell> random_cell(randomizer& rng) const noexcept;
54
55 private:
56 mask m_mask;
57 };
58} // namespace mazes
59
60#endif // MASKED_GRID_H
Cell class with links to other cells.
Definition cell.h:19
General purpose grid class for 2D maze generation.
Definition grid.h:25
2D boolean mask for controlling which cells are available in maze generation
Definition mask.h:19
A grid that restricts cell availability based on a boolean mask.
Definition masked_grid.h:22
int num_cells() const noexcept override
Return the number of available (unmasked) cells.
masked_grid(mask m)
Construct a masked grid from a mask object.
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:15