Work-in-progress library for making Minesweeper boards. Actually playing Minesweeper is dependent on the the program that uses this crate.
Inside your project's Cargo.toml
:
# ...
[dependencies]
mines = { git = "https://github.com/ben01189998819991197253/mines-rs.git" }
git clone https://github.com/ben01189998819991197253/mines-rs.git
cd mines-rs
cargo test && cargo build
See the documentation by running:
cargo doc --no-deps --open
in the crate root. It will automatically open in your default web browser.
Assuming you've included the crate with your project:
extern crate mines;
use mines::Board;
fn main() {
// Default 8x8 grid with 10 mines
let board = Board::default();
// Reveal the tile at (0, 4)
let index = board.linear_coords((0, 4));
// Revealing a tile returns a Result<_, &'static str> depending on
// whether it was able to flood-reveal the tiles
let result = board.reveal_tile(index);
assert_eq!(Ok(()), result);
println!("{}", board);
}
Example output:
????????
12??????
.124????
...2????
...2????
...111??
11...1??
?1...1??
...is welcomed! Please submit any and all pull requests or issues.
Running your code through rustfmt
would be nice.
Dual-licensed under the MIT or Apache v2.0 Licenses, at your
preference. See LICENSE-MIT
or LICENSE-APACHE
for details.