Minesweeper, swept by Hazel's rules

Hazel activities › one-player games · source on GitHub · hazeljs on npm

Open every cell that hides no mine. A number says how many of the cell's eight neighbours are mines. Tap to open; flag a mine with a right click, a long press, or 🚩 mode; tap a number whose mines are all flagged to open the rest around it. The first tap is always safe. The mines, the counts, the opening and the flags are a Hazel program, shown beside the board.

⏳ Loading Hazel (hazeljs from jsDelivr), whose rules lay the mines and open the cells.
💣 10🙂⏱ 0

This app needs JavaScript, and a page served over http (python3 -m http.server, then localhost).

The vocabulary every module sees (minesweeper/rules/preamble.hz). The listings are text, highlighted, until Edit in Hazel opens each in Hazel's own editor; an edit changes the next tap.

loading preamble.hz…
Board a fresh board, the mines laid after the first tap (never beside it), and each cell's count
loading Board.hz…
Play a cell opened (an empty region floods open), a flag, a chord, and the end. The page calls (fresh, lay, reveal, flag, chord, flags).
loading Play.hz…
Hint the 💡 hint: a sure move worked out from the open numbers alone (a safe cell, a mine to flag, or a flag on a safe cell) and the number that shows it. The page calls sure.
loading Hint.hz…
Guess when no number alone shows a sure move: the odds of a mine in each closed cell, from every way the mines can lie that meets all the numbers, and the cell least likely to be one (🤖's guess, and 💡's when there is no sure move). The page calls pick.
loading Guess.hz…

hazeljs-examples · versions · Apache 2.0 (code), CC BY 4.0 (words, the icon) · by Matthew Hammer · an example for hazeljs