💣 MINESWEEPER

Ten mines, eighty-one squares, and nothing but logic

← Back to Fun Time
Mines left
10
Time
0
Opened
0
Best time

⌨️ Controls

  • Left click a square to dig  •  right click to flag it
  • On a phone: tap to dig, press and hold to flag
  • move  •  SPACE dig  •  F flag
  • P pause  •  R new game
  • 🎮 Xbox controller? Just plug it in or pair it — the stick and D-pad are the arrow keys, A is SPACE, Menu pauses and View starts again

🎯 How to play

  • The number on a square says how many of the eight squares around it are mines.
  • A square with no number has no mines near it at all — so its neighbours open too.
  • Your first click is always safe. Dig anywhere to start.
  • You win by opening every square that is not a mine. Flags are just notes to yourself.

🏆 Getting good

  • If a 1 already has one flag beside it, every other neighbour is safe.
  • If a 3 has exactly three covered neighbours, all three are mines.
  • Work along the edges of the opened area — that is where the clues are.
  • Stuck? There is usually a square somewhere else you can still work out.

🧑‍💻 For young coders: build this game yourself

This game is split into small library files inside funtime/lib/, and every function has a comment saying exactly what goes in, what comes out, and the algorithm in plain English. Empty any function out, read its comment, and write it yourself.

File What it does Good functions to try re-writing
lib/mines-rules.js The rules: the neighbours, the mines, the flood fill neighbours, countMines, placeMines, revealCell
lib/mines-draw.js Painting the squares, the flags and the mines drawCovered, drawFlag, renderGame
lib/mines-main.js The glue: left click, right click, long press doAction, connectBoard, gameLoop

💡 The big idea: flood fill. Keep a to-do list of squares; take one off, deal with it, and if it is blank put its neighbours on the list. When the list is empty you are finished. That is how one click opens a whole field — and how the paint bucket works in every drawing program.

🛠️ Want to be walked through it? Build Minesweeper Yourself takes you through the key functions one step at a time and tests each one you write. There is a Python version too.