Expand description
§Mine sweeper
A minimalist interface to manage the backend of a mine sweeper game.
Import MineSweeper
and one of its implementations
(MSMatrix
or MSHash
) to use it.
You can also create your own implementation, if you prefer:
this crate already declares the needed functions and types to create and manage a mine sweeper game.
IMPORTANT: This crate supports wasm but, in that case, seeded random generators (or in general the rand crate) are not allowed due to incompatibility with wasm itself. Maybe in future versions some kind of trick will be implemented to make it work. A working implementation of this library with wasm frontend is available on my GitHub page
Structs§
- Cell
- A cell with its
state
andcontent
. - MSHash
- Represents a grid using
HashSets
ofCoordinates
. Use this when you don’t want to load the whole grid in memory at the beginning. Has lower performances when opening cells but takes less memory. - MSMatrix
- Represents the grid using a matrix of
cells
. Use this when you want to load the whole grid in memory at the beginning. Has higher performances when opening cells but takes more memory. - Open
Result - The result of opening a
cell
.
Enums§
- Cell
Content - The content of a
cell
. - Cell
State - The state of a
cell
. - Error
- Error type for the
MineSweeper
game.
Traits§
- Mine
Sweeper - Represents a board with its cells.
Functions§
- iter_
neighbors - Returns an iterator over the neighbors of the given cell.
If the coordinates are out of bounds returns
OutOfBounds
. You can safely unwrap the result if you are sure that the given coordinates are in bounds.
Type Aliases§
- Coordinate
- A pair of zero-based coordinates. The first coordinate is the row, the second is the column.
- Result
- The result of some potentially dangerous action.