Socket
Book a DemoInstallSign in
Socket

polyglot-chess

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyglot-chess

Polyglot is a node module to search moves in polyglot format opening books.

0.1.6
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Polyglot

Polyglot is a node module to search moves in polyglot format opening books. For a description of the polyglot book format refer to this link.

Installation

Make sure you have node.js installed. Then do:

$ npm install polyglot-chess

Example

var Polyglot = require('polyglot-chess');

var obj = new Polyglot();

var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
console.log("Polyglot hash for fen " + fen + " is: " + obj.hash(fen));
console.log("Best move in the book is: " + obj.find(fen, "book.bin", true));
console.log("Random move in the book is: " + obj.find(fen, "book.bin", false));

API

Functions

Polyglot exposes following functions -

find(fen, bookFile, findBest)

find takes a fen string and a book file path and looks up the hash in the book file. If findBest is true it returns the best move according to the weight otherwise it returns a random move with the given hash. The chance of a random move being returned is in proportion to its weight. If no move is found it returns an empty string.

hash(fen)

hash takes a fen string and returns its polyglot hash.

Linting

To lint the js files with jshint run the command:

$ grunt lint

Running Tests

To run the tests with mocha run the command:

$ grunt test

Contributing

Fork, pick an issue to fix from issues or add a missing feature and send a pull request.

Credits

This work is derivative of the excellent stockfish polyglot book source code.

License

Polyglot is released under the MIT License. See the bundled LICENSE file for details.

Keywords

chess

FAQs

Package last updated on 30 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.