Struct sweeprs::Board[][src]

pub struct Board { /* fields omitted */ }
Expand description

Default implementation of the SweeperBoard trait

Implementations

Helper methods to help implement the trait

A convenient alias from self.cells.len().

A convenient alias from self.cells[0].len(). Guarateed to return because the height of the board is never less than 9.

Trait Implementations

Create a new minesweeper board. height and width cannot be under 9, while mine_count cannot exceed height * width - 9 since the initial cell and its neighbors must be a free cell. Return error if given invalid configuration.

Open a cell, propagate if all neighboring cell is a free cell. Opening an opened cell will propagate if flagged cell count is equal to surrounding mine count.

Propagation is stopped when propagation reached a mine cell.

Flag a cell. Flagged cell cannot be opened until unflagged. Remove the flag by flagging a flagged cell again. Flagged cell counts toward opening an opened cell propagation.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.