Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d0x2f/casspir.rs
Minesweeper puzzle generator and solver.
https://github.com/d0x2f/casspir.rs
minesweeper puzzle rust solver
Last synced: 12 days ago
JSON representation
Minesweeper puzzle generator and solver.
- Host: GitHub
- URL: https://github.com/d0x2f/casspir.rs
- Owner: d0x2f
- License: lgpl-3.0
- Created: 2018-06-30T10:25:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-24T03:14:20.000Z (almost 4 years ago)
- Last Synced: 2024-11-04T03:22:34.709Z (about 2 months ago)
- Topics: minesweeper, puzzle, rust, solver
- Language: Rust
- Size: 25.4 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Casspir.rs
[![Build Status](https://travis-ci.org/d0x2f/Casspir.rs.svg?branch=master)](https://travis-ci.org/d0x2f/Casspir.rs)
[![Coverage Status](https://coveralls.io/repos/github/d0x2f/Casspir.rs/badge.svg)](https://coveralls.io/github/d0x2f/Casspir.rs)Minesweeper puzzle generator and solver.
It's not perfect and there are improvements possible, some of which you may be able to notice from the video [here](https://www.youtube.com/watch?v=qlBwNXP5lfM).
## Usage Example
A simple program that uses the library might look like this:
```rust
// Generate a random map.
let mut map = map::generate_map_with_difficulty(5, 5, 100, point::Point { x: 2, y: 3 });// Print the begining map state.
println!("Puzzle Start:");
map.print(&mut std::io::stdout(), false).unwrap();// Run the solver
let moves = solver::solve(&map);// Print each step of the solution.
println!("\nSolution:");
for play in &moves {
let move_type;
if play.move_type == solver::MoveType::Flip {
move_type = "Flip";
} else {
move_type = "Flag";
}
println!("{} ({},{})", move_type, play.position.x, play.position.y);
}// Apply the moves to the map.
map.apply_moves(&moves);// Print the final (hopefully solved) state.
println!("\nPuzzle End:");
map.print(&mut std::io::stdout(), false).unwrap();if *map.get_status() == map::Status::Complete {
println!("\nSuccess!");
} else {
println!("\nFailure :(");
}
```Which would produce results like so:
```
$ casspir-example
Puzzle Start:#####
#####
#####
##2##
#####Solution:
Flip (3,3)
Flag (2,1)
Flip (1,3)
Flip (1,1)
Flip (2,0)
Flag (1,2)
Flag (1,4)
Flag (3,0)
Flag (1,0)
Flip (1,1)
Flip (3,1)
Flip (0,2)
Flip (0,3)Puzzle End:
1^3^1
23^21
1^210
22200
1^100Success!
```---
Ported to rust from [Casspir](https://github.com/d0x2f/Casspir).