minesweeper-board
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Minesweeper-board

A fast, lightweight Node module for generating minesweeper boards.

install size weekly downloads

Installation:

npm i minesweeper-board

# or

yarn add minesweeper-board

Usage:

//cjs:
const { Board } = require('minesweeper-board');

//mjs:
import { Board } from 'minesweeper-board';

const board = new Board(5, 5); //dimension, mines
console.log(board.getBoard());

example 5x5 board:

$ node dist/tests/test
[
  [
    Cell { hasMine: false, id: 'A0' },
    Cell { hasMine: false, id: 'A1' },
    Cell { hasMine: false, id: 'A2' },
    Cell { hasMine: true, id: 'A3' },
    Cell { hasMine: true, id: 'A4' }
  ],
  [
    Cell { hasMine: false, id: 'B0' },
    Cell { hasMine: false, id: 'B1' },
    Cell { hasMine: false, id: 'B2' },
    Cell { hasMine: false, id: 'B3' },
    Cell { hasMine: false, id: 'B4' }
  ],
  [
    Cell { hasMine: false, id: 'C0' },
    Cell { hasMine: false, id: 'C1' },
    Cell { hasMine: true, id: 'C2' },
    Cell { hasMine: false, id: 'C3' },
    Cell { hasMine: false, id: 'C4' }
  ],
  [
    Cell { hasMine: false, id: 'D0' },
    Cell { hasMine: false, id: 'D1' },
    Cell { hasMine: false, id: 'D2' },
    Cell { hasMine: true, id: 'D3' },
    Cell { hasMine: true, id: 'D4' }
  ],
  [
    Cell { hasMine: false, id: 'E0' },
    Cell { hasMine: false, id: 'E1' },
    Cell { hasMine: false, id: 'E2' },
    Cell { hasMine: false, id: 'E3' },
    Cell { hasMine: false, id: 'E4' }
  ]
]
  • hasMine: indicates if the cell has a mine or not.
  • id: a string that can be used to identify a cell.

Readme

Keywords

Package Sidebar

Install

npm i minesweeper-board

Weekly Downloads

5

Version

1.1.2

License

MIT

Unpacked Size

6.26 kB

Total Files

10

Last publish

Collaborators

  • ayanthedev