stockfish-native
UCI interface for native Stockfish
Installation
npm install stockfish-native
Download or build the Stockfish engine from source. If necessary, mark the binary as executable.
Usage
stockfish-native
provides methods thinly wrapping the UCI commands supported by the stockfish engine.
For better type checking, the results and options are explicitly typed and parsed instead unlike the strings UCI operates on.
Most operations are asynchronous and return a promise. If a command is send before the previous command has been returned, it will be queued and run after the previous commands complete.
Create an engine instance
; ;
Spawns the engine, and any sets the provided UCI options.
Options
;
Search the position
;
Search for the best move from the current position.
Note: If the infinite option is passed, searching will continue until engine.stop() is called.
Options
;
Evaluate the position
;
Get the score and detailed evaluation for the current position.
Set the position
engine.positionposition;
Set the position used by eval
and search
.
Start a new game
await engine.newgame;await engine.position; // reset to start position
Quit
await engine.quit;
Quits the engine after all previous commands have finished.
Kill
engine.kill;
Immediately kill the engine.
Note: If there are active commands they will not resolve.
TypeScript
stockfish-native
is written in TypeScript - no types install!
Development
Available Scripts
In the project directory, you can run:
npm run build
Builds the package using typescript into ./lib
npm test
Launches the Jest to run tests.
npm run lint
Checks code for style issues and syntax errors with TSLint and Prettier.
npm run lint:fix
Checks code for style issues and syntax errors with TSLint and Prettier, attempting to fix them when possible.
Publishing a new version
Travis is configured to run deploys on tags.