Maze Builder Docs 8.2.1
Loading...
Searching...
No Matches
mask.h
Go to the documentation of this file.
1#ifndef MASK_H
2#define MASK_H
3
5
6#include <string>
7#include <utility>
8#include <vector>
9
12namespace mazes
13{
18 class mask
19 {
20 public:
24 explicit mask(unsigned int rows, unsigned int columns);
25
26 ~mask() = default;
27
28 mask(const mask&) = default;
29 mask& operator=(const mask&) = default;
30
31 mask(mask&&) noexcept = default;
32 mask& operator=(mask&&) noexcept = default;
33
38 bool operator()(unsigned int row, unsigned int column) const noexcept;
39
44 void set(unsigned int row, unsigned int column, bool is_on) noexcept;
45
48 int count() const noexcept;
49
54 std::pair<unsigned int, unsigned int> random_location(randomizer& rng) const noexcept;
55
58 [[nodiscard]] unsigned int rows() const noexcept { return m_rows; }
59
62 [[nodiscard]] unsigned int columns() const noexcept { return m_columns; }
63
69 static mask from_txt(const std::string& filename);
70
71 private:
72 unsigned int m_rows;
73 unsigned int m_columns;
74 std::vector<std::vector<bool>> m_bits;
75 };
76} // namespace mazes
77
78#endif // MASK_H
2D boolean mask for controlling which cells are available in maze generation
Definition mask.h:19
void set(unsigned int row, unsigned int column, bool is_on) noexcept
Set a cell's availability.
static mask from_txt(const std::string &filename)
Load a mask from a text file.
std::pair< unsigned int, unsigned int > random_location(randomizer &rng) const noexcept
Get a random available cell location.
unsigned int columns() const noexcept
Get the number of columns.
Definition mask.h:62
int count() const noexcept
Count the number of available cells.
unsigned int rows() const noexcept
Get the number of rows.
Definition mask.h:58
mask(unsigned int rows, unsigned int columns)
Construct a mask with specified dimensions, all cells enabled.
Provides random-number generating capabilities.
Definition randomizer.h:15