Minefield Sweep
Mine puzzles need clear state and safe first moves; I built a JavaScript grid game with delayed mine placement, recursive reveal, flag mode, difficulty switching, timer/best-time state, and accessible cell labels.
- Status
- Accessible prototype / live demo
- Last updated
- May 2026
- Controls
- Reveal cells, mark suspected mines, switch difficulty, and clear the field without triggering a mine.
- Keyboard
- Focus a cell, use Arrow keys to move, Enter or Space reveals, F toggles a flag, and P or Escape pauses.
- Touch
- Tap to reveal, use Flag Mode to mark mines, and use Scout/Ranger/Warden buttons for difficulty.
- Accessibility
- The minefield is a keyboard-navigable board with live status, mines-left, timer, best-time, and cleared-percentage readouts.
Ready
Minefield ready.
Keyboard and touch controls
Keyboard shortcuts
- Arrow keysMove focus between cells on the board.
- Enter / SpaceReveal the focused cell, or flag it when Flag Mode is on.
- FToggle a flag on the focused cell.
- P / EscPause or resume the current field.
- Difficulty arrowsMove between Scout, Ranger, and Warden when difficulty buttons are focused.
Touch controls
- Tap cellReveal a cell in sweep mode.
- Flag ModeTurn it on, then tap cells to place or remove flags.
- Difficulty buttonsChoose Scout, Ranger, or Warden before or between fields.
Board generation, reveal flow, and accessible cell state.
Main state includes difficulty config, mine positions, revealed cells, flags, timer, first-click status, cleared percentage, best time, and game status. The loop is event-driven rather than continuous: clicks, key presses, or difficulty changes update board state and then re-render the grid. Mine placement waits for the first reveal so the first move can stay safe. Reveal logic expands empty regions recursively, counts adjacent mines, toggles flags, and checks win/loss conditions; scoring is represented by clear time and completion percentage. Keyboard users can focus cells, move with Arrow keys, reveal with Enter or Space, and flag with F. Touch uses tap-to-reveal and Flag Mode. The lesson was treating every cell as stateful UI with labels, focus, and game state.
Mine placement, reveal logic, and accessible board state.
- Implemented delayed mine placement, safe first reveal, adjacent counts, recursive empty-cell reveal, flag toggling, and win/loss state.
- Built difficulty switching, timer/best-time persistence, mines-left tracking, cleared-percent updates, pause/restart controls, and touch flag mode.
- Rendered the board as a keyboard-navigable grid with roving focus, row/column labels, live announcements, and state-specific cell descriptions.
Minesweeper-style rules are the reference; this board generation, reveal state, difficulty model, and UI treatment are custom code.
Accessible prototype with testable logic still to add.
Already solid includes safe first reveal, recursive clearing, flag mode, difficulty state, keyboard navigation, live announcements, and cell labels. Prototype-only areas include limited automated tests and simple local best-time persistence. Hardening would add reveal/flag tests, focus regression checks, difficulty validation, reset controls, and assistive-tech QA.
Static logic game with difficulty config in source.
Hosted/run location: GitHub Pages serves minefield-sweep.html, minefield-sweep.css, and minefield-sweep.js. Environment/config: no environment variables are required; difficulty sizes, mine counts, timer behavior, and reveal logic are client-side JavaScript. External APIs/services: none beyond DOM events, keyboard/touch input, and LocalStorage for best times. Local development: run python -m http.server 8000 and open /minefield-sweep.html. Security: game state is local and no user data is transmitted.