Field of cells, each being either a mine or a blank space.
More...
|
| CellType | get_cell (std::uint32_t x, std::uint32_t y) const |
| | Get type of a cell at a position.
|
|
std::uint8_t | mines_close_to_cell (std::uint32_t x, std::uint32_t y) |
| std::uint32_t | get_width () const |
| | Get width.
|
| std::uint32_t | get_height () const |
| | Get height.
|
| std::uint32_t | get_mines () const |
| | Get the number of mines.
|
| std::uint64_t | position_to_index (std::uint32_t x, std::uint32_t y) const |
| | Convert the position of a cell to it's index in the cell list.
|
| std::uint8_t | close_mines_count (std::uint32_t x, std::uint32_t y) const |
| | Get the count of mines close to a cell.
|
| std::vector< std::tuple< std::uint32_t, std::uint32_t > > | get_adjacent (std::uint32_t x, std::uint32_t y) |
| | Get cells adjacent to a cell.
|
|
| template<typename RandomEngine> |
| static Minefield | generate (std::uint32_t width, std::uint32_t height, std::uint32_t mines, std::uint32_t start_x, std::uint32_t start_y, RandomEngine &random_engine) |
| | Construct a random minefield.
|
| template<typename RandomEngine> |
| static Minefield | generate_pure_skill (std::uint32_t width, std::uint32_t height, std::uint32_t mines, std::uint32_t start_x, std::uint32_t start_y, RandomEngine &random_engine) |
| | Construct a random minefield that does not require guessing to solve.
|
| static Minefield | from_cells (std::vector< CellType > cells, std::uint32_t width, std::uint32_t height) |
| | Construct a minefield from pregenerated cells.
|
Field of cells, each being either a mine or a blank space.
Does not define other game elements, like flags or which cells are uncovered.
◆ close_mines_count()
| std::uint8_t Minefield::close_mines_count |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) const |
|
inline |
Get the count of mines close to a cell.
Close mines are mines positioned on adjacent cells.
In game, this number is shown to the player on uncovered cells, typically unless it's equal to 0.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
- Returns
- Count of close mines.
◆ from_cells()
| Minefield Minefield::from_cells |
( |
std::vector< CellType > | cells, |
|
|
std::uint32_t | width, |
|
|
std::uint32_t | height ) |
|
inlinestatic |
Construct a minefield from pregenerated cells.
- Parameters
-
| cells | List of cells. |
| width | Width. |
| height | Height. |
- Returns
- Minefield.
◆ generate()
template<typename RandomEngine>
| Minefield Minefield::generate |
( |
std::uint32_t | width, |
|
|
std::uint32_t | height, |
|
|
std::uint32_t | mines, |
|
|
std::uint32_t | start_x, |
|
|
std::uint32_t | start_y, |
|
|
RandomEngine & | random_engine ) |
|
inlinestatic |
Construct a random minefield.
The cell at the starting position is guaranteed to not be a mine.
- Parameters
-
| width | Width. |
| height | Height. |
| mines | Amount of mines to place on the field. |
| start_x | X coordinate of starting position. |
| start_y | Y coordinate of starting position. |
| random_engine | Random engine used to generate the minefield. Must satisfy RandomNumberEngine. |
- Returns
- Minefield.
- Exceptions
-
| TooManyMines | Requested generating more mines than it is possible given the size of the minefield. |
◆ generate_pure_skill()
template<typename RandomEngine>
| Minefield Minefield::generate_pure_skill |
( |
std::uint32_t | width, |
|
|
std::uint32_t | height, |
|
|
std::uint32_t | mines, |
|
|
std::uint32_t | start_x, |
|
|
std::uint32_t | start_y, |
|
|
RandomEngine & | random_engine ) |
|
inlinestatic |
Construct a random minefield that does not require guessing to solve.
Like generate, but it's also guaranteed that a game with the minefield is possible to win without ever guessing.
- Parameters
-
| width | Width. |
| height | Height. |
| mines | Amount of mines to place on the field. |
| start_x | X position of the starting position. |
| start_y | Y position of the starting position. |
| random_engine | Random engine used to generate the minefield. Must satisfy RandomNumberEngine. |
- Returns
- Minefield.
- Exceptions
-
| TooManyMines | Requested generating more mines than it is possible given the size of the minefield. |
◆ get_adjacent()
| std::vector< std::tuple< std::uint32_t, std::uint32_t > > Minefield::get_adjacent |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) |
|
inline |
Get cells adjacent to a cell.
A cell is adjacent to another if their coordinates differ by 1 on either the x axis, the y axis, or both. This means a cell is not adjacent to itself.
- Parameters
-
| x | Cell X position. |
| y | Cell Y position. |
- Returns
- List of (x, y) coordinates of adjacent cells.
◆ get_cell()
| CellType Minefield::get_cell |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) const |
|
inline |
Get type of a cell at a position.
- Parameters
-
| x | X position. |
| y | Y position. |
- Returns
- Cell type.
◆ get_height()
| std::uint32_t Minefield::get_height |
( |
| ) |
const |
|
inline |
Get height.
- Returns
- Height.
◆ get_mines()
| std::uint32_t Minefield::get_mines |
( |
| ) |
const |
|
inline |
Get the number of mines.
- Returns
- Number of mines.
◆ get_width()
| std::uint32_t Minefield::get_width |
( |
| ) |
const |
|
inline |
◆ position_to_index()
| std::uint64_t Minefield::position_to_index |
( |
std::uint32_t | x, |
|
|
std::uint32_t | y ) const |
|
inline |
Convert the position of a cell to it's index in the cell list.
- Parameters
-
| x | X position. |
| y | Y position. |
- Returns
- Index in the cell list.
The documentation for this class was generated from the following file: