https://nikitalurye.com/minesweeper2/

My friend used to play my old Minesweeper game a bunch, but he was complaining about 50/50s and how it wasn’t hard, but just annoying. I took that as a challenge and made a new version of Minesweeper which is guaranteed to be solvable without guessing. I added difficulty settings that actually make the game easier or harder without changing the mine density.

My idea was that, if I have a solver that can solve the game, I can just generate random boards and check if the solver can solve them. If it can’t, I can just regenerate the board. This works well, but it is slow. What I actually do is start with an empty board and repeatedly add mines to random squares until I have the desired mine density. At each step I run the solver to see if it can solve the board. If it can’t, I remove the last mine I added. If it gets stuck in a loop, I remove all the mines and start over. This way I can guarantee that the board is solvable without too much trial and error. Additionally, I launch this generator on multiple threads and take the first thread that finishes. This way I can generate boards much faster.

The difficulty slider controls the types of deductions the solver is allowed to make. On easy, the solver can only make the most basic deductions referring only to one number cell at a time. On medium and hard, the solver can make more advanced deductions referring to multiple number cells at a time through brute force checking every possible mine configuration. The solver is not very optimized, and optimizing it would result in significantly faster generation times. I hope to do that in the future.