121

Is it possible for some unlucky guy to hit a mine when they click the first square randomly?

  • 2
    Tangentially related on Puzzling.SE: Is it always safe to start on the lower left-hand corner? – antimo Aug 3 '17 at 11:01
  • 1
    Oddly I have been making a minesweeper clone lately and solving this issue was on my todo list. (Also don't forget to mark an answer as accepted.) – Pharap Aug 4 '17 at 2:29
  • @Pharap Solving it should be pretty trivial. If you keep a list of spaces without mines, pick one at random and swap its contents with whatever square the user first clicked on. – jamesdlin Aug 4 '17 at 10:47
  • @jamesdlin Oh I know, it's not a hard problem, my solution was going to be different from the canonical solution though. – Pharap Aug 4 '17 at 12:12
  • 2
    I did a minesweeper game during my first semester in college and generating the map after first click was a very trivial thing. – Sulthan Aug 6 '17 at 8:08
128

It is impossible to click a mine on the first click, at least in Windows 98. If a mine is under the first clicked tile, it is moved to the upper-left corner, if the upper left corner is occupied, the mine moves to the right of the corner tile. It does not appear the behavior has changed since then.

Source

  • 4
    On newer versions (Win 7+) it should be possible to hit a mine with the first click. – dly Aug 2 '17 at 6:40
  • 2
    What if all four corners are occupied? – nalzok Aug 2 '17 at 8:34
  • 6
    @SunQingyao It's not trying the right corner, it's trying the left corner +1 (e.g. one step right). If the top row is full, it tries the next row. This could only fail if the entire board were full of mines, which I believe is not allowed in the game configuration. – Samthere Aug 2 '17 at 9:46
  • 46
    @dly That's only possible if you restart the same game, keeping the mines in the same places. Under normal conditions, Win7 Minesweeper doesn't generate the board until after the first click, and it also ensures that the first click is always a 0. – Toomai Aug 2 '17 at 10:30
  • 4
    I have tried this on this link: copy.sh/v86/?profile=windows98 and it seems it is correct. There's no way to lose on the first click and I have deleted the other answer I had provided before. – John Hamilton Aug 2 '17 at 14:15
105

No, it is (normally) not possible to hit a mine on the first click in Microsoft's implementation of Minesweeper.

It is pretty easy to convince yourself that it is impossible to lose on the first click. Here's a test that I do to gauge the quality of other Minesweeper implementations: Run Minesweeper, create a custom game, and set the board size and number of mines to their maximum allowed values. The Windows 7 version of Minesweeper allows a 24x30 board with 668 mines (92.7% of the board). Start a game, click a random square. Create a new game, repeat. Do it a few more times. The probability that all your first clicks happen to be lucky quickly gets very small (e.g., after 5 times, the probability that you got lucky on all your first clicks drops to (1 - 0.927)5 ≈ 0.000002). Since that is so improbable, the game must be guaranteeing that the first click is always safe. (If that low probability doesn't convince you, keep repeating until it's low enough that it does.)

Additionally, on Windows 7 and later, if you choose to restart a game (with tips enabled), Minesweeper shows a message:

The mines are in the same position as last game. Be careful! You can lose on the first click.

The last sentence implies that normally you cannot lose on the first click.

Finally, as noted in another answer, old versions of Minesweeper had an xyzzy cheat code that indicated whether a square contained a mine. However, when enabling this cheat, clicking on a square that is reportedly a mine will not reveal a mine for the first click, providing further evidence that the game has special logic to prevent a first-move loss. (I have verified that this is true at least as far back as Windows 3.1.)

  • 16
    So if the objective is to make sure there are no mines, and the mines only get placed after your first click... does that mean someone who ends the game without clicking would have completed the objective? – Stephan Bijzitter Aug 3 '17 at 10:20
  • 27
    @StephanBijzitter The only winning move is not to play? – Malco Aug 3 '17 at 13:23
  • Yes, that happened to me years, years ago. However, I can't prove it. But did happened, at least once. – Delonix R. Aug 3 '17 at 15:53
  • @StephanBijzitter the objective is to know where the mines are and which spots are safe. Technically, for the first step, all spots are, though. – Chieron Aug 3 '17 at 17:43
  • 4
    @StephanBijzitter Until the first click, the game is simultaneously lost and won. =P ... well, actually, the objective of the game is to reveal all non-mine squares, so no, you have not won without clicking. – jamesdlin Aug 3 '17 at 18:23
7

Yes, in older versions of Windows.

In versions of Windows up to XP Service Pack 3, if you hold shift and type "XYZZY", release shift, then hold shift again, you can hover your mouse over each square in turn and see whether it has a mine or not by looking at the upper-left corner of your screen (source: Wikipedia). Clicking on a mine will lose.

  • 3
    I just tested it. It doesn't work. – Frank Aug 4 '17 at 3:29
  • 1
    @frank or Wikipedia, if you prefer: en.m.wikipedia.org/wiki/Xyzzy_(computing) – fectin Aug 4 '17 at 3:29
  • 5
    Just in case people doubt, I want to verify that this DID work at one point in time. I did this a long time ago on Windows 3.1, and made my dad think for a moment I had amazing skill (he was very entertained when i showed him a single white pixel appeared on-screen to show me the mines lol we had fun) – NOP Aug 4 '17 at 18:31
  • 1
    I remember the "xyzzy" cheat code. However, the way I remember it in Windows 3.1, even if it told you that the first square was a mine, clicking on it would still swap it for a non-mine square. – jamesdlin Aug 4 '17 at 19:22
  • 5
    Likewise, I remember this in XP and 2000. However, according to this post in /r/minesweeper, the xyzzy cheat was removed in Windows 7: reddit.com/r/Minesweeper/comments/5yitcc/… Edit: The linked wikipedia page states "The easter egg does not exist in versions after Windows XP SP3." – WindowsEscapist Aug 5 '17 at 1:18

protected by Jutschge Aug 7 '17 at 15:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.