A simple mine sweeper in console with auto-playing algorithm.
- python3
- termcolor==1.1.0
- tqdm==4.32.1
- matplotlib==3.0.3
- Inference: whether unknown cells around a known cell are all mines / clean.
- Inference based on searching all feasible solutions.
- Use Union-Find algorithm to distinctive group constraints.
- Use backtracking algorithm to find all feasible solutions in all cell groups.
- For sake of efficiency, we won't try to find solutions for cells more than 40 (could be modified in
auto/find_solutions.py
).
- For sake of efficiency, we won't try to find solutions for cells more than 40 (could be modified in
- Remove impossible solutions whose number of mines is larger than number of remain mines.
- Find common inferences in all solutions for each cell group.
- Inference based on all solutions from advanced inference.
- Use inference with maximum probabilistic in all solutions.
- Inference based on random numbers.
- Basically, the auto mine-bot searches moves in this order(if no moves are generated, go to next move):
Naive -> advanced -> probabilistic -> random
.
Test 40 * 40 shape board with mine rate being 0.050, 0.075, …, 0.250.
Test 1000 rounds of games for each mine rate.
Settings in windows version(from wikipedia):
-
Primary: 8 × 8, 10mines(Windows 98or before)/9 × 9, 10mines(Windows 2000or later)
-
Medium: 16 × 16, 40mines
-
Advanced: 30 × 16, 99mines
$ python play.py
# Type `[rows] [cols] [mines] man / auto` to start a game.
# e.g., `20 30 30 auto`
# In manual mode, use `[operation] [row] [col]` to uncover / mask a cell.
# In auto mode, default sleep 0.05s each move so that you can see the precess clearly.