Seikho / node-chess

Extensible Chess engine in JavaScript
21 stars 3 forks source link

Provide API for using UCI chess engines #33

Open lawlesscreation opened 8 years ago

lawlesscreation commented 8 years ago

Hi,

I'm wondering if node-chess can be used to carry out board/game analysis, similar to Stockfish JS, where you could give a fen string or board position and node-chess analyses and scores the board in favour of white or black. Similar to http://forwardcoding.com/projects/ajaxchess/chess.html.

It looks like node-chess has a configurable analysis engine with depth and time options but I cannot see any documentation or examples of how this analysis messaging can be displayed to the user.

Thanks for any help.

Seikho commented 8 years ago

I've basically decided that an analysis engine for this would be too difficult at the moment.
However it wouldn't be too laborious to provide an API for attaching a UCI engine. Something like:

import * as stockfish from "stockfish";
const game = chess.classic.engine();
const analyzer = new stockfish();
game.analyzer(analyzer.postMessage);

analyzer.onmessage = event => { /* stuff ... */ }

game.analyze({ /* options ... */ });

If you're happy with that, I can work on that this week.

lawlesscreation commented 8 years ago

Thanks for the response Seikho. That could be a neat feature but we were looking for something that had the analysis engine already. Sadly Stockfish (and therefore Stockfish JS) is GPL licensed which means we cannot use it this time :(

Seikho commented 8 years ago

No problem. I used stockfish as an example. The API would take any UCI chess engine.

lawlesscreation commented 8 years ago

You wouldn't happen to know of any UCI chess engines written in JavaScript or emscripten port? We've not been able to find any other than Stockfish JS.

Seikho commented 8 years ago

The engine you linked should be using UCI. Does that have a compatible license?

Seikho commented 8 years ago

Are you able to use GPLv3?

lawlesscreation commented 8 years ago

Garbochess-JS has a BSD license which is great but it doesn't look like it has changed since 2012 and had limited documentation.

Sadly we cannot using GPLv3 because we cannot open-source our code, at least in the short-term.

Seikho commented 8 years ago

The documentation definitely is poor, but seems to have the same API as stockfish. Apparently it has a playing strength of ~2600 ELO as well.

lawlesscreation commented 8 years ago

Thanks for you're help Seikho. I think we'll give that a shot until we can open-source our code and use Stockfish :)