Minesweeper
The most complete minesweeper game built with React, Redux and Immutable.js.
Install / Use
/learn @kevin940726/MinesweeperREADME
minesweeper
The most complete minesweeper game built with React, Redux and Immutable.js.

Features
- [x] Custom game board and three different major difficulty.
- [x] Counting Time.
- [x] Mines left.
- [x] Set flags.
- [x] Quick mode and mode switch.
- [x] Settings save in cookie.
- [x] Generate non-guessing game.
How to Play
Seriously !?
Build
git clone this project, then.
cd minesweeper
npm install
npm start
Head to localhost:8000.
API
You can find the logic of the game in ./src/minesweeper.js. If you don't like the UI or you want to make a enhancement, import it to your custom UI.
import Minesweeper, { Block, BlockRecord } from './src/minesweeper.js';
Block:
An immutable Record store in each block. Check out immutable.js for methods.
const Block = Record({
type: 'normal',
mines: 0,
hidden: true,
flag: false
});
BlockRecord:
An immutable Record indicate the row and column of the block.
const BlockRecord = Record({
row: 0,
col: 0
});
Blocks:
An immutable Map represent the whole game board blocks, with BlockRecord as keys and Block as values.
Minesweeper():
Create the game board, load initial data. There are some game data you can get:
rows: (Int) Game board rows.cols: (Int) Game board columns.mines: (Int) Game board mines.minesRemaining: (Int) How many mines left without flagged.blocks: (Immutable Map) An immutable Map data for each blocks in the game board.status: (String)ready: Ready to play the game before first click.playing: Playing the game after first click.win: Clear the game board without hitting mines.lose: Hit a mine.
timePass: (Int) Current time pass in the game.mode: (String)regular: Regular game mode. Single click to reveal the block, right click to set a flag.quick: Quick mode. Single click to set a flag, while right click will reveal the block.
flagMode: (Boolean) Quick mode for the game or not.checkIsSolvable: (Boolean) Generate non-guessing game or not.
const game = Minesweeper();
Minesweeper::reset(rows, cols, mines, quickMode):
Clear the game board and reset the config settings. Return blocks.
Minesweeper::init(rows, cols, mines, quickMode, exclude):
Reset and start the game. The exclude take an array of BlockRecord to exclude from being mine. Return blocks.
Minesweeper::singleClick(BlockRecord):
Perform a single click on a block. Set a flag if mode === quick, else reveal the block. Return a Promise with blocks as argument.
Minesweeper::rightClick(BlockRecord):
Perform a right click on a block. Reveal the block if mode === quick, else set a flag. Return a Promise with blocks as argument.
TODO
- [ ] Record high score.
- [x] Cleverly first click init.
- [ ] Mobile friendly.
- [x] Game solver (hard, for non-guessing game).
- [x] Completely switch to Immutable.js.
- [ ] Increase solver speed.
- [x] Cover up loading screen.
- [ ] Write some tests.
- [ ] Generate hints by solver.
Contribute
Issues, PRs, and all the advise and discussion are very welcome!
Special Thanks
- muan/emoji: Great cross-platform emoji collection!
- Solving Minesweeper with Matrices By Robert Massaioli: Awesome and inspiring minesweeper solver algorithm.
