Node-chess
A fully isomorphic and extensible chess engine with position analysis, board analysis, and computer opposition.
What does it do? How is it extensible?
Node-chess allows you extend the board and add your own rules. The analysis engine and computer player will automatically factor these changes/additions into their calculations and adjust accordingly.
With node-chess you can:
- define your own pieces and modify existing pieces
- (re-)define their notation, movement, value, and capture logic
- add, change, and remove rules such as win and loss conditions
- extend the existing engine to improve the calculations for your own variants
Installation
Add it as a dependency to your project
npm install node-chess
In the browser
The engine comes with a 'classic' implementation of Chess.
var chess = ;var game = chessclassic;
Using the board
// Move the E2 pawn to E4game; // Move the B8 knight to C6 game; // Try and make an invalid move// No piece is on B8game; === null; // true // Promotion// To a queen (by default)game; // To a rookgame; // Print the available moves of the C6 knight to the consoleconsole;
Defining your own pieces
The 'super knight' moves 3 squares laterally before moving 1 square on the opposite axis!
var Direction = ;var customEngine = ; var upLeft = ;var upRight = ; var downLeft = ;var downRight = ; var leftUp = ;var leftDown = ; var rightUp = ;var rightDown = ; { return canCapture: true canMove: true transforms: file: file rank: rank canJump: true } var superKnight = name: "SuperKnight" movement: upLeft upRight downLeft downRight leftUp leftDown rightUp rightDown canQueen: false canSpawn: true value: 35 notation: "s" customEnginepieces;