I am about to design my own minesweeper in Java. And while analyzing the real windows 7 minesweeper, I came across this situation.
The uncovered square(pointed by arrow), may be 1 or mayn't have any number(an开发者_JS百科 empty square). But in windows 7 minesweeper, this square has 1.
hypothesis: And by analyzing I came to know that all the mines are always surrounded by numbers.
If I go with my hypothesis, then no other go, the uncovered square should be 1.
And designing the logic for the minesweeper will be easier, if I follow this hypothesis. since,
step 1: Randomly assign the squares with mines.(Make the specific (i,j)element in the 2D array to be -1).
step 2: Number each square, equal to the number of mines surrounding it. (In this case, the hypothesis became true).
And my questions are,
- What wrong if the uncovered square is an empty square?
- Does that hypothesis is the rule in minesweeper?
- Does I have to follow the hypothesis, to make my coding simpler to implement?
- *If I proposed a new minesweeper with the rule against the hypothesis, does my new minesweeper will end up in instability?Is so,how?
*->I am not intentionally breaking the rules, I try to removing redundant hint/keys to the user.
Of course the pointed square has a number - it is adjacent to (exactly one) mine square so it gets a 1. The empty squares are just shorhand for zero.
The square could not be unnumbered, the numbers represent how many mines are touching that square. Unnumbered squares are "0", meaning no mines touching.
So yes, a mine must always be surrounded by numbered squares.
The reason you don't see a number there is the fill algorithm of minesweeper.
It reveals all the fields which have a 0 value (0 is shown as empty). And it reveals all the adjacent fields to those revealed before, which have a non zero value.
The field in the corner does not have an adjacent zero value field and thus cannot be revealed automatically.
It carries a 1.
If you'd have a 10x11 field with the last row being empty, This field would be revealed with value 1.
The reason why the Windows version shows a one may be that you already marked all the existing mines with flags and so Windows Minesweeper reveals all the remaining fields.
精彩评论