The most complete minesweeper game built with React, Redux and Immutable.js.
- Custom game board and three different major difficulty.
- Counting Time.
- Mines left.
- Set flags.
- Quick mode and mode switch.
- Settings save in cookie.
- Generate non-guessing game.
Seriously !?
git clone this project, then.
cd minesweeper
npm install
npm start
Head to localhost:8000.
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';
An immutable Record store in each block. Check out immutable.js for methods.
const Block = Record({
type: 'normal',
mines: 0,
hidden: true,
flag: false
});
An immutable Record indicate the row and column of the block.
const BlockRecord = Record({
row: 0,
col: 0
});
An immutable Map represent the whole game board blocks, with BlockRecord
as keys and Block
as values.
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();
Clear the game board and reset the config settings. Return blocks
.
Reset and start the game. The exclude
take an array of BlockRecord
to exclude from being mine. Return blocks
.
Perform a single click on a block. Set a flag if mode
=== quick
, else reveal the block. Return a Promise with blocks
as argument.
Perform a right click on a block. Reveal the block if mode
=== quick
, else set a flag. Return a Promise with blocks
as argument.
- Record high score.
- Cleverly first click init.
- Mobile friendly.
- Game solver (hard, for non-guessing game).
- Completely switch to Immutable.js.
- Increase solver speed.
- Cover up loading screen.
- Write some tests.
- Generate hints by solver.
Issues, PRs, and all the advise and discussion are very welcome!
- muan/emoji: Great cross-platform emoji collection!
- Solving Minesweeper with Matrices By Robert Massaioli: Awesome and inspiring minesweeper solver algorithm.