2D boolean mask for controlling which cells are available in maze generation
More...
#include <mask.h>
|
| | mask (unsigned int rows, unsigned int columns) |
| | Construct a mask with specified dimensions, all cells enabled.
|
| |
|
| mask (const mask &)=default |
| |
|
mask & | operator= (const mask &)=default |
| |
|
| mask (mask &&) noexcept=default |
| |
|
mask & | operator= (mask &&) noexcept=default |
| |
| bool | operator() (unsigned int row, unsigned int column) const noexcept |
| | Check if a cell at (row, column) is available.
|
| |
| void | set (unsigned int row, unsigned int column, bool is_on) noexcept |
| | Set a cell's availability.
|
| |
| int | count () const noexcept |
| | Count the number of available cells.
|
| |
| std::pair< unsigned int, unsigned int > | random_location (randomizer &rng) const noexcept |
| | Get a random available cell location.
|
| |
| unsigned int | rows () const noexcept |
| | Get the number of rows.
|
| |
| unsigned int | columns () const noexcept |
| | Get the number of columns.
|
| |
|
| static mask | from_txt (const std::string &filename) |
| | Load a mask from a text file.
|
| |
2D boolean mask for controlling which cells are available in maze generation
Cells marked as blocked (false) are excluded from maze generation. "X" characters in text files denote blocked cells.
◆ mask()
| mazes::mask::mask |
( |
unsigned int | rows, |
|
|
unsigned int | columns ) |
|
explicit |
Construct a mask with specified dimensions, all cells enabled.
- Parameters
-
| rows | Number of rows |
| columns | Number of columns |
◆ columns()
| unsigned int mazes::mask::columns |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Get the number of columns.
- Returns
- Number of columns
◆ count()
| int mazes::mask::count |
( |
| ) |
const |
|
noexcept |
Count the number of available cells.
- Returns
- Number of available cells
◆ from_txt()
| static mask mazes::mask::from_txt |
( |
const std::string & | filename | ) |
|
|
static |
Load a mask from a text file.
- Parameters
-
| filename | Path to the text file ('X' = blocked, other = available) |
- Returns
- A mask loaded from the file
- Exceptions
-
| std::runtime_error | if the file cannot be opened or is empty |
- Note
- Lines of different lengths are supported; shorter rows default to available
◆ operator()()
| bool mazes::mask::operator() |
( |
unsigned int | row, |
|
|
unsigned int | column ) const |
|
noexcept |
Check if a cell at (row, column) is available.
- Parameters
-
| row | Row index |
| column | Column index |
- Returns
- true if available, false if blocked or out of bounds
◆ random_location()
| std::pair< unsigned int, unsigned int > mazes::mask::random_location |
( |
randomizer & | rng | ) |
const |
|
noexcept |
Get a random available cell location.
- Parameters
-
- Returns
- A pair (row, col) of a random available cell
- Precondition
- count() > 0 — callers must ensure at least one cell is available
◆ rows()
| unsigned int mazes::mask::rows |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Get the number of rows.
- Returns
- Number of rows
◆ set()
| void mazes::mask::set |
( |
unsigned int | row, |
|
|
unsigned int | column, |
|
|
bool | is_on ) |
|
noexcept |
Set a cell's availability.
- Parameters
-
| row | Row index |
| column | Column index |
| is_on | true to enable, false to block |
The documentation for this class was generated from the following file: