Settings

Theme

Show HN: Minesweeper

madprops.github.io

4 points by madprops 5 years ago · 2 comments

Reader

mtmail 5 years ago

Very 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.

  • madpropsOP 5 years ago

    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.)"

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection