chess-legal-moves
TypeScript icon, indicating that this package has built-in type declarations

2.3.2 • Public • Published

♔ Chess legal moves

Contributor Covenant

Analyses a given chess game position in Fen notation to return legal moves and provides the next game position after a given move

API reference

This lib exposes a Game class, its constructor takes a string representing a snapshot of a chess game in FEN notation. You can then use legalMoves, kingState properties and addMove() method.

legalMoves property is an array containing all legal moves in UCI notation

kingState property gives you the state of the game (isCheck, isCheckmated, isDraw).

Installation

  • with npm
npm install chess-legal-moves
  • with yarn
yarn add chess-legal-moves

Usage

Import the Game class from the library and pass its constructor a FEN string. As an example the following FEN string represents a game starting position. Learn about FEN notation

import Game from 'chess-legal-moves';
const game = new Game('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
const possibleMoves = game.legalMoves;
const kingState = game.kingState;

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.3.29latest

Version History

VersionDownloads (Last 7 Days)Published
2.3.29
2.3.10
2.3.00
2.2.00
2.1.00
2.0.90
2.0.80
2.0.70
2.0.00
1.0.20
1.0.10
0.0.350
0.0.340
0.0.330
0.0.320
0.0.310
0.0.300
0.0.290
0.0.280
0.0.270
0.0.250
0.0.240
0.0.230
0.0.220
0.0.210
0.0.200
0.0.190
0.0.180
0.0.170
0.0.160
0.0.150
0.0.140
0.0.131
0.0.110
0.0.90
0.0.80
0.0.70
0.0.60
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i chess-legal-moves

Weekly Downloads

10

Version

2.3.2

License

MIT

Unpacked Size

111 kB

Total Files

75

Last publish

Collaborators

  • colinfaivre