mines
Loading...
Searching...
No Matches
game.cpp File Reference
module mines
#include <cstdint>
#include <exception>
#include <tuple>
#include <vector>
#include <random>
#include <optional>
Include dependency graph for game.cpp:

Classes

class  TooManyMines
 The number of mines is more than what is possible given the size of the minefield. More...
class  NoMinefield
 The board has no associated minefield. More...
class  Minefield
 Field of cells, each being either a mine or a blank space. More...
class  Board
 Game board, including the minefield, placed flags and uncovered cells. More...

Enumerations

enum class  CellType { Empty , Mine }
 Type of a cell in a minefield. More...
enum class  CellState { Hidden , Flag , Mark , Uncovered }
 State of a cell on a game board. More...

Functions

const std::vector< std::tuple< std::int32_t, std::int32_t > > solve (const Minefield &minefield, const std::vector< std::tuple< std::int32_t, std::int32_t > > &moves)
 Solve a minefield.

Enumeration Type Documentation

◆ CellState

enum class CellState
exportstrong

State of a cell on a game board.

Enumerator
Hidden 

Cell is not uncovered and not marked.

Flag 

Cell is not uncovered and flagged.

Mark 

Cell is not uncovered and marked.

Uncovered 

Cell is uncovered.

◆ CellType

enum class CellType
exportstrong

Type of a cell in a minefield.

Enumerator
Empty 

Empty cell.

Mine 

Mine cell.

Function Documentation

◆ solve()

const std::vector< std::tuple< std::int32_t, std::int32_t > > solve ( const Minefield & minefield,
const std::vector< std::tuple< std::int32_t, std::int32_t > > & moves )
export

Solve a minefield.

Parameters
minefieldMinefield to solve.
movesList of (x, y) coordinates of previously uncovered fields.
Returns
List of (x, y) coordinates of empty fields. If empty, the minefield is unsolvable.