
The mechanism of uncovering all tiles with zero value is a good exercise in recursive functions - the function calls itself multiple times.ġ. Play the game by clicking the tiles on top of the page!Ĭoding this game in JavaScript is a lot of fun, since it is a relatively short and easy algorithm, but at the same time quite interesting. This allows you to simulate different scenarios - you can place a question mark and then verify if the neighboring tiles have the correct numbers. A question mark is placed if you suspect a mine might be there, but you're not certain. This reduces the count of mines remaining. You place a flag when you are sure the tile has a mine. Right-clicking on a tile toggles between flag, question mark and hidden. You repeat the process until all safe tiles are revealed. Based on the revealed numbers, you calculate which of the neighboring tiles contain mines, mark them with a flag and click on the safe ones to reveal them. Otherwise, the tile will show the sum of mines in the eight neighboring tiles. When you click a tile, its content is revealed. The point of the game is to uncover all the tiles except the ones containing the mines. The board consists of rows and columns of tiles, some of which contain a mine. If you're older than 30, let me remind you the rules, since at our age memory no longer serves us well: If you're younger than 30, let me teach you the rules.

It probably led to millions of hours of productivity wasted when people played it at work.
#Rules of minesweeper windows#
Let's bring the 1989 Minesweeper game back to life!Īctually the game is much older, but it gained worldwide fame after it was bundled with Windows 3.1. The Minesweeper game in 100 lines of JavaScript
