stockfish.js
stockfish.js copied to clipboard
Readable output from Stockfish 10.
I am currently running Stuckfish the following way.
var stockfish = new Worker("stockfish.js");
stockfish.postMessage("position fen " + currfen)
stockfish.postMessage("go depth 21");
stockfish.onmessage = function(event) {
console.log(event.data ? event.data : event);
}
Of course the output is very messy. Two questions. Is there a way to filter to the best line calculated so far? Also, the lines are usually in long algebraic notation, is there a way to use short algebraic notation? Thanks.
About the first question, in my project, I use a simple string matching of the incoming message. Something like this:
stockfish.onmessage = function(e) {
if (typeof e !== 'string') return;
if (e.startsWith('bestmove')) {
const bestMove = e.split(' ')[1];
}
}