npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

minesweeper-ultimate

v1.0.0

Published

Minesweeper API.

Downloads

3

Readme

Minesweeper API · Build Status

Game State

The Minesweeper game is internally represented by a 2D array of integers. See below for the range of integer values and their meanings.

Cell State Legend:

  • 0: Unvisited, no bomb

  • 1: Unvisited, bomb

  • 2: Visited, no bomb

  • 3: Unvisited, no bomb, flagged

  • 4: Unvisited, bomb, flagged

A client to this API interacts with the internal board state via the public game grid, a 2D array of strings representing what the player sees when they play the game.

API

Public Methods:

  • checkCell - Select a cell to sweep for a bomb.
  • flagCell - Flag a cell as possibly having a bomb.
  • cellIsFlagged - Check if a cell is flagged.
  • getNumRows - Returns height of underlying matrix i.e. number of rows.
  • getNumColumns - Returns width of underlying matrix i.e. number of columns.
  • getNumBombs - Returns number of bombs in matrix.
  • getStatus - Returns game status e.g. won, lost, or in-progress.
  • getGrid - Returns a 2D array of strings representing what the player sees when they play the game.

Usage

// require statement
const MinesweeperGame = require('minesweeper-ultimate');

// import statement
import MinesweeperGame from 'minesweeper-ultimate';
const game = new MinesweeperGame(/* difficulty */, /* options */);

Difficulty setting is required. If difficulty set to 'custom', options are required, otherwise they are unused.

Difficulty Settings:

  • 'easy'
  • 'medium'
  • 'hard'
  • 'custom'

Options Interface:

{
  n: /* number of rows */,
  m: /* number of columns */,
  b: /* number of bombs */
}
game.checkCell(/* row */, /* column */); /* --> void */

/*
Checks a cell for a bomb. If cell does not have a bomb, counts surrounding bombs. If surrounding bomb count is zero, sweeps grid until it has found cells with a bomb count. Returns void i.e. implicit return of undefined.
*/
game.flagCell(/* row */, /* column */); /* --> void */

/*
Updates board state to indicate cell is flagged. Can only flag unvisited cells. Returns void i.e. implicit return of undefined.
*/
game.cellIsFlagged(/* row */, /* column */); /* --> boolean */

/*
Returns true if cell is flagged and false if not.
*/
game.getNumRows(); /* --> integer */

/*
Returns height of underlying matrix i.e. number of rows.
*/
game.getNumColumns(); /* --> integer */

/*
Returns width of underlying matrix i.e. number of columns.
*/
game.getNumBombs(); /* --> integer */

/*
Returns number of bombs in matrix.
*/
game.getStatus(); /* --> string */

/*
Returns game status as a string e.g. won, lost, or in-progress.
*/
game.getGrid(); /* --> [][]string */

/*
Returns a 2D array of strings representing what the player sees when they play the game.
*/