Show HN: Minesweeper
madprops.github.ioVery nice readable source code.
One feature request I'd have is allowing users to skip flags. I usually play minesweeper fast and don't set any flags. The game should end when I opened all fields without hitting a bomb, at least that's how others minesweeper implementations work (e.g. https://www.google.com/fbx?fbx=minesweeper). Maybe
if (num_revealed = x*y-num_bombs) Mine.over = true
The google one also seems to guarantee that the first click opens a whole field, never just one number or bomb. Not sure how they do that but it make the game more enjoyable.
Thank you. I made some improvements including your suggestions. For the field-on-first click procedure I just reserved some space around the clicked item when placing the mines and that seems to work, though the size of the fields can be different. I'm thinking of maybe implementing some grid generation algorithm where guessing is not not necessary. The minesweeper here is supposed to do just that: https://www.chiark.greenend.org.uk/~sgtatham/puzzles/ "The first square you open is guaranteed to be safe, and (by default) you are guaranteed to be able to solve the whole grid by deduction rather than guesswork. (Deductions may require you to think about the total number of mines.)"